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,
38 kServiceWorkerCache
= 1 << 5,
39 kServiceWorker
= 1 << 6,
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
,
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
,
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_