Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_quota_helper.h
blobdf94404c2bbd538e64f21365bf7637b5163ef8ba
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"
17 namespace base {
18 class SingleThreadTaskRunner;
19 } // namespace base
21 class BrowsingDataQuotaHelper;
22 class Profile;
24 struct BrowsingDataQuotaHelperDeleter {
25 static void Destruct(const BrowsingDataQuotaHelper* helper);
28 // This class is an interface class to bridge between Cookies Tree and Unified
29 // Quota System. This class provides a way to get usage and quota information
30 // through the instance.
32 // Call Create to create an instance for a profile and call StartFetching with
33 // a callback to fetch information asynchronously.
35 // Parallel fetching is not allowed, a fetching task should start after end of
36 // previous task. All method of this class should called from UI thread.
37 class BrowsingDataQuotaHelper
38 : public base::RefCountedThreadSafe<BrowsingDataQuotaHelper,
39 BrowsingDataQuotaHelperDeleter> {
40 public:
41 // QuotaInfo contains host-based quota and usage information for persistent
42 // and temporary storage.
43 struct QuotaInfo {
44 QuotaInfo();
45 explicit QuotaInfo(const std::string& host);
46 QuotaInfo(const std::string& host,
47 int64 temporary_usage,
48 int64 persistent_usage,
49 int64 syncable_usage);
50 ~QuotaInfo();
52 // Certain versions of MSVC 2008 have bad implementations of ADL for nested
53 // classes so they require these operators to be declared here instead of in
54 // the global namespace.
55 bool operator <(const QuotaInfo& rhs) const;
56 bool operator ==(const QuotaInfo& rhs) const;
58 std::string host;
59 int64 temporary_usage = 0;
60 int64 persistent_usage = 0;
61 int64 syncable_usage = 0;
64 typedef std::list<QuotaInfo> QuotaInfoArray;
65 typedef base::Callback<void(const QuotaInfoArray&)> FetchResultCallback;
67 static BrowsingDataQuotaHelper* Create(Profile* profile);
69 virtual void StartFetching(const FetchResultCallback& callback) = 0;
71 virtual void RevokeHostQuota(const std::string& host) = 0;
73 protected:
74 explicit BrowsingDataQuotaHelper(base::SingleThreadTaskRunner* io_thread_);
75 virtual ~BrowsingDataQuotaHelper();
77 private:
78 friend class base::DeleteHelper<BrowsingDataQuotaHelper>;
79 friend struct BrowsingDataQuotaHelperDeleter;
80 scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
82 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelper);
85 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_QUOTA_HELPER_H_