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_PROXY_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 #include <set> | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 #include "base/memory/ref_counted.h" | |
15 #include "content/browser/browser_thread.h" | |
16 #include "webkit/quota/quota_manager.h" | |
17 #include "webkit/quota/quota_types.h" | |
18 | |
19 class Value; | |
20 class ListValue; | |
21 | |
22 namespace quota_internals { | |
23 | |
24 class QuotaInternalsHandler; | |
25 class GlobalData; | |
26 class HostData; | |
27 class OriginData; | |
28 typedef std::map<std::string, std::string> Statistics; | |
29 | |
30 // This class is the bridge between QuotaInternalsHandler and QuotaManager. | |
kinuko
2011/07/04 08:24:27
nit: Would be nice to also note that who creates a
tzik
2011/07/06 22:49:04
Done.
| |
31 class QuotaInternalsProxy | |
32 : public base::RefCountedThreadSafe<QuotaInternalsProxy, | |
33 BrowserThread::DeleteOnIOThread> { | |
34 public: | |
35 explicit QuotaInternalsProxy(QuotaInternalsHandler* handler); | |
36 | |
37 void RequestData(scoped_refptr<quota::QuotaManager> quota_manager); | |
38 | |
39 private: | |
40 typedef quota::QuotaManager::QuotaTableEntries QuotaTableEntries; | |
41 typedef quota::QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; | |
42 | |
43 void ReportAvailableSpace(int64 available_space); | |
44 void ReportGlobalData(const GlobalData& data); | |
45 void ReportHostData(const std::vector<HostData>& hosts); | |
46 void ReportOriginData(const std::vector<OriginData>& origins); | |
47 void ReportStatistics(const Statistics& stats); | |
48 | |
49 // Called on IO Thread by QuotaManager as callback. | |
50 void DidGetAvailableSpace(quota::QuotaStatusCode status, int64 space); | |
51 void DidGetGlobalQuota(quota::QuotaStatusCode status, | |
52 quota::StorageType type, | |
53 int64 quota); | |
54 void DidGetGlobalUsage(quota::StorageType type, | |
55 int64 usage, | |
56 int64 unlimited_usage); | |
57 void DidDumpQuotaTable(const QuotaTableEntries& entries); | |
58 void DidDumpOriginInfoTable(const OriginInfoTableEntries& entries); | |
59 void DidGetHostUsage(const std::string& host, | |
60 quota::StorageType type, | |
61 int64 usage); | |
62 | |
63 // Helper. Called on IO Thread. | |
64 void RequestPerOriginData(quota::StorageType type); | |
65 void VisitHost(const std::string& host, quota::StorageType type); | |
66 void GetHostUsage(const std::string& host, quota::StorageType type); | |
67 | |
68 // Used on UI Thread. | |
69 QuotaInternalsHandler* handler_; | |
70 | |
71 // Used on IO Thread. | |
72 base::ScopedCallbackFactory<QuotaInternalsProxy> callback_factory_; | |
73 scoped_refptr<quota::QuotaManager> quota_manager_; | |
74 std::set<std::pair<std::string, quota::StorageType> > | |
75 hosts_visited_, hosts_pending_; | |
76 std::vector<HostData> report_pending_; | |
77 | |
78 friend class QuotaInternalsHandler; | |
79 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | |
80 friend class DeleteTask<QuotaInternalsProxy>; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(QuotaInternalsProxy); | |
83 }; | |
84 } // quota_internals | |
85 | |
86 #endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ | |
OLD | NEW |