Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_quota_helper.h
blobf15f9fb34ea8e181e0f6c5a844337c02b7f496e8
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/message_loop/message_loop_proxy.h"
14 #include "base/sequenced_task_runner_helpers.h"
15 #include "webkit/common/quota/quota_types.h"
17 class BrowsingDataQuotaHelper;
18 class Profile;
20 struct BrowsingDataQuotaHelperDeleter {
21 static void Destruct(const BrowsingDataQuotaHelper* helper);
24 // This class is an interface class to bridge between Cookies Tree and Unified
25 // Quota System. This class provides a way to get usage and quota information
26 // through the instance.
28 // Call Create to create an instance for a profile and call StartFetching with
29 // a callback to fetch information asynchronously.
31 // Parallel fetching is not allowed, a fetching task should start after end of
32 // previous task. All method of this class should called from UI thread.
33 class BrowsingDataQuotaHelper
34 : public base::RefCountedThreadSafe<BrowsingDataQuotaHelper,
35 BrowsingDataQuotaHelperDeleter> {
36 public:
37 // QuotaInfo contains host-based quota and usage information for persistent
38 // and temporary storage.
39 struct QuotaInfo {
40 QuotaInfo();
41 explicit QuotaInfo(const std::string& host);
42 QuotaInfo(const std::string& host,
43 int64 temporary_usage,
44 int64 persistent_usage,
45 int64 syncable_usage);
46 ~QuotaInfo();
48 // Certain versions of MSVC 2008 have bad implementations of ADL for nested
49 // classes so they require these operators to be declared here instead of in
50 // the global namespace.
51 bool operator <(const QuotaInfo& rhs) const;
52 bool operator ==(const QuotaInfo& rhs) const;
54 std::string host;
55 int64 temporary_usage;
56 int64 persistent_usage;
57 int64 syncable_usage;
60 typedef std::list<QuotaInfo> QuotaInfoArray;
61 typedef base::Callback<void(const QuotaInfoArray&)> FetchResultCallback;
63 static BrowsingDataQuotaHelper* Create(Profile* profile);
65 virtual void StartFetching(const FetchResultCallback& callback) = 0;
67 virtual void RevokeHostQuota(const std::string& host) = 0;
69 protected:
70 explicit BrowsingDataQuotaHelper(base::MessageLoopProxy* io_thread_);
71 virtual ~BrowsingDataQuotaHelper();
73 private:
74 friend class base::DeleteHelper<BrowsingDataQuotaHelper>;
75 friend struct BrowsingDataQuotaHelperDeleter;
76 scoped_refptr<base::MessageLoopProxy> io_thread_;
78 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelper);
81 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_QUOTA_HELPER_H_