| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/quota_internals_handler.h" | 5 #include "chrome/browser/ui/webui/quota_internals_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 9 #include "base/values.h" | 11 #include "base/values.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/webui/quota_internals_proxy.h" | 13 #include "chrome/browser/ui/webui/quota_internals_proxy.h" |
| 12 #include "chrome/browser/ui/webui/quota_internals_types.h" | 14 #include "chrome/browser/ui/webui/quota_internals_types.h" |
| 13 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 14 | 16 |
| 15 namespace quota_internals { | 17 namespace quota_internals { |
| 16 | 18 |
| 17 QuotaInternalsHandler::QuotaInternalsHandler() {} | 19 QuotaInternalsHandler::QuotaInternalsHandler() {} |
| 18 | 20 |
| 19 QuotaInternalsHandler::~QuotaInternalsHandler() { | 21 QuotaInternalsHandler::~QuotaInternalsHandler() { |
| 20 if (proxy_) | 22 if (proxy_) |
| 21 proxy_->handler_ = NULL; | 23 proxy_->handler_ = NULL; |
| 22 } | 24 } |
| 23 | 25 |
| 24 void QuotaInternalsHandler::RegisterMessages() { | 26 void QuotaInternalsHandler::RegisterMessages() { |
| 25 DCHECK(web_ui_); | 27 DCHECK(web_ui_); |
| 26 web_ui_->RegisterMessageCallback( | 28 web_ui_->RegisterMessageCallback("requestInfo", |
| 27 "requestInfo", | 29 base::Bind(&QuotaInternalsHandler::OnRequestInfo, |
| 28 NewCallback(this, &QuotaInternalsHandler::OnRequestInfo)); | 30 base::Unretained(this))); |
| 29 } | 31 } |
| 30 | 32 |
| 31 void QuotaInternalsHandler::ReportAvailableSpace(int64 available_space) { | 33 void QuotaInternalsHandler::ReportAvailableSpace(int64 available_space) { |
| 32 scoped_ptr<base::Value> avail( | 34 scoped_ptr<base::Value> avail( |
| 33 base::Value::CreateDoubleValue(static_cast<double>(available_space))); | 35 base::Value::CreateDoubleValue(static_cast<double>(available_space))); |
| 34 SendMessage("AvailableSpaceUpdated", *avail); | 36 SendMessage("AvailableSpaceUpdated", *avail); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void QuotaInternalsHandler::ReportGlobalInfo(const GlobalStorageInfo& data) { | 39 void QuotaInternalsHandler::ReportGlobalInfo(const GlobalStorageInfo& data) { |
| 38 scoped_ptr<base::Value> value(data.NewValue()); | 40 scoped_ptr<base::Value> value(data.NewValue()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 value); | 81 value); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void QuotaInternalsHandler::OnRequestInfo(const base::ListValue*) { | 84 void QuotaInternalsHandler::OnRequestInfo(const base::ListValue*) { |
| 83 if (!proxy_) | 85 if (!proxy_) |
| 84 proxy_ = new QuotaInternalsProxy(this); | 86 proxy_ = new QuotaInternalsProxy(this); |
| 85 proxy_->RequestInfo(Profile::FromWebUI(web_ui_)->GetQuotaManager()); | 87 proxy_->RequestInfo(Profile::FromWebUI(web_ui_)->GetQuotaManager()); |
| 86 } | 88 } |
| 87 | 89 |
| 88 } // namespace quota_internals | 90 } // namespace quota_internals |
| OLD | NEW |