OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_ | |
6 #define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 #include <string> | |
11 #include <utility> | |
12 | |
13 #include "base/compiler_specific.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "base/memory/weak_ptr.h" | |
16 #include "base/time.h" | |
17 #include "chrome/browser/browsing_data_quota_helper.h" | |
18 #include "content/public/browser/browser_thread.h" | |
19 #include "webkit/quota/quota_types.h" | |
20 | |
21 namespace quota { | |
22 class QuotaManager; | |
23 } | |
24 | |
25 // Implementation of BrowsingDataQuotaHelper. Since a client of | |
26 // BrowsingDataQuotaHelper should live in UI thread and QuotaManager lives in | |
27 // IO thread, we have to communicate over thread using PostTask. | |
28 class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper { | |
29 public: | |
30 virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE; | |
31 virtual void RevokeHostQuota(const std::string& host) OVERRIDE; | |
32 | |
33 private: | |
34 BrowsingDataQuotaHelperImpl(base::MessageLoopProxy* ui_thread, | |
35 base::MessageLoopProxy* io_thread, | |
36 quota::QuotaManager* quota_manager); | |
37 virtual ~BrowsingDataQuotaHelperImpl(); | |
38 | |
39 void FetchQuotaInfo(); | |
40 | |
41 // Callback function for GetOriginModifiedSince. | |
42 void GotOrigins(const std::set<GURL>& origins, quota::StorageType type); | |
43 | |
44 void ProcessPendingHosts(); | |
45 void GetHostUsage(const std::string& host, quota::StorageType type); | |
46 | |
47 // Callback function for GetHostUsage. | |
48 void GotHostUsage(const std::string& host, | |
49 quota::StorageType type, | |
50 int64 usage); | |
51 | |
52 void OnComplete(); | |
53 void DidRevokeHostQuota(quota::QuotaStatusCode status, | |
54 const std::string& host, | |
55 quota::StorageType type, | |
56 int64 quota); | |
57 | |
58 scoped_refptr<quota::QuotaManager> quota_manager_; | |
59 FetchResultCallback callback_; | |
60 | |
61 typedef std::set<std::pair<std::string, quota::StorageType> > PendingHosts; | |
62 PendingHosts pending_hosts_; | |
63 std::map<std::string, QuotaInfo> quota_info_; | |
64 | |
65 bool is_fetching_; | |
66 | |
67 scoped_refptr<base::MessageLoopProxy> ui_thread_; | |
68 scoped_refptr<base::MessageLoopProxy> io_thread_; | |
69 base::WeakPtrFactory<BrowsingDataQuotaHelperImpl> weak_factory_; | |
70 | |
71 friend class BrowsingDataQuotaHelper; | |
72 friend class BrowsingDataQuotaHelperTest; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperImpl); | |
75 }; | |
76 | |
77 #endif // CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_ | |
OLD | NEW |