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