Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7307)

Unified Diff: chrome/browser/ui/webui/quota_internals_handler.h

Issue 7084024: Add chrome://quota-internals/ (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/quota_internals_handler.h
diff --git a/chrome/browser/ui/webui/quota_internals_handler.h b/chrome/browser/ui/webui/quota_internals_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..c6defc1431d5c7cc8dc61dd9814fdb39857f4304
--- /dev/null
+++ b/chrome/browser/ui/webui/quota_internals_handler.h
@@ -0,0 +1,170 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_
+#pragma once
+
+#include <map>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "content/browser/browser_thread.h"
+#include "content/browser/webui/web_ui.h"
+#include "webkit/quota/quota_manager.h"
+#include "webkit/quota/quota_types.h"
+
+class Value;
+class ListValue;
+
+namespace quota_internals {
+
+class QuotaInternalsProxy;
+
+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.
+ public:
+ GlobalData(quota::StorageType type,
+ int64 usage,
+ int64 unlimited_usage,
+ int64 quota);
+ Value* NewValue() const;
+
+ private:
+ quota::StorageType type_;
+ int64 usage_;
+ int64 unlimited_usage_;
+ int64 quota_;
+};
+
+class HostData {
+ public:
+ HostData(const std::string& host,
+ quota::StorageType type,
+ int64 usage,
+ int64 quota);
+ Value* NewValue() const;
+
+ private:
+ std::string host_;
+ quota::StorageType type_;
+ int64 usage_;
+ int64 quota_;
+};
+
+struct OriginData {
+ public:
+ OriginData(const GURL& origin,
+ quota::StorageType type,
+ int in_use,
+ int used_count,
+ base::Time last_access_time,
+ base::Time last_modified_time);
+ Value* NewValue() const;
+
+ private:
+ GURL origin_;
+ quota::StorageType type_;
+ std::string host_;
+ int in_use_;
+ int used_count_;
+ base::Time last_access_time_;
+ base::Time last_modified_time_;
+};
+
+typedef std::map<std::string, std::string> Statistics;
+
+class QuotaInternalsHandler : public WebUIMessageHandler {
+ public:
+ QuotaInternalsHandler();
+ virtual ~QuotaInternalsHandler();
+ virtual void RegisterMessages() OVERRIDE;
+
+ void ReportAvailableSpace(int64 available_space);
+ void ReportGlobalData(const GlobalData& data);
+ void ReportHostData(const std::vector<HostData>& hosts);
+ void ReportOriginData(const std::vector<OriginData>& origins);
+ void ReportStatistics(const Statistics& stats);
+
+ private:
+ void OnRequestData(const ListValue*);
+ void SendMessage(const std::string& message, const Value& value);
+
+ scoped_refptr<QuotaInternalsProxy> proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(QuotaInternalsHandler);
+};
+
+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.
+ : public base::RefCountedThreadSafe<QuotaInternalsProxy,
+ BrowserThread::DeleteOnIOThread> {
+ public:
+ explicit QuotaInternalsProxy(QuotaInternalsHandler* handler);
+
+ // Called on IO Thread.
+ void ReportAvailableSpace(int64 available_space);
+ void ReportGlobalData(const GlobalData& data);
+ void ReportHostData(const std::vector<HostData>& hosts);
+ void ReportOriginData(const std::vector<OriginData>& origins);
+ void ReportStatistics(const Statistics& stats);
+
+ // Called on UI Thread.
+ void RequestData(quota::QuotaManager* quota_manager);
+
+ private:
+ 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.
+ typedef quota::QuotaManager::OriginInfoTableEntry OriginInfoTableEntry;
Evan Stade 2011/06/28 17:36:49 or this one
tzik 2011/07/01 01:27:05 Done.
+ typedef quota::QuotaManager::QuotaTableEntries QuotaTableEntries;
+ 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
+
+ // Called on UI Thread.
+ void RunReportAvailableSpaceOnUIThread(int64 available_space);
+ void RunReportGlobalDataOnUIThread(const GlobalData& data);
+ void RunReportHostDataOnUIThread(const std::vector<HostData>& hosts);
+ void RunReportOriginDataOnUIThread(const std::vector<OriginData>& origins);
+ void RunReportStatisticsOnUIThread(const Statistics& stats);
+
+ // Called on IO Thread.
+ void RunRequestDataOnIOThread();
+
+ // 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 DidDumpOriginInfoTable(const OriginInfoTableEntries& 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);
+
+ // Used on UI Thread.
+ QuotaInternalsHandler* handler_;
+
+ // Used on IO Thread.
+ base::ScopedCallbackFactory<QuotaInternalsProxy> callback_factory_;
+ scoped_refptr<quota::QuotaManager> quota_manager_;
+ std::set<std::pair<std::string, quota::StorageType> >
+ hosts_visited_, hosts_pending_;
+ std::vector<HostData> report_pending_;
+
+ friend class QuotaInternalsHandler;
+ friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
+ friend class DeleteTask<QuotaInternalsProxy>;
+
+ DISALLOW_COPY_AND_ASSIGN(QuotaInternalsProxy);
+};
+} // quota_internals
+
+#endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_
« no previous file with comments | « chrome/browser/resources/quota_internals/event_handler.js ('k') | chrome/browser/ui/webui/quota_internals_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698