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

Side by Side Diff: content/browser/gpu/gpu_internals_ui.cc

Issue 12207089: Cleanup: Remove deprecated base::Value methods from contents. Use base::Value too. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/gpu/gpu_blacklist.cc ('k') | content/browser/media/media_internals.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/gpu/gpu_internals_ui.h" 5 #include "content/browser/gpu/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 WebUIDataSource* CreateGpuHTMLSource() { 43 WebUIDataSource* CreateGpuHTMLSource() {
44 WebUIDataSource* source = WebUIDataSource::Create(chrome::kChromeUIGpuHost); 44 WebUIDataSource* source = WebUIDataSource::Create(chrome::kChromeUIGpuHost);
45 45
46 source->SetJsonPath("strings.js"); 46 source->SetJsonPath("strings.js");
47 source->AddResourcePath("gpu_internals.js", IDR_GPU_INTERNALS_JS); 47 source->AddResourcePath("gpu_internals.js", IDR_GPU_INTERNALS_JS);
48 source->SetDefaultResource(IDR_GPU_INTERNALS_HTML); 48 source->SetDefaultResource(IDR_GPU_INTERNALS_HTML);
49 return source; 49 return source;
50 } 50 }
51 51
52 DictionaryValue* NewDescriptionValuePair(const std::string& desc, 52 base::DictionaryValue* NewDescriptionValuePair(const std::string& desc,
53 const std::string& value) { 53 const std::string& value) {
54 DictionaryValue* dict = new DictionaryValue(); 54 base::DictionaryValue* dict = new base::DictionaryValue();
55 dict->SetString("description", desc); 55 dict->SetString("description", desc);
56 dict->SetString("value", value); 56 dict->SetString("value", value);
57 return dict; 57 return dict;
58 } 58 }
59 59
60 DictionaryValue* NewDescriptionValuePair(const std::string& desc, 60 base::DictionaryValue* NewDescriptionValuePair(const std::string& desc,
61 Value* value) { 61 Value* value) {
62 DictionaryValue* dict = new DictionaryValue(); 62 base::DictionaryValue* dict = new base::DictionaryValue();
63 dict->SetString("description", desc); 63 dict->SetString("description", desc);
64 dict->Set("value", value); 64 dict->Set("value", value);
65 return dict; 65 return dict;
66 } 66 }
67 67
68 Value* NewStatusValue(const char* name, const char* status) { 68 base::Value* NewStatusValue(const char* name, const char* status) {
69 DictionaryValue* value = new DictionaryValue(); 69 base::DictionaryValue* value = new base::DictionaryValue();
70 value->SetString("name", name); 70 value->SetString("name", name);
71 value->SetString("status", status); 71 value->SetString("status", status);
72 return value; 72 return value;
73 } 73 }
74 74
75 #if defined(OS_WIN) 75 #if defined(OS_WIN)
76 // Output DxDiagNode tree as nested array of {description,value} pairs 76 // Output DxDiagNode tree as nested array of {description,value} pairs
77 ListValue* DxDiagNodeToList(const DxDiagNode& node) { 77 base::ListValue* DxDiagNodeToList(const DxDiagNode& node) {
78 ListValue* list = new ListValue(); 78 base::ListValue* list = new ListValue();
79 for (std::map<std::string, std::string>::const_iterator it = 79 for (std::map<std::string, std::string>::const_iterator it =
80 node.values.begin(); 80 node.values.begin();
81 it != node.values.end(); 81 it != node.values.end();
82 ++it) { 82 ++it) {
83 list->Append(NewDescriptionValuePair(it->first, it->second)); 83 list->Append(NewDescriptionValuePair(it->first, it->second));
84 } 84 }
85 85
86 for (std::map<std::string, DxDiagNode>::const_iterator it = 86 for (std::map<std::string, DxDiagNode>::const_iterator it =
87 node.children.begin(); 87 node.children.begin();
88 it != node.children.end(); 88 it != node.children.end();
89 ++it) { 89 ++it) {
90 ListValue* sublist = DxDiagNodeToList(it->second); 90 base::ListValue* sublist = DxDiagNodeToList(it->second);
91 list->Append(NewDescriptionValuePair(it->first, sublist)); 91 list->Append(NewDescriptionValuePair(it->first, sublist));
92 } 92 }
93 return list; 93 return list;
94 } 94 }
95 #endif 95 #endif
96 96
97 std::string GPUDeviceToString(const GPUInfo::GPUDevice& gpu) { 97 std::string GPUDeviceToString(const GPUInfo::GPUDevice& gpu) {
98 std::string vendor = base::StringPrintf("0x%04x", gpu.vendor_id); 98 std::string vendor = base::StringPrintf("0x%04x", gpu.vendor_id);
99 if (!gpu.vendor_string.empty()) 99 if (!gpu.vendor_string.empty())
100 vendor += " [" + gpu.vendor_string + "]"; 100 vendor += " [" + gpu.vendor_string + "]";
101 std::string device = base::StringPrintf("0x%04x", gpu.device_id); 101 std::string device = base::StringPrintf("0x%04x", gpu.device_id);
102 if (!gpu.device_string.empty()) 102 if (!gpu.device_string.empty())
103 device += " [" + gpu.device_string + "]"; 103 device += " [" + gpu.device_string + "]";
104 return base::StringPrintf( 104 return base::StringPrintf(
105 "VENDOR = %s, DEVICE= %s", vendor.c_str(), device.c_str()); 105 "VENDOR = %s, DEVICE= %s", vendor.c_str(), device.c_str());
106 } 106 }
107 107
108 DictionaryValue* GpuInfoAsDictionaryValue() { 108 base::DictionaryValue* GpuInfoAsDictionaryValue() {
109 GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); 109 GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo();
110 ListValue* basic_info = new ListValue(); 110 base::ListValue* basic_info = new base::ListValue();
111 basic_info->Append(NewDescriptionValuePair( 111 basic_info->Append(NewDescriptionValuePair(
112 "Initialization time", 112 "Initialization time",
113 base::Int64ToString(gpu_info.initialization_time.InMilliseconds()))); 113 base::Int64ToString(gpu_info.initialization_time.InMilliseconds())));
114 basic_info->Append(NewDescriptionValuePair( 114 basic_info->Append(NewDescriptionValuePair(
115 "Sandboxed", 115 "Sandboxed", new base::FundamentalValue(gpu_info.sandboxed)));
116 Value::CreateBooleanValue(gpu_info.sandboxed)));
117 basic_info->Append(NewDescriptionValuePair( 116 basic_info->Append(NewDescriptionValuePair(
118 "GPU0", GPUDeviceToString(gpu_info.gpu))); 117 "GPU0", GPUDeviceToString(gpu_info.gpu)));
119 for (size_t i = 0; i < gpu_info.secondary_gpus.size(); ++i) { 118 for (size_t i = 0; i < gpu_info.secondary_gpus.size(); ++i) {
120 basic_info->Append(NewDescriptionValuePair( 119 basic_info->Append(NewDescriptionValuePair(
121 base::StringPrintf("GPU%d", static_cast<int>(i + 1)), 120 base::StringPrintf("GPU%d", static_cast<int>(i + 1)),
122 GPUDeviceToString(gpu_info.secondary_gpus[i]))); 121 GPUDeviceToString(gpu_info.secondary_gpus[i])));
123 } 122 }
124 basic_info->Append(NewDescriptionValuePair( 123 basic_info->Append(NewDescriptionValuePair(
125 "Optimus", Value::CreateBooleanValue(gpu_info.optimus))); 124 "Optimus", new base::FundamentalValue(gpu_info.optimus)));
126 basic_info->Append(NewDescriptionValuePair( 125 basic_info->Append(NewDescriptionValuePair(
127 "AMD switchable", Value::CreateBooleanValue(gpu_info.amd_switchable))); 126 "AMD switchable", new base::FundamentalValue(gpu_info.amd_switchable)));
128 basic_info->Append(NewDescriptionValuePair("Driver vendor", 127 basic_info->Append(NewDescriptionValuePair("Driver vendor",
129 gpu_info.driver_vendor)); 128 gpu_info.driver_vendor));
130 basic_info->Append(NewDescriptionValuePair("Driver version", 129 basic_info->Append(NewDescriptionValuePair("Driver version",
131 gpu_info.driver_version)); 130 gpu_info.driver_version));
132 basic_info->Append(NewDescriptionValuePair("Driver date", 131 basic_info->Append(NewDescriptionValuePair("Driver date",
133 gpu_info.driver_date)); 132 gpu_info.driver_date));
134 basic_info->Append(NewDescriptionValuePair("Pixel shader version", 133 basic_info->Append(NewDescriptionValuePair("Pixel shader version",
135 gpu_info.pixel_shader_version)); 134 gpu_info.pixel_shader_version));
136 basic_info->Append(NewDescriptionValuePair("Vertex shader version", 135 basic_info->Append(NewDescriptionValuePair("Vertex shader version",
137 gpu_info.vertex_shader_version)); 136 gpu_info.vertex_shader_version));
138 basic_info->Append(NewDescriptionValuePair("Machine model", 137 basic_info->Append(NewDescriptionValuePair("Machine model",
139 gpu_info.machine_model)); 138 gpu_info.machine_model));
140 basic_info->Append(NewDescriptionValuePair("GL version", 139 basic_info->Append(NewDescriptionValuePair("GL version",
141 gpu_info.gl_version)); 140 gpu_info.gl_version));
142 basic_info->Append(NewDescriptionValuePair("GL_VENDOR", 141 basic_info->Append(NewDescriptionValuePair("GL_VENDOR",
143 gpu_info.gl_vendor)); 142 gpu_info.gl_vendor));
144 basic_info->Append(NewDescriptionValuePair("GL_RENDERER", 143 basic_info->Append(NewDescriptionValuePair("GL_RENDERER",
145 gpu_info.gl_renderer)); 144 gpu_info.gl_renderer));
146 basic_info->Append(NewDescriptionValuePair("GL_VERSION", 145 basic_info->Append(NewDescriptionValuePair("GL_VERSION",
147 gpu_info.gl_version_string)); 146 gpu_info.gl_version_string));
148 basic_info->Append(NewDescriptionValuePair("GL_EXTENSIONS", 147 basic_info->Append(NewDescriptionValuePair("GL_EXTENSIONS",
149 gpu_info.gl_extensions)); 148 gpu_info.gl_extensions));
150 149
151 DictionaryValue* info = new DictionaryValue(); 150 base::DictionaryValue* info = new base::DictionaryValue();
152 info->Set("basic_info", basic_info); 151 info->Set("basic_info", basic_info);
153 152
154 #if defined(OS_WIN) 153 #if defined(OS_WIN)
155 ListValue* perf_info = new ListValue(); 154 base::ListValue* perf_info = new base::ListValue();
156 perf_info->Append(NewDescriptionValuePair( 155 perf_info->Append(NewDescriptionValuePair(
157 "Graphics", 156 "Graphics",
158 base::StringPrintf("%.1f", gpu_info.performance_stats.graphics))); 157 base::StringPrintf("%.1f", gpu_info.performance_stats.graphics)));
159 perf_info->Append(NewDescriptionValuePair( 158 perf_info->Append(NewDescriptionValuePair(
160 "Gaming", 159 "Gaming",
161 base::StringPrintf("%.1f", gpu_info.performance_stats.gaming))); 160 base::StringPrintf("%.1f", gpu_info.performance_stats.gaming)));
162 perf_info->Append(NewDescriptionValuePair( 161 perf_info->Append(NewDescriptionValuePair(
163 "Overall", 162 "Overall",
164 base::StringPrintf("%.1f", gpu_info.performance_stats.overall))); 163 base::StringPrintf("%.1f", gpu_info.performance_stats.overall)));
165 info->Set("performance_info", perf_info); 164 info->Set("performance_info", perf_info);
166 165
167 Value* dx_info; 166 base::Value* dx_info = gpu_info.dx_diagnostics.children.size() ?
168 if (gpu_info.dx_diagnostics.children.size()) 167 DxDiagNodeToList(gpu_info.dx_diagnostics) :
169 dx_info = DxDiagNodeToList(gpu_info.dx_diagnostics); 168 base::Value::CreateNullValue();
170 else
171 dx_info = Value::CreateNullValue();
172 info->Set("diagnostics", dx_info); 169 info->Set("diagnostics", dx_info);
173 #endif 170 #endif
174 171
175 return info; 172 return info;
176 } 173 }
177 174
178 // Determine if accelerated-2d-canvas is supported, which depends on whether 175 // Determine if accelerated-2d-canvas is supported, which depends on whether
179 // lose_context could happen and whether skia is the backend. 176 // lose_context could happen and whether skia is the backend.
180 bool SupportsAccelerated2dCanvas() { 177 bool SupportsAccelerated2dCanvas() {
181 if (GpuDataManagerImpl::GetInstance()->GetGPUInfo().can_lose_context) 178 if (GpuDataManagerImpl::GetInstance()->GetGPUInfo().can_lose_context)
182 return false; 179 return false;
183 #if defined(USE_SKIA) 180 #if defined(USE_SKIA)
184 return true; 181 return true;
185 #else 182 #else
186 return false; 183 return false;
187 #endif 184 #endif
188 } 185 }
189 186
190 Value* GetFeatureStatus() { 187 base::Value* GetFeatureStatus() {
191 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 188 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
192 bool gpu_access_blocked = 189 bool gpu_access_blocked =
193 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(); 190 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed();
194 191
195 uint32 flags = GpuDataManagerImpl::GetInstance()->GetBlacklistedFeatures(); 192 uint32 flags = GpuDataManagerImpl::GetInstance()->GetBlacklistedFeatures();
196 DictionaryValue* status = new DictionaryValue(); 193 base::DictionaryValue* status = new base::DictionaryValue();
197 194
198 const GpuFeatureInfo kGpuFeatureInfo[] = { 195 const GpuFeatureInfo kGpuFeatureInfo[] = {
199 { 196 {
200 "2d_canvas", 197 "2d_canvas",
201 flags & GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, 198 flags & GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS,
202 command_line.HasSwitch(switches::kDisableAccelerated2dCanvas) || 199 command_line.HasSwitch(switches::kDisableAccelerated2dCanvas) ||
203 !SupportsAccelerated2dCanvas(), 200 !SupportsAccelerated2dCanvas(),
204 "Accelerated 2D canvas is unavailable: either disabled at the command" 201 "Accelerated 2D canvas is unavailable: either disabled at the command"
205 " line or not supported by the current system.", 202 " line or not supported by the current system.",
206 true 203 true
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 !(flags & GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE), 309 !(flags & GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE),
313 "Force compositing mode is off, either disabled at the command" 310 "Force compositing mode is off, either disabled at the command"
314 " line or not supported by the current system.", 311 " line or not supported by the current system.",
315 false 312 false
316 } 313 }
317 }; 314 };
318 const size_t kNumFeatures = sizeof(kGpuFeatureInfo) / sizeof(GpuFeatureInfo); 315 const size_t kNumFeatures = sizeof(kGpuFeatureInfo) / sizeof(GpuFeatureInfo);
319 316
320 // Build the feature_status field. 317 // Build the feature_status field.
321 { 318 {
322 ListValue* feature_status_list = new ListValue(); 319 base::ListValue* feature_status_list = new base::ListValue();
323 320
324 for (size_t i = 0; i < kNumFeatures; ++i) { 321 for (size_t i = 0; i < kNumFeatures; ++i) {
325 // force_compositing_mode status is part of the compositing status. 322 // force_compositing_mode status is part of the compositing status.
326 if (kGpuFeatureInfo[i].name == "force_compositing_mode") 323 if (kGpuFeatureInfo[i].name == "force_compositing_mode")
327 continue; 324 continue;
328 325
329 std::string status; 326 std::string status;
330 if (kGpuFeatureInfo[i].disabled) { 327 if (kGpuFeatureInfo[i].disabled) {
331 status = "disabled"; 328 status = "disabled";
332 if (kGpuFeatureInfo[i].name == "css_animation") { 329 if (kGpuFeatureInfo[i].name == "css_animation") {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 break; 386 break;
390 } 387 }
391 feature_status_list->Append( 388 feature_status_list->Append(
392 NewStatusValue("gpu_switching", gpu_switching.c_str())); 389 NewStatusValue("gpu_switching", gpu_switching.c_str()));
393 } 390 }
394 status->Set("featureStatus", feature_status_list); 391 status->Set("featureStatus", feature_status_list);
395 } 392 }
396 393
397 // Build the problems list. 394 // Build the problems list.
398 { 395 {
399 ListValue* problem_list = 396 base::ListValue* problem_list =
400 GpuDataManagerImpl::GetInstance()->GetBlacklistReasons(); 397 GpuDataManagerImpl::GetInstance()->GetBlacklistReasons();
401 398
402 if (gpu_access_blocked) { 399 if (gpu_access_blocked) {
403 DictionaryValue* problem = new DictionaryValue(); 400 base::DictionaryValue* problem = new base::DictionaryValue();
404 problem->SetString("description", 401 problem->SetString("description",
405 "GPU process was unable to boot. Access to GPU disallowed."); 402 "GPU process was unable to boot. Access to GPU disallowed.");
406 problem->Set("crBugs", new ListValue()); 403 problem->Set("crBugs", new base::ListValue());
407 problem->Set("webkitBugs", new ListValue()); 404 problem->Set("webkitBugs", new base::ListValue());
408 problem_list->Append(problem); 405 problem_list->Append(problem);
409 } 406 }
410 407
411 for (size_t i = 0; i < kNumFeatures; ++i) { 408 for (size_t i = 0; i < kNumFeatures; ++i) {
412 if (kGpuFeatureInfo[i].disabled) { 409 if (kGpuFeatureInfo[i].disabled) {
413 DictionaryValue* problem = new DictionaryValue(); 410 base::DictionaryValue* problem = new base::DictionaryValue();
414 problem->SetString( 411 problem->SetString(
415 "description", kGpuFeatureInfo[i].disabled_description); 412 "description", kGpuFeatureInfo[i].disabled_description);
416 problem->Set("crBugs", new ListValue()); 413 problem->Set("crBugs", new base::ListValue());
417 problem->Set("webkitBugs", new ListValue()); 414 problem->Set("webkitBugs", new base::ListValue());
418 problem_list->Append(problem); 415 problem_list->Append(problem);
419 } 416 }
420 } 417 }
421 418
422 status->Set("problems", problem_list); 419 status->Set("problems", problem_list);
423 } 420 }
424 421
425 return status; 422 return status;
426 } 423 }
427 424
(...skipping 10 matching lines...) Expand all
438 435
439 // WebUIMessageHandler implementation. 436 // WebUIMessageHandler implementation.
440 virtual void RegisterMessages() OVERRIDE; 437 virtual void RegisterMessages() OVERRIDE;
441 438
442 // GpuDataManagerObserver implementation. 439 // GpuDataManagerObserver implementation.
443 virtual void OnGpuInfoUpdate() OVERRIDE; 440 virtual void OnGpuInfoUpdate() OVERRIDE;
444 virtual void OnVideoMemoryUsageStatsUpdate( 441 virtual void OnVideoMemoryUsageStatsUpdate(
445 const GPUVideoMemoryUsageStats& video_memory_usage_stats) OVERRIDE {} 442 const GPUVideoMemoryUsageStats& video_memory_usage_stats) OVERRIDE {}
446 443
447 // Messages 444 // Messages
448 void OnBrowserBridgeInitialized(const ListValue* list); 445 void OnBrowserBridgeInitialized(const base::ListValue* list);
449 void OnCallAsync(const ListValue* list); 446 void OnCallAsync(const base::ListValue* list);
450 447
451 // Submessages dispatched from OnCallAsync 448 // Submessages dispatched from OnCallAsync
452 Value* OnRequestClientInfo(const ListValue* list); 449 base::Value* OnRequestClientInfo(const base::ListValue* list);
453 Value* OnRequestLogMessages(const ListValue* list); 450 base::Value* OnRequestLogMessages(const base::ListValue* list);
454 451
455 private: 452 private:
456 // True if observing the GpuDataManager (re-attaching as observer would 453 // True if observing the GpuDataManager (re-attaching as observer would
457 // DCHECK). 454 // DCHECK).
458 bool observing_; 455 bool observing_;
459 456
460 DISALLOW_COPY_AND_ASSIGN(GpuMessageHandler); 457 DISALLOW_COPY_AND_ASSIGN(GpuMessageHandler);
461 }; 458 };
462 459
463 //////////////////////////////////////////////////////////////////////////////// 460 ////////////////////////////////////////////////////////////////////////////////
(...skipping 15 matching lines...) Expand all
479 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
480 477
481 web_ui()->RegisterMessageCallback("browserBridgeInitialized", 478 web_ui()->RegisterMessageCallback("browserBridgeInitialized",
482 base::Bind(&GpuMessageHandler::OnBrowserBridgeInitialized, 479 base::Bind(&GpuMessageHandler::OnBrowserBridgeInitialized,
483 base::Unretained(this))); 480 base::Unretained(this)));
484 web_ui()->RegisterMessageCallback("callAsync", 481 web_ui()->RegisterMessageCallback("callAsync",
485 base::Bind(&GpuMessageHandler::OnCallAsync, 482 base::Bind(&GpuMessageHandler::OnCallAsync,
486 base::Unretained(this))); 483 base::Unretained(this)));
487 } 484 }
488 485
489 void GpuMessageHandler::OnCallAsync(const ListValue* args) { 486 void GpuMessageHandler::OnCallAsync(const base::ListValue* args) {
490 DCHECK_GE(args->GetSize(), static_cast<size_t>(2)); 487 DCHECK_GE(args->GetSize(), static_cast<size_t>(2));
491 // unpack args into requestId, submessage and submessageArgs 488 // unpack args into requestId, submessage and submessageArgs
492 bool ok; 489 bool ok;
493 const Value* requestId; 490 const base::Value* requestId;
494 ok = args->Get(0, &requestId); 491 ok = args->Get(0, &requestId);
495 DCHECK(ok); 492 DCHECK(ok);
496 493
497 std::string submessage; 494 std::string submessage;
498 ok = args->GetString(1, &submessage); 495 ok = args->GetString(1, &submessage);
499 DCHECK(ok); 496 DCHECK(ok);
500 497
501 ListValue* submessageArgs = new ListValue(); 498 base::ListValue* submessageArgs = new base::ListValue();
502 for (size_t i = 2; i < args->GetSize(); ++i) { 499 for (size_t i = 2; i < args->GetSize(); ++i) {
503 const Value* arg; 500 const base::Value* arg;
504 ok = args->Get(i, &arg); 501 ok = args->Get(i, &arg);
505 DCHECK(ok); 502 DCHECK(ok);
506 503
507 Value* argCopy = arg->DeepCopy(); 504 base::Value* argCopy = arg->DeepCopy();
508 submessageArgs->Append(argCopy); 505 submessageArgs->Append(argCopy);
509 } 506 }
510 507
511 // call the submessage handler 508 // call the submessage handler
512 Value* ret = NULL; 509 base::Value* ret = NULL;
513 if (submessage == "requestClientInfo") { 510 if (submessage == "requestClientInfo") {
514 ret = OnRequestClientInfo(submessageArgs); 511 ret = OnRequestClientInfo(submessageArgs);
515 } else if (submessage == "requestLogMessages") { 512 } else if (submessage == "requestLogMessages") {
516 ret = OnRequestLogMessages(submessageArgs); 513 ret = OnRequestLogMessages(submessageArgs);
517 } else { // unrecognized submessage 514 } else { // unrecognized submessage
518 NOTREACHED(); 515 NOTREACHED();
519 delete submessageArgs; 516 delete submessageArgs;
520 return; 517 return;
521 } 518 }
522 delete submessageArgs; 519 delete submessageArgs;
523 520
524 // call BrowserBridge.onCallAsyncReply with result 521 // call BrowserBridge.onCallAsyncReply with result
525 if (ret) { 522 if (ret) {
526 web_ui()->CallJavascriptFunction("browserBridge.onCallAsyncReply", 523 web_ui()->CallJavascriptFunction("browserBridge.onCallAsyncReply",
527 *requestId, 524 *requestId,
528 *ret); 525 *ret);
529 delete ret; 526 delete ret;
530 } else { 527 } else {
531 web_ui()->CallJavascriptFunction("browserBridge.onCallAsyncReply", 528 web_ui()->CallJavascriptFunction("browserBridge.onCallAsyncReply",
532 *requestId); 529 *requestId);
533 } 530 }
534 } 531 }
535 532
536 void GpuMessageHandler::OnBrowserBridgeInitialized(const ListValue* args) { 533 void GpuMessageHandler::OnBrowserBridgeInitialized(
534 const base::ListValue* args) {
537 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 535 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
538 536
539 // Watch for changes in GPUInfo 537 // Watch for changes in GPUInfo
540 if (!observing_) 538 if (!observing_)
541 GpuDataManagerImpl::GetInstance()->AddObserver(this); 539 GpuDataManagerImpl::GetInstance()->AddObserver(this);
542 observing_ = true; 540 observing_ = true;
543 541
544 // Tell GpuDataManager it should have full GpuInfo. If the 542 // Tell GpuDataManager it should have full GpuInfo. If the
545 // Gpu process has not run yet, this will trigger its launch. 543 // Gpu process has not run yet, this will trigger its launch.
546 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); 544 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded();
547 545
548 // Run callback immediately in case the info is ready and no update in the 546 // Run callback immediately in case the info is ready and no update in the
549 // future. 547 // future.
550 OnGpuInfoUpdate(); 548 OnGpuInfoUpdate();
551 } 549 }
552 550
553 Value* GpuMessageHandler::OnRequestClientInfo(const ListValue* list) { 551 base::Value* GpuMessageHandler::OnRequestClientInfo(
552 const base::ListValue* list) {
554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 553 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
555 554
556 DictionaryValue* dict = new DictionaryValue(); 555 base::DictionaryValue* dict = new base::DictionaryValue();
557 556
558 dict->SetString("version", GetContentClient()->GetProduct()); 557 dict->SetString("version", GetContentClient()->GetProduct());
559 dict->SetString("command_line", 558 dict->SetString("command_line",
560 CommandLine::ForCurrentProcess()->GetCommandLineString()); 559 CommandLine::ForCurrentProcess()->GetCommandLineString());
561 dict->SetString("operating_system", 560 dict->SetString("operating_system",
562 base::SysInfo::OperatingSystemName() + " " + 561 base::SysInfo::OperatingSystemName() + " " +
563 base::SysInfo::OperatingSystemVersion()); 562 base::SysInfo::OperatingSystemVersion());
564 dict->SetString("angle_revision", base::UintToString(BUILD_REVISION)); 563 dict->SetString("angle_revision", base::UintToString(BUILD_REVISION));
565 #if defined(USE_SKIA) 564 #if defined(USE_SKIA)
566 dict->SetString("graphics_backend", "Skia"); 565 dict->SetString("graphics_backend", "Skia");
567 #else 566 #else
568 dict->SetString("graphics_backend", "Core Graphics"); 567 dict->SetString("graphics_backend", "Core Graphics");
569 #endif 568 #endif
570 dict->SetString("blacklist_version", 569 dict->SetString("blacklist_version",
571 GpuDataManagerImpl::GetInstance()->GetBlacklistVersion()); 570 GpuDataManagerImpl::GetInstance()->GetBlacklistVersion());
572 571
573 return dict; 572 return dict;
574 } 573 }
575 574
576 Value* GpuMessageHandler::OnRequestLogMessages(const ListValue*) { 575 base::Value* GpuMessageHandler::OnRequestLogMessages(const base::ListValue*) {
577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
578 577
579 return GpuDataManagerImpl::GetInstance()->GetLogMessages(); 578 return GpuDataManagerImpl::GetInstance()->GetLogMessages();
580 } 579 }
581 580
582 void GpuMessageHandler::OnGpuInfoUpdate() { 581 void GpuMessageHandler::OnGpuInfoUpdate() {
583 // Get GPU Info. 582 // Get GPU Info.
584 scoped_ptr<base::DictionaryValue> gpu_info_val( 583 scoped_ptr<base::DictionaryValue> gpu_info_val(GpuInfoAsDictionaryValue());
585 GpuInfoAsDictionaryValue());
586 584
587 // Add in blacklisting features 585 // Add in blacklisting features
588 Value* feature_status = GetFeatureStatus(); 586 base::Value* feature_status = GetFeatureStatus();
589 if (feature_status) 587 if (feature_status)
590 gpu_info_val->Set("featureStatus", feature_status); 588 gpu_info_val->Set("featureStatus", feature_status);
591 589
592 // Send GPU Info to javascript. 590 // Send GPU Info to javascript.
593 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", 591 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate",
594 *(gpu_info_val.get())); 592 *(gpu_info_val.get()));
595 } 593 }
596 594
597 } // namespace 595 } // namespace
598 596
599 597
600 //////////////////////////////////////////////////////////////////////////////// 598 ////////////////////////////////////////////////////////////////////////////////
601 // 599 //
602 // GpuInternalsUI 600 // GpuInternalsUI
603 // 601 //
604 //////////////////////////////////////////////////////////////////////////////// 602 ////////////////////////////////////////////////////////////////////////////////
605 603
606 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) 604 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui)
607 : WebUIController(web_ui) { 605 : WebUIController(web_ui) {
608 web_ui->AddMessageHandler(new GpuMessageHandler()); 606 web_ui->AddMessageHandler(new GpuMessageHandler());
609 607
610 // Set up the chrome://gpu/ source. 608 // Set up the chrome://gpu/ source.
611 BrowserContext* browser_context = 609 BrowserContext* browser_context =
612 web_ui->GetWebContents()->GetBrowserContext(); 610 web_ui->GetWebContents()->GetBrowserContext();
613 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); 611 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource());
614 } 612 }
615 613
616 } // namespace content 614 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_blacklist.cc ('k') | content/browser/media/media_internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698