1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
6#define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
7
8#include <set>
9#include <string>
10
11#include "base/basictypes.h"
12#include "base/files/file.h"
13#include "storage/browser/storage_browser_export.h"
14#include "storage/common/fileapi/file_system_types.h"
15#include "url/gurl.h"
16
17namespace base {
18class SequencedTaskRunner;
19}
20
21namespace storage {
22class QuotaManagerProxy;
23}
24
25namespace storage {
26
27class FileSystemContext;
28class QuotaReservation;
29
30// An abstract interface that provides common quota-related utility functions
31// for file_system_quota_client.
32// All the methods of this class are synchronous and need to be called on
33// the thread that the method name implies.
34class STORAGE_EXPORT FileSystemQuotaUtil {
35 public:
36  virtual ~FileSystemQuotaUtil() {}
37
38  // Deletes the data on the origin and reports the amount of deleted data
39  // to the quota manager via |proxy|.
40  virtual base::File::Error DeleteOriginDataOnFileTaskRunner(
41      FileSystemContext* context,
42      storage::QuotaManagerProxy* proxy,
43      const GURL& origin_url,
44      FileSystemType type) = 0;
45
46  virtual void GetOriginsForTypeOnFileTaskRunner(storage::FileSystemType type,
47                                                 std::set<GURL>* origins) = 0;
48
49  virtual void GetOriginsForHostOnFileTaskRunner(storage::FileSystemType type,
50                                                 const std::string& host,
51                                                 std::set<GURL>* origins) = 0;
52
53  // Returns the amount of data used for the origin for usage tracking.
54  virtual int64 GetOriginUsageOnFileTaskRunner(
55      storage::FileSystemContext* file_system_context,
56      const GURL& origin_url,
57      storage::FileSystemType type) = 0;
58
59  // Creates new reservation object for the origin and the type.
60  virtual scoped_refptr<QuotaReservation>
61      CreateQuotaReservationOnFileTaskRunner(
62          const GURL& origin_url,
63          FileSystemType type) = 0;
64};
65
66}  // namespace storage
67
68#endif  // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
69