Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / storage / browser / quota / quota_client.h
blob624a3f2ca148892988ea673e8ff4fc5b3a867753
1 // Copyright 2013 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.
5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_CLIENT_H_
6 #define STORAGE_BROWSER_QUOTA_QUOTA_CLIENT_H_
8 #include <list>
9 #include <set>
10 #include <string>
12 #include "base/callback.h"
13 #include "storage/browser/storage_browser_export.h"
14 #include "storage/common/quota/quota_types.h"
15 #include "url/gurl.h"
17 namespace storage {
19 // An abstract interface for quota manager clients.
20 // Each storage API must provide an implementation of this interface and
21 // register it to the quota manager.
22 // All the methods are assumed to be called on the IO thread in the browser.
23 class STORAGE_EXPORT QuotaClient {
24 public:
25 typedef base::Callback<void(int64 usage)> GetUsageCallback;
26 typedef base::Callback<void(const std::set<GURL>& origins)>
27 GetOriginsCallback;
28 typedef base::Callback<void(QuotaStatusCode status)> DeletionCallback;
30 virtual ~QuotaClient() {}
32 enum ID {
33 kUnknown = 1 << 0,
34 kFileSystem = 1 << 1,
35 kDatabase = 1 << 2,
36 kAppcache = 1 << 3,
37 kIndexedDatabase = 1 << 4,
38 kServiceWorkerCache = 1 << 5,
39 kServiceWorker = 1 << 6,
40 kAllClientsMask = -1,
43 virtual ID id() const = 0;
45 // Called when the quota manager is destroyed.
46 virtual void OnQuotaManagerDestroyed() = 0;
48 // Called by the QuotaManager.
49 // Gets the amount of data stored in the storage specified by
50 // |origin_url| and |type|.
51 // Note it is safe to fire the callback after the QuotaClient is destructed.
52 virtual void GetOriginUsage(const GURL& origin_url,
53 StorageType type,
54 const GetUsageCallback& callback) = 0;
56 // Called by the QuotaManager.
57 // Returns a list of origins that has data in the |type| storage.
58 // Note it is safe to fire the callback after the QuotaClient is destructed.
59 virtual void GetOriginsForType(StorageType type,
60 const GetOriginsCallback& callback) = 0;
62 // Called by the QuotaManager.
63 // Returns a list of origins that match the |host|.
64 // Note it is safe to fire the callback after the QuotaClient is destructed.
65 virtual void GetOriginsForHost(StorageType type,
66 const std::string& host,
67 const GetOriginsCallback& callback) = 0;
69 // Called by the QuotaManager.
70 // Note it is safe to fire the callback after the QuotaClient is destructed.
71 virtual void DeleteOriginData(const GURL& origin,
72 StorageType type,
73 const DeletionCallback& callback) = 0;
75 virtual bool DoesSupport(StorageType type) const = 0;
78 // TODO(dmikurube): Replace it to std::vector for efficiency.
79 typedef std::list<QuotaClient*> QuotaClientList;
81 } // namespace storage
83 #endif // STORAGE_BROWSER_QUOTA_QUOTA_CLIENT_H_