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 "content/browser/gpu/gpu_internals_ui.h" | 5 #include "content/browser/gpu/gpu_internals_ui.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 WebUIDataSource* CreateGpuHTMLSource() { | 61 WebUIDataSource* CreateGpuHTMLSource() { |
62 WebUIDataSource* source = WebUIDataSource::Create(kChromeUIGpuHost); | 62 WebUIDataSource* source = WebUIDataSource::Create(kChromeUIGpuHost); |
63 | 63 |
64 source->SetJsonPath("strings.js"); | 64 source->SetJsonPath("strings.js"); |
65 source->AddResourcePath("gpu_internals.js", IDR_GPU_INTERNALS_JS); | 65 source->AddResourcePath("gpu_internals.js", IDR_GPU_INTERNALS_JS); |
66 source->SetDefaultResource(IDR_GPU_INTERNALS_HTML); | 66 source->SetDefaultResource(IDR_GPU_INTERNALS_HTML); |
67 source->DisableI18nAndUseGzipForAllPaths(); | 67 source->DisableI18nAndUseGzipForAllPaths(); |
68 return source; | 68 return source; |
69 } | 69 } |
70 | 70 |
71 base::DictionaryValue* NewDescriptionValuePair(const std::string& desc, | 71 std::unique_ptr<base::DictionaryValue> NewDescriptionValuePair( |
| 72 const std::string& desc, |
72 const std::string& value) { | 73 const std::string& value) { |
73 base::DictionaryValue* dict = new base::DictionaryValue(); | 74 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
74 dict->SetString("description", desc); | 75 dict->SetString("description", desc); |
75 dict->SetString("value", value); | 76 dict->SetString("value", value); |
76 return dict; | 77 return dict; |
77 } | 78 } |
78 | 79 |
79 base::DictionaryValue* NewDescriptionValuePair(const std::string& desc, | 80 std::unique_ptr<base::DictionaryValue> NewDescriptionValuePair( |
| 81 const std::string& desc, |
80 base::Value* value) { | 82 base::Value* value) { |
81 base::DictionaryValue* dict = new base::DictionaryValue(); | 83 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
82 dict->SetString("description", desc); | 84 dict->SetString("description", desc); |
83 dict->Set("value", value); | 85 dict->Set("value", value); |
84 return dict; | 86 return dict; |
85 } | 87 } |
86 | 88 |
87 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
88 // Output DxDiagNode tree as nested array of {description,value} pairs | 90 // Output DxDiagNode tree as nested array of {description,value} pairs |
89 base::ListValue* DxDiagNodeToList(const gpu::DxDiagNode& node) { | 91 base::ListValue* DxDiagNodeToList(const gpu::DxDiagNode& node) { |
90 base::ListValue* list = new base::ListValue(); | 92 base::ListValue* list = new base::ListValue(); |
91 for (std::map<std::string, std::string>::const_iterator it = | 93 for (std::map<std::string, std::string>::const_iterator it = |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 std::string submessage; | 424 std::string submessage; |
423 ok = args->GetString(1, &submessage); | 425 ok = args->GetString(1, &submessage); |
424 DCHECK(ok); | 426 DCHECK(ok); |
425 | 427 |
426 base::ListValue* submessageArgs = new base::ListValue(); | 428 base::ListValue* submessageArgs = new base::ListValue(); |
427 for (size_t i = 2; i < args->GetSize(); ++i) { | 429 for (size_t i = 2; i < args->GetSize(); ++i) { |
428 const base::Value* arg; | 430 const base::Value* arg; |
429 ok = args->Get(i, &arg); | 431 ok = args->Get(i, &arg); |
430 DCHECK(ok); | 432 DCHECK(ok); |
431 | 433 |
432 base::Value* argCopy = arg->DeepCopy(); | 434 submessageArgs->Append(arg->CreateDeepCopy()); |
433 submessageArgs->Append(argCopy); | |
434 } | 435 } |
435 | 436 |
436 // call the submessage handler | 437 // call the submessage handler |
437 base::Value* ret = NULL; | 438 base::Value* ret = NULL; |
438 if (submessage == "requestClientInfo") { | 439 if (submessage == "requestClientInfo") { |
439 ret = OnRequestClientInfo(submessageArgs); | 440 ret = OnRequestClientInfo(submessageArgs); |
440 } else if (submessage == "requestLogMessages") { | 441 } else if (submessage == "requestLogMessages") { |
441 ret = OnRequestLogMessages(submessageArgs); | 442 ret = OnRequestLogMessages(submessageArgs); |
442 } else { // unrecognized submessage | 443 } else { // unrecognized submessage |
443 NOTREACHED(); | 444 NOTREACHED(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 : WebUIController(web_ui) { | 547 : WebUIController(web_ui) { |
547 web_ui->AddMessageHandler(new GpuMessageHandler()); | 548 web_ui->AddMessageHandler(new GpuMessageHandler()); |
548 | 549 |
549 // Set up the chrome://gpu/ source. | 550 // Set up the chrome://gpu/ source. |
550 BrowserContext* browser_context = | 551 BrowserContext* browser_context = |
551 web_ui->GetWebContents()->GetBrowserContext(); | 552 web_ui->GetWebContents()->GetBrowserContext(); |
552 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); | 553 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); |
553 } | 554 } |
554 | 555 |
555 } // namespace content | 556 } // namespace content |
OLD | NEW |