Update V8 to version 4.7.21.
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_quota_helper.h
blob0730ab3c5395df90e9417105fe8a29131abfe4df
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 CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_QUOTA_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_QUOTA_HELPER_H_
8 #include <list>
9 #include <string>
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/sequenced_task_runner_helpers.h"
14 #include "storage/common/quota/quota_types.h"
16 class BrowsingDataQuotaHelper;
17 class Profile;
19 struct BrowsingDataQuotaHelperDeleter {
20 static void Destruct(const BrowsingDataQuotaHelper* helper);
23 // This class is an interface class to bridge between Cookies Tree and Unified
24 // Quota System. This class provides a way to get usage and quota information
25 // through the instance.
27 // Call Create to create an instance for a profile and call StartFetching with
28 // a callback to fetch information asynchronously.
30 // Parallel fetching is not allowed, a fetching task should start after end of
31 // previous task. All method of this class should called from UI thread.
32 class BrowsingDataQuotaHelper
33 : public base::RefCountedThreadSafe<BrowsingDataQuotaHelper,
34 BrowsingDataQuotaHelperDeleter> {
35 public:
36 // QuotaInfo contains host-based quota and usage information for persistent
37 // and temporary storage.
38 struct QuotaInfo {
39 QuotaInfo();
40 explicit QuotaInfo(const std::string& host);
41 QuotaInfo(const std::string& host,
42 int64 temporary_usage,
43 int64 persistent_usage,
44 int64 syncable_usage);
45 ~QuotaInfo();
47 // Certain versions of MSVC 2008 have bad implementations of ADL for nested
48 // classes so they require these operators to be declared here instead of in
49 // the global namespace.
50 bool operator <(const QuotaInfo& rhs) const;
51 bool operator ==(const QuotaInfo& rhs) const;
53 std::string host;
54 int64 temporary_usage = 0;
55 int64 persistent_usage = 0;
56 int64 syncable_usage = 0;
59 typedef std::list<QuotaInfo> QuotaInfoArray;
60 typedef base::Callback<void(const QuotaInfoArray&)> FetchResultCallback;
62 static BrowsingDataQuotaHelper* Create(Profile* profile);
64 virtual void StartFetching(const FetchResultCallback& callback) = 0;
66 virtual void RevokeHostQuota(const std::string& host) = 0;
68 protected:
69 BrowsingDataQuotaHelper();
70 virtual ~BrowsingDataQuotaHelper();
72 private:
73 friend class base::DeleteHelper<BrowsingDataQuotaHelper>;
74 friend struct BrowsingDataQuotaHelperDeleter;
76 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelper);
79 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_QUOTA_HELPER_H_