OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop_helpers.h" | 16 #include "base/sequenced_task_runner_helpers.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "webkit/quota/quota_manager.h" | 18 #include "webkit/quota/quota_manager.h" |
19 #include "webkit/quota/quota_types.h" | 19 #include "webkit/quota/quota_types.h" |
20 | 20 |
21 namespace quota_internals { | 21 namespace quota_internals { |
22 | 22 |
23 class QuotaInternalsHandler; | 23 class QuotaInternalsHandler; |
24 class GlobalStorageInfo; | 24 class GlobalStorageInfo; |
25 class PerHostStorageInfo; | 25 class PerHostStorageInfo; |
26 class PerOriginStorageInfo; | 26 class PerOriginStorageInfo; |
27 typedef std::map<std::string, std::string> Statistics; | 27 typedef std::map<std::string, std::string> Statistics; |
28 | 28 |
29 // This class is the bridge between QuotaInternalsHandler and QuotaManager. | 29 // This class is the bridge between QuotaInternalsHandler and QuotaManager. |
30 // Each QuotaInternalsHandler instances creates and owns a instance of this | 30 // Each QuotaInternalsHandler instances creates and owns a instance of this |
31 // class. | 31 // class. |
32 class QuotaInternalsProxy | 32 class QuotaInternalsProxy |
33 : public base::RefCountedThreadSafe< | 33 : public base::RefCountedThreadSafe< |
34 QuotaInternalsProxy, | 34 QuotaInternalsProxy, |
35 content::BrowserThread::DeleteOnIOThread> { | 35 content::BrowserThread::DeleteOnIOThread> { |
36 public: | 36 public: |
37 explicit QuotaInternalsProxy(QuotaInternalsHandler* handler); | 37 explicit QuotaInternalsProxy(QuotaInternalsHandler* handler); |
38 ~QuotaInternalsProxy(); | |
39 | 38 |
40 void RequestInfo(scoped_refptr<quota::QuotaManager> quota_manager); | 39 void RequestInfo(scoped_refptr<quota::QuotaManager> quota_manager); |
41 | 40 |
42 private: | 41 private: |
| 42 friend class base::DeleteHelper<QuotaInternalsProxy>; |
| 43 friend struct content::BrowserThread::DeleteOnThread< |
| 44 content::BrowserThread::IO>; |
| 45 friend class QuotaInternalsHandler; |
| 46 |
43 typedef quota::QuotaManager::QuotaTableEntries QuotaTableEntries; | 47 typedef quota::QuotaManager::QuotaTableEntries QuotaTableEntries; |
44 typedef quota::QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; | 48 typedef quota::QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; |
45 | 49 |
| 50 virtual ~QuotaInternalsProxy(); |
| 51 |
46 void ReportAvailableSpace(int64 available_space); | 52 void ReportAvailableSpace(int64 available_space); |
47 void ReportGlobalInfo(const GlobalStorageInfo& data); | 53 void ReportGlobalInfo(const GlobalStorageInfo& data); |
48 void ReportPerHostInfo(const std::vector<PerHostStorageInfo>& hosts); | 54 void ReportPerHostInfo(const std::vector<PerHostStorageInfo>& hosts); |
49 void ReportPerOriginInfo(const std::vector<PerOriginStorageInfo>& origins); | 55 void ReportPerOriginInfo(const std::vector<PerOriginStorageInfo>& origins); |
50 void ReportStatistics(const Statistics& stats); | 56 void ReportStatistics(const Statistics& stats); |
51 | 57 |
52 // Called on IO Thread by QuotaManager as callback. | 58 // Called on IO Thread by QuotaManager as callback. |
53 void DidGetAvailableSpace(quota::QuotaStatusCode status, int64 space); | 59 void DidGetAvailableSpace(quota::QuotaStatusCode status, int64 space); |
54 void DidGetGlobalQuota(quota::QuotaStatusCode status, | 60 void DidGetGlobalQuota(quota::QuotaStatusCode status, |
55 quota::StorageType type, | 61 quota::StorageType type, |
(...skipping 15 matching lines...) Expand all Loading... |
71 // Used on UI Thread. | 77 // Used on UI Thread. |
72 QuotaInternalsHandler* handler_; | 78 QuotaInternalsHandler* handler_; |
73 | 79 |
74 // Used on IO Thread. | 80 // Used on IO Thread. |
75 base::WeakPtrFactory<QuotaInternalsProxy> weak_factory_; | 81 base::WeakPtrFactory<QuotaInternalsProxy> weak_factory_; |
76 scoped_refptr<quota::QuotaManager> quota_manager_; | 82 scoped_refptr<quota::QuotaManager> quota_manager_; |
77 std::set<std::pair<std::string, quota::StorageType> > | 83 std::set<std::pair<std::string, quota::StorageType> > |
78 hosts_visited_, hosts_pending_; | 84 hosts_visited_, hosts_pending_; |
79 std::vector<PerHostStorageInfo> report_pending_; | 85 std::vector<PerHostStorageInfo> report_pending_; |
80 | 86 |
81 friend class QuotaInternalsHandler; | |
82 friend struct content::BrowserThread::DeleteOnThread< | |
83 content::BrowserThread::IO>; | |
84 friend class base::DeleteHelper<QuotaInternalsProxy>; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(QuotaInternalsProxy); | 87 DISALLOW_COPY_AND_ASSIGN(QuotaInternalsProxy); |
87 }; | 88 }; |
88 } // quota_internals | 89 } // quota_internals |
89 | 90 |
90 #endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ | 91 #endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ |
OLD | NEW |