OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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. | |
4 | |
5 #ifndef CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_ | |
6 #define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/callback_old.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/message_loop_proxy.h" | |
15 #include "base/time.h" | |
16 #include "content/browser/browser_thread.h" | |
17 #include "webkit/quota/quota_types.h" | |
18 | |
19 class Profile; | |
20 | |
21 namespace quota { | |
22 class QuotaManager; | |
23 } | |
24 | |
25 class BrowsingDataQuotaHelper; | |
26 | |
27 struct BrowsingDataQuotaHelperDeleter { | |
28 static void Destruct(const BrowsingDataQuotaHelper* helper); | |
29 }; | |
30 | |
31 // This class is an interface class to bridge between Cookies Tree and Unified | |
32 // Quota System. This class provides a way to get usage and quota information | |
33 // through the instance. | |
34 // | |
35 // Call Create to create an instance for a profile and call StartFetching with | |
36 // a callback to fetch information asynchronously. If result is no longer needed | |
37 // after StartFetching, call CancelNotification to prevent callback. | |
38 // | |
39 // Parallel fetching is not allowed, a fetching task should start after end of | |
40 // previous task. All method of this class should called from UI thread. | |
41 class BrowsingDataQuotaHelper | |
42 : public base::RefCountedThreadSafe<BrowsingDataQuotaHelper, | |
43 BrowsingDataQuotaHelperDeleter> { | |
44 public: | |
45 // QuotaInfo contains host-based quota and usage informations for persistent | |
kinuko
2011/08/02 09:09:30
nit: s/informations/information/ would be better I
tzik
2011/08/03 04:15:00
Done.
| |
46 // and temporary storage. | |
47 struct QuotaInfo { | |
48 QuotaInfo(); | |
49 explicit QuotaInfo(const std::string& host); | |
50 QuotaInfo(const std::string& host, | |
51 int64 temporary_usage, | |
52 int64 persistent_usage); | |
53 ~QuotaInfo(); | |
54 | |
55 std::string host; | |
56 int64 temporary_usage; | |
57 int64 persistent_usage; | |
58 }; | |
59 | |
60 typedef std::vector<QuotaInfo> QuotaInfoList; | |
61 typedef Callback1<const QuotaInfoList&>::Type FetchResultCallback; | |
62 | |
63 static BrowsingDataQuotaHelper* Create(Profile* profile); | |
64 | |
65 virtual void StartFetching(FetchResultCallback* callback) = 0; | |
66 virtual void CancelNotification() = 0; | |
67 | |
68 // We don't support deletion now. | |
69 virtual void DeleteQuotaHost(const std::string& host) { } | |
kinuko
2011/08/02 09:09:30
nit: no space between { }
tzik
2011/08/03 04:15:00
Done.
| |
70 | |
71 protected: | |
72 explicit BrowsingDataQuotaHelper(base::MessageLoopProxy* io_thread_); | |
73 virtual ~BrowsingDataQuotaHelper(); | |
74 | |
75 private: | |
76 friend class DeleteTask<const BrowsingDataQuotaHelper>; | |
77 friend struct BrowsingDataQuotaHelperDeleter; | |
78 scoped_refptr<base::MessageLoopProxy> io_thread_; | |
79 | |
80 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelper); | |
81 }; | |
82 | |
83 bool operator <(const BrowsingDataQuotaHelper::QuotaInfo& lhs, | |
84 const BrowsingDataQuotaHelper::QuotaInfo& rhs); | |
85 bool operator ==(const BrowsingDataQuotaHelper::QuotaInfo& lhs, | |
86 const BrowsingDataQuotaHelper::QuotaInfo& rhs); | |
87 | |
88 #endif // CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_ | |
OLD | NEW |