Chromium Code Reviews| Index: chrome/browser/ui/webui/quota_internals_ui.h |
| diff --git a/chrome/browser/ui/webui/quota_internals_ui.h b/chrome/browser/ui/webui/quota_internals_ui.h |
| index c7b90cf0016fd0b930326af699e6eb89b8c786d3..b4c822948bcbf92e3e0b841ccdb78842c8346bfc 100644 |
| --- a/chrome/browser/ui/webui/quota_internals_ui.h |
| +++ b/chrome/browser/ui/webui/quota_internals_ui.h |
| @@ -6,10 +6,15 @@ |
| #define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_UI_H_ |
| #pragma once |
| +#include <set> |
| #include <string> |
| +#include <utility> |
| +#include <vector> |
| #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| #include "content/browser/webui/web_ui.h" |
| +#include "webkit/quota/quota_types.h" |
| +#include "webkit/quota/quota_manager.h" |
| class TabContents; |
| @@ -23,6 +28,7 @@ class QuotaInternalsUI : public WebUI { |
| }; |
| namespace quota_internals { |
| +class QuotaInternalsProxy; |
| class QuotaInternalsHTMLSource : public ChromeURLDataManager::DataSource { |
| public: |
| @@ -37,7 +43,132 @@ class QuotaInternalsHTMLSource : public ChromeURLDataManager::DataSource { |
| DISALLOW_COPY_AND_ASSIGN(QuotaInternalsHTMLSource); |
| }; |
| +class QuotaInternalsMessageHandler : public WebUIMessageHandler { |
|
kinuko
2011/05/30 10:18:00
nit: could this be declared in .cc?
tzik
2011/05/31 04:53:00
Done.
|
| + public: |
| + struct GlobalData { |
| + quota::StorageType type; |
| + int64 usage; |
| + int64 unlimited_usage; |
| + int64 quota; |
| + }; |
| + |
| + struct HostData { |
| + std::string host; |
| + quota::StorageType type; |
| + int64 usage; |
| + int64 quota; |
| + }; |
| + |
| + struct OriginData { |
| + GURL origin; |
| + quota::StorageType type; |
| + std::string host; |
| + int in_use; |
| + int used_count; |
| + base::Time last_access_time; |
| + }; |
| + |
| + QuotaInternalsMessageHandler(); |
| + virtual ~QuotaInternalsMessageHandler(); |
| + |
| + virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
| + virtual void RegisterMessages() OVERRIDE; |
| + |
| + void ReportAvailableSpace(int64 available_space); |
| + void ReportGlobalData(const GlobalData& global_data); |
| + void ReportHostData(const std::vector<HostData>& hosts); |
| + void ReportOriginData(const std::vector<OriginData>& origins); |
| + |
| + private: |
| + void OnRequestData(const ListValue* list_unused); |
| + void SendMessage(const std::string& message, const Value& value); |
| + |
| + DictionaryValue* GlobalDataToValue(const GlobalData& global_data); |
| + ListValue* HostDataToValue(const HostData& host); |
| + ListValue* OriginDataToValue(const OriginData& origin); |
| + |
| + scoped_refptr<QuotaInternalsProxy> proxy_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(QuotaInternalsMessageHandler); |
| +}; |
| + |
| +typedef QuotaInternalsProxy QuotaInternalsProxyDeleter; |
| + |
| +class QuotaInternalsProxy |
| + : public base::RefCountedThreadSafe<QuotaInternalsProxy, |
| + QuotaInternalsProxyDeleter> { |
|
kinuko
2011/05/30 10:18:00
As we're in chrome/ I think you can simply use Bro
tzik
2011/05/31 04:53:00
Done.
|
| + public: |
| + typedef QuotaInternalsMessageHandler::GlobalData GlobalData; |
| + typedef QuotaInternalsMessageHandler::HostData HostData; |
| + typedef QuotaInternalsMessageHandler::OriginData OriginData; |
| + |
| + explicit QuotaInternalsProxy(QuotaInternalsMessageHandler* handler); |
| + |
| + // Called on IO Thread |
|
kinuko
2011/05/30 10:18:00
style-nit: please end the comment with '.'
tzik
2011/05/31 04:53:00
Done.
|
| + void ReportAvailableSpace(int64 available_space); |
| + void ReportGlobalData(const GlobalData& global_data); |
| + void ReportHostData(const std::vector<HostData>& hosts); |
| + void ReportOriginData(const std::vector<OriginData>& origins); |
| + |
| + // Called on UI Thread |
| + void RequestData(quota::QuotaManager* quota_manager); |
| + |
| + static void Destruct(const QuotaInternalsProxy* proxy); |
| + |
| + private: |
| + typedef quota::QuotaManager::QuotaTableEntry QuotaTableEntry; |
| + typedef quota::QuotaManager::LastAccessTimeTableEntry |
| + LastAccessTimeTableEntry; |
| + typedef quota::QuotaManager::QuotaTableEntries QuotaTableEntries; |
| + typedef quota::QuotaManager::LastAccessTimeTableEntries |
| + LastAccessTimeTableEntries; |
| + |
| + // Called on UI Thread |
| + void RunReportAvailableSpace(int64 available_space); |
| + void RunReportGlobalData(const GlobalData& global_data); |
| + void RunReportHostData(const std::vector<HostData>& hosts); |
| + void RunReportOriginData(const std::vector<OriginData>& origins); |
| + |
| + // Called on IO Thread |
| + void RunRequestData(scoped_refptr<quota::QuotaManager> quota_manager); |
| + |
| + // Called on IO Thread by QuotaManager as callback |
| + void DidGetAvailableSpace(quota::QuotaStatusCode status, int64 space); |
| + void DidGetGlobalQuota(quota::QuotaStatusCode status, |
| + quota::StorageType type, |
| + int64 quota); |
| + void DidGetGlobalUsage(quota::StorageType type, |
| + int64 usage, |
| + int64 unlimited_usage); |
| + void DidDumpQuotaTable(const QuotaTableEntries& entries); |
| + void DidDumpLastAccessTimeTable(const LastAccessTimeTableEntries& entries); |
| + void DidGetHostUsage(const std::string& host, |
| + quota::StorageType type, |
| + int64 usage); |
| + |
| + // Helper. Called on IO Thread |
| + void RequestPerOriginData(quota::StorageType type); |
| + void VisitHost(const std::string& host, quota::StorageType type); |
| + void GetHostUsage(const std::string& host, quota::StorageType type); |
| + |
| + // base::ScopedCallbackFactory<QuotaInternalsProxy> callback_factory_; |
|
kinuko
2011/05/30 10:18:00
you forgot to delete this line?
tzik
2011/05/31 04:53:00
Done.
|
| + scoped_refptr<base::MessageLoopProxy> io_thread_, ui_thread_; |
| + |
| + // Used on UI Thread |
| + QuotaInternalsMessageHandler* handler_; |
| + |
| + // Used on IO Thread |
| + base::ScopedCallbackFactory<QuotaInternalsProxy> callback_factory_; |
| + base::WeakPtr<quota::QuotaManager> quota_manager_; |
| + std::set<std::pair<std::string, quota::StorageType> > |
| + hosts_visited_, hosts_pending_; |
| + std::vector<HostData> report_pending_; |
| + |
| + friend class QuotaInternalsMessageHandler; |
| + friend class DeleteTask<const QuotaInternalsProxy>; |
| + |
| + virtual ~QuotaInternalsProxy() {} |
| +}; |
| } // namespace quota_internals |
| #endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_UI_H_ |
| - |