Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gpu_internals_ui.h" | 5 #include "chrome/browser/ui/webui/gpu_internals_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 Value* OnRequestLogMessages(const ListValue* list); | 80 Value* OnRequestLogMessages(const ListValue* list); |
| 81 Value* OnRequestCrashList(const ListValue* list); | 81 Value* OnRequestCrashList(const ListValue* list); |
| 82 | 82 |
| 83 // Executes the javascript function |function_name| in the renderer, passing | 83 // Executes the javascript function |function_name| in the renderer, passing |
| 84 // it the argument |value|. | 84 // it the argument |value|. |
| 85 void CallJavascriptFunction(const std::wstring& function_name, | 85 void CallJavascriptFunction(const std::wstring& function_name, |
| 86 const Value* value); | 86 const Value* value); |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 scoped_refptr<CrashUploadList> crash_list_; | 89 scoped_refptr<CrashUploadList> crash_list_; |
| 90 bool crash_list_available_; | 90 bool crash_list_available_; |
|
Dan Beam
2012/04/21 02:53:07
doc comment
Evan Stade
2012/04/24 17:52:40
Done.
| |
| 91 bool observing_; | |
| 91 | 92 |
| 92 DISALLOW_COPY_AND_ASSIGN(GpuMessageHandler); | 93 DISALLOW_COPY_AND_ASSIGN(GpuMessageHandler); |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 //////////////////////////////////////////////////////////////////////////////// | 96 //////////////////////////////////////////////////////////////////////////////// |
| 96 // | 97 // |
| 97 // GpuMessageHandler | 98 // GpuMessageHandler |
| 98 // | 99 // |
| 99 //////////////////////////////////////////////////////////////////////////////// | 100 //////////////////////////////////////////////////////////////////////////////// |
| 100 | 101 |
| 101 GpuMessageHandler::GpuMessageHandler() | 102 GpuMessageHandler::GpuMessageHandler() |
| 102 : crash_list_available_(false) { | 103 : crash_list_available_(false), |
| 104 observing_(true) { | |
|
stuartmorgan
2012/04/24 09:12:20
It's initialized to true, and only set to true fro
Evan Stade
2012/04/24 17:52:40
yea, good catch.
| |
| 103 crash_list_ = CrashUploadList::Create(this); | 105 crash_list_ = CrashUploadList::Create(this); |
| 104 } | 106 } |
| 105 | 107 |
| 106 GpuMessageHandler::~GpuMessageHandler() { | 108 GpuMessageHandler::~GpuMessageHandler() { |
| 107 GpuDataManager::GetInstance()->RemoveObserver(this); | 109 GpuDataManager::GetInstance()->RemoveObserver(this); |
| 108 crash_list_->ClearDelegate(); | 110 crash_list_->ClearDelegate(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 /* BrowserBridge.callAsync prepends a requestID to these messages. */ | 113 /* BrowserBridge.callAsync prepends a requestID to these messages. */ |
| 112 void GpuMessageHandler::RegisterMessages() { | 114 void GpuMessageHandler::RegisterMessages() { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 } else { | 170 } else { |
| 169 web_ui()->CallJavascriptFunction("browserBridge.onCallAsyncReply", | 171 web_ui()->CallJavascriptFunction("browserBridge.onCallAsyncReply", |
| 170 *requestId); | 172 *requestId); |
| 171 } | 173 } |
| 172 } | 174 } |
| 173 | 175 |
| 174 void GpuMessageHandler::OnBrowserBridgeInitialized(const ListValue* args) { | 176 void GpuMessageHandler::OnBrowserBridgeInitialized(const ListValue* args) { |
| 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 176 | 178 |
| 177 // Watch for changes in GPUInfo | 179 // Watch for changes in GPUInfo |
| 178 GpuDataManager::GetInstance()->AddObserver(this); | 180 if (!observing_) |
| 181 GpuDataManager::GetInstance()->AddObserver(this); | |
| 182 observing_ = true; | |
| 179 | 183 |
| 180 // Tell GpuDataManager it should have full GpuInfo. If the | 184 // Tell GpuDataManager it should have full GpuInfo. If the |
| 181 // Gpu process has not run yet, this will trigger its launch. | 185 // Gpu process has not run yet, this will trigger its launch. |
| 182 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded(); | 186 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded(); |
| 183 | 187 |
| 184 // Run callback immediately in case the info is ready and no update in the | 188 // Run callback immediately in case the info is ready and no update in the |
| 185 // future. | 189 // future. |
| 186 OnGpuInfoUpdate(); | 190 OnGpuInfoUpdate(); |
| 187 } | 191 } |
| 188 | 192 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 //////////////////////////////////////////////////////////////////////////////// | 292 //////////////////////////////////////////////////////////////////////////////// |
| 289 | 293 |
| 290 GpuInternalsUI::GpuInternalsUI(content::WebUI* web_ui) | 294 GpuInternalsUI::GpuInternalsUI(content::WebUI* web_ui) |
| 291 : WebUIController(web_ui) { | 295 : WebUIController(web_ui) { |
| 292 web_ui->AddMessageHandler(new GpuMessageHandler()); | 296 web_ui->AddMessageHandler(new GpuMessageHandler()); |
| 293 | 297 |
| 294 // Set up the chrome://gpu-internals/ source. | 298 // Set up the chrome://gpu-internals/ source. |
| 295 Profile* profile = Profile::FromWebUI(web_ui); | 299 Profile* profile = Profile::FromWebUI(web_ui); |
| 296 profile->GetChromeURLDataManager()->AddDataSource(CreateGpuHTMLSource()); | 300 profile->GetChromeURLDataManager()->AddDataSource(CreateGpuHTMLSource()); |
| 297 } | 301 } |
| OLD | NEW |