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

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

Issue 7084024: Add chrome://quota-internals/ (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix clang compile error Created 9 years, 5 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
« no previous file with comments | « chrome/browser/ui/webui/quota_internals_handler.h ('k') | chrome/browser/ui/webui/quota_internals_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/quota_internals_handler.cc
diff --git a/chrome/browser/ui/webui/quota_internals_handler.cc b/chrome/browser/ui/webui/quota_internals_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f1322b8848c8633cf05839dfde58bff999ff343a
--- /dev/null
+++ b/chrome/browser/ui/webui/quota_internals_handler.cc
@@ -0,0 +1,88 @@
+// 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.
+
+#include "chrome/browser/ui/webui/quota_internals_handler.h"
+
+#include <string>
+
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/quota_internals_proxy.h"
+#include "chrome/browser/ui/webui/quota_internals_types.h"
+#include "net/base/net_util.h"
+
+namespace quota_internals {
+
+QuotaInternalsHandler::QuotaInternalsHandler() {}
+
+QuotaInternalsHandler::~QuotaInternalsHandler() {
+ if (proxy_)
+ proxy_->handler_ = NULL;
+}
+
+void QuotaInternalsHandler::RegisterMessages() {
+ DCHECK(web_ui_);
+ web_ui_->RegisterMessageCallback(
+ "requestInfo",
+ NewCallback(this, &QuotaInternalsHandler::OnRequestInfo));
+}
+
+void QuotaInternalsHandler::ReportAvailableSpace(int64 available_space) {
+ scoped_ptr<base::Value> avail(
+ base::Value::CreateDoubleValue(static_cast<double>(available_space)));
+ SendMessage("AvailableSpaceUpdated", *avail);
+}
+
+void QuotaInternalsHandler::ReportGlobalInfo(const GlobalStorageInfo& data) {
+ scoped_ptr<base::Value> value(data.NewValue());
+ SendMessage("GlobalInfoUpdated", *value);
+}
+
+void QuotaInternalsHandler::ReportPerHostInfo(
+ const std::vector<PerHostStorageInfo>& hosts) {
+ base::ListValue values;
+ typedef std::vector<PerHostStorageInfo>::const_iterator iterator;
+ for (iterator itr(hosts.begin()); itr != hosts.end(); ++itr) {
+ values.Append(itr->NewValue());
+ }
+
+ SendMessage("PerHostInfoUpdated", values);
+}
+
+void QuotaInternalsHandler::ReportPerOriginInfo(
+ const std::vector<PerOriginStorageInfo>& origins) {
+ base::ListValue origins_value;
+ typedef std::vector<PerOriginStorageInfo>::const_iterator iterator;
+ for (iterator itr(origins.begin()); itr != origins.end(); ++itr) {
+ origins_value.Append(itr->NewValue());
+ }
+
+ SendMessage("PerOriginInfoUpdated", origins_value);
+}
+
+void QuotaInternalsHandler::ReportStatistics(const Statistics& stats) {
+ base::DictionaryValue dict;
+ typedef Statistics::const_iterator iterator;
+ for (iterator itr(stats.begin()); itr != stats.end(); ++itr) {
+ dict.SetString(itr->first, itr->second);
+ }
+
+ SendMessage("StatisticsUpdated", dict);
+}
+
+void QuotaInternalsHandler::SendMessage(const std::string& message,
+ const base::Value& value) {
+ scoped_ptr<base::Value> message_data(base::Value::CreateStringValue(message));
+ web_ui_->CallJavascriptFunction("cr.quota.messageHandler",
+ *message_data,
+ value);
+}
+
+void QuotaInternalsHandler::OnRequestInfo(const base::ListValue*) {
+ if (!proxy_)
+ proxy_ = new QuotaInternalsProxy(this);
+ proxy_->RequestInfo(web_ui_->GetProfile()->GetQuotaManager());
+}
+
+} // namespace quota_internals
« no previous file with comments | « chrome/browser/ui/webui/quota_internals_handler.h ('k') | chrome/browser/ui/webui/quota_internals_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698