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.
5 #ifndef WEBKIT_QUOTA_QUOTA_CLIENT_H_
6 #define WEBKIT_QUOTA_QUOTA_CLIENT_H_
12 #include "base/callback.h"
13 #include "googleurl/src/gurl.h"
14 #include "webkit/quota/quota_types.h"
15 #include "webkit/storage/webkit_storage_export.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 WEBKIT_STORAGE_EXPORT QuotaClient
{
25 typedef base::Callback
<void(int64
)> GetUsageCallback
; // NOLINT
26 typedef base::Callback
<void(const std::set
<GURL
>&, StorageType
)>
28 typedef base::Callback
<void(QuotaStatusCode
)> 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;
74 // TODO(dmikurube): Replace it to std::vector for efficiency.
75 typedef std::list
<QuotaClient
*> QuotaClientList
;
79 #endif // WEBKIT_QUOTA_QUOTA_CLIENT_H_