Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / webkit / quota / quota_client.h
blob88a5ddfe2ff1f25c802cf66d4f9d2d4bea4d05f1
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_
8 #include <list>
9 #include <set>
10 #include <string>
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"
17 namespace quota {
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 {
24 public:
25 typedef base::Callback<void(int64)> GetUsageCallback; // NOLINT
26 typedef base::Callback<void(const std::set<GURL>&, StorageType)>
27 GetOriginsCallback;
28 typedef base::Callback<void(QuotaStatusCode)> 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 kAllClientsMask = -1,
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,
51 StorageType type,
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,
70 StorageType type,
71 const DeletionCallback& callback) = 0;
74 // TODO(dmikurube): Replace it to std::vector for efficiency.
75 typedef std::list<QuotaClient*> QuotaClientList;
77 } // namespace quota
79 #endif // WEBKIT_QUOTA_QUOTA_CLIENT_H_