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_
12 #include "base/callback.h"
13 #include "storage/browser/storage_browser_export.h"
14 #include "storage/common/quota/quota_types.h"
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 {
25 typedef base::Callback<void(int64 usage)> GetUsageCallback;
26 typedef base::Callback<void(const std::set<GURL>& origins)>
28 typedef base::Callback<void(QuotaStatusCode status)> DeletionCallback;
30 virtual ~QuotaClient() {}
37 kIndexedDatabase = 1 << 4,
41 virtual ID id() const = 0;
43 // Called when the quota manager is destroyed.
44 virtual void OnQuotaManagerDestroyed() = 0;
46 // Called by the QuotaManager.
47 // Gets the amount of data stored in the storage specified by
48 // |origin_url| and |type|.
49 // Note it is safe to fire the callback after the QuotaClient is destructed.
50 virtual void GetOriginUsage(const GURL& origin_url,
52 const GetUsageCallback& callback) = 0;
54 // Called by the QuotaManager.
55 // Returns a list of origins that has data in the |type| storage.
56 // Note it is safe to fire the callback after the QuotaClient is destructed.
57 virtual void GetOriginsForType(StorageType type,
58 const GetOriginsCallback& callback) = 0;
60 // Called by the QuotaManager.
61 // Returns a list of origins that match the |host|.
62 // Note it is safe to fire the callback after the QuotaClient is destructed.
63 virtual void GetOriginsForHost(StorageType type,
64 const std::string& host,
65 const GetOriginsCallback& callback) = 0;
67 // Called by the QuotaManager.
68 // Note it is safe to fire the callback after the QuotaClient is destructed.
69 virtual void DeleteOriginData(const GURL& origin,
71 const DeletionCallback& callback) = 0;
73 virtual bool DoesSupport(StorageType type) const = 0;
76 // TODO(dmikurube): Replace it to std::vector for efficiency.
77 typedef std::list<QuotaClient*> QuotaClientList;
79 } // namespace storage
81 #endif // STORAGE_BROWSER_QUOTA_QUOTA_CLIENT_H_