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_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 #include <set> | |
11 #include <string> | |
12 #include <utility> | |
13 #include <vector> | |
14 | |
15 #include "base/memory/ref_counted.h" | |
16 #include "content/browser/browser_thread.h" | |
17 #include "content/browser/webui/web_ui.h" | |
18 #include "webkit/quota/quota_manager.h" | |
19 #include "webkit/quota/quota_types.h" | |
20 | |
21 class Value; | |
22 class ListValue; | |
23 | |
24 namespace quota_internals { | |
25 | |
26 class QuotaInternalsProxy; | |
27 | |
28 class GlobalData { | |
Evan Stade
2011/06/28 17:36:49
class comments on all of these.
Why are the first
tzik
2011/07/01 01:27:05
Done. That is forgotten to modify. Thanks.
| |
29 public: | |
30 GlobalData(quota::StorageType type, | |
31 int64 usage, | |
32 int64 unlimited_usage, | |
33 int64 quota); | |
34 Value* NewValue() const; | |
35 | |
36 private: | |
37 quota::StorageType type_; | |
38 int64 usage_; | |
39 int64 unlimited_usage_; | |
40 int64 quota_; | |
41 }; | |
42 | |
43 class HostData { | |
44 public: | |
45 HostData(const std::string& host, | |
46 quota::StorageType type, | |
47 int64 usage, | |
48 int64 quota); | |
49 Value* NewValue() const; | |
50 | |
51 private: | |
52 std::string host_; | |
53 quota::StorageType type_; | |
54 int64 usage_; | |
55 int64 quota_; | |
56 }; | |
57 | |
58 struct OriginData { | |
59 public: | |
60 OriginData(const GURL& origin, | |
61 quota::StorageType type, | |
62 int in_use, | |
63 int used_count, | |
64 base::Time last_access_time, | |
65 base::Time last_modified_time); | |
66 Value* NewValue() const; | |
67 | |
68 private: | |
69 GURL origin_; | |
70 quota::StorageType type_; | |
71 std::string host_; | |
72 int in_use_; | |
73 int used_count_; | |
74 base::Time last_access_time_; | |
75 base::Time last_modified_time_; | |
76 }; | |
77 | |
78 typedef std::map<std::string, std::string> Statistics; | |
79 | |
80 class QuotaInternalsHandler : public WebUIMessageHandler { | |
81 public: | |
82 QuotaInternalsHandler(); | |
83 virtual ~QuotaInternalsHandler(); | |
84 virtual void RegisterMessages() OVERRIDE; | |
85 | |
86 void ReportAvailableSpace(int64 available_space); | |
87 void ReportGlobalData(const GlobalData& data); | |
88 void ReportHostData(const std::vector<HostData>& hosts); | |
89 void ReportOriginData(const std::vector<OriginData>& origins); | |
90 void ReportStatistics(const Statistics& stats); | |
91 | |
92 private: | |
93 void OnRequestData(const ListValue*); | |
94 void SendMessage(const std::string& message, const Value& value); | |
95 | |
96 scoped_refptr<QuotaInternalsProxy> proxy_; | |
97 | |
98 DISALLOW_COPY_AND_ASSIGN(QuotaInternalsHandler); | |
99 }; | |
100 | |
101 class QuotaInternalsProxy | |
Evan Stade
2011/06/28 17:36:49
I think this warrants its own file
tzik
2011/07/01 01:27:05
Done.
| |
102 : public base::RefCountedThreadSafe<QuotaInternalsProxy, | |
103 BrowserThread::DeleteOnIOThread> { | |
104 public: | |
105 explicit QuotaInternalsProxy(QuotaInternalsHandler* handler); | |
106 | |
107 // Called on IO Thread. | |
108 void ReportAvailableSpace(int64 available_space); | |
109 void ReportGlobalData(const GlobalData& data); | |
110 void ReportHostData(const std::vector<HostData>& hosts); | |
111 void ReportOriginData(const std::vector<OriginData>& origins); | |
112 void ReportStatistics(const Statistics& stats); | |
113 | |
114 // Called on UI Thread. | |
115 void RequestData(quota::QuotaManager* quota_manager); | |
116 | |
117 private: | |
118 typedef quota::QuotaManager::QuotaTableEntry QuotaTableEntry; | |
Evan Stade
2011/06/28 17:36:49
I don't see where this is used
tzik
2011/07/01 01:27:05
Done.
| |
119 typedef quota::QuotaManager::OriginInfoTableEntry OriginInfoTableEntry; | |
Evan Stade
2011/06/28 17:36:49
or this one
tzik
2011/07/01 01:27:05
Done.
| |
120 typedef quota::QuotaManager::QuotaTableEntries QuotaTableEntries; | |
121 typedef quota::QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; | |
Evan Stade
2011/06/28 17:36:49
I think you should remove this typedef and if you
tzik
2011/07/01 01:27:05
Did you mean "using quota::QuotaManager::QuotaTabl
| |
122 | |
123 // Called on UI Thread. | |
124 void RunReportAvailableSpaceOnUIThread(int64 available_space); | |
125 void RunReportGlobalDataOnUIThread(const GlobalData& data); | |
126 void RunReportHostDataOnUIThread(const std::vector<HostData>& hosts); | |
127 void RunReportOriginDataOnUIThread(const std::vector<OriginData>& origins); | |
128 void RunReportStatisticsOnUIThread(const Statistics& stats); | |
129 | |
130 // Called on IO Thread. | |
131 void RunRequestDataOnIOThread(); | |
132 | |
133 // Called on IO Thread by QuotaManager as callback. | |
134 void DidGetAvailableSpace(quota::QuotaStatusCode status, int64 space); | |
135 void DidGetGlobalQuota(quota::QuotaStatusCode status, | |
136 quota::StorageType type, | |
137 int64 quota); | |
138 void DidGetGlobalUsage(quota::StorageType type, | |
139 int64 usage, | |
140 int64 unlimited_usage); | |
141 void DidDumpQuotaTable(const QuotaTableEntries& entries); | |
142 void DidDumpOriginInfoTable(const OriginInfoTableEntries& entries); | |
143 void DidGetHostUsage(const std::string& host, | |
144 quota::StorageType type, | |
145 int64 usage); | |
146 | |
147 // Helper. Called on IO Thread. | |
148 void RequestPerOriginData(quota::StorageType type); | |
149 void VisitHost(const std::string& host, quota::StorageType type); | |
150 void GetHostUsage(const std::string& host, quota::StorageType type); | |
151 | |
152 // Used on UI Thread. | |
153 QuotaInternalsHandler* handler_; | |
154 | |
155 // Used on IO Thread. | |
156 base::ScopedCallbackFactory<QuotaInternalsProxy> callback_factory_; | |
157 scoped_refptr<quota::QuotaManager> quota_manager_; | |
158 std::set<std::pair<std::string, quota::StorageType> > | |
159 hosts_visited_, hosts_pending_; | |
160 std::vector<HostData> report_pending_; | |
161 | |
162 friend class QuotaInternalsHandler; | |
163 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | |
164 friend class DeleteTask<QuotaInternalsProxy>; | |
165 | |
166 DISALLOW_COPY_AND_ASSIGN(QuotaInternalsProxy); | |
167 }; | |
168 } // quota_internals | |
169 | |
170 #endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_ | |
OLD | NEW |