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

Side by Side Diff: content/browser/devtools/devtools_system_info_handler.cc

Issue 21682002: Expose GPU information to Telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed pfeldman's and nduca's review feedback. Rebased. Retested. Created 7 years, 4 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/devtools/devtools_system_info_handler.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/devtools/devtools_system_info_handler.h"
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/values.h"
10 #include "content/browser/devtools/devtools_protocol_constants.h"
11 #include "content/browser/gpu/gpu_data_manager_impl.h"
12 #include "gpu/config/gpu_info.h"
13
14 namespace content {
15
16 namespace {
17
18 const char kGPU[] = "gpu";
19 const char kVendorId[] = "vendorId";
20 const char kDeviceId[] = "deviceId";
21 const char kVendorString[] = "vendorString";
22 const char kDeviceString[] = "deviceString";
23 const char kSecondaryGPUs[] = "secondaryGpus";
pfeldman 2013/08/14 09:18:20 I don't see neither aux gpu attributes nor machine
Ken Russell (switch to Gerrit) 2013/08/14 19:33:16 Sorry, this was a mistake on my part. The code's b
24
25 class GPUInfoEnumerator : public gpu::GPUInfo::Enumerator {
26 public:
27 GPUInfoEnumerator(base::DictionaryValue* dictionary)
28 : dictionary_(dictionary) { }
29
30 virtual void AddInt64(const char* name, int64 value) OVERRIDE {
31 dictionary_->SetDouble(name, value);
pfeldman 2013/08/14 09:18:20 I don't see these in the schema.
Ken Russell (switch to Gerrit) 2013/08/14 19:33:16 Fixed.
32 }
33
34 virtual void AddInt(const char* name, int value) OVERRIDE {
35 dictionary_->SetInteger(name, value);
36 }
37
38 virtual void AddString(const char* name, const std::string& value) OVERRIDE {
39 dictionary_->SetString(name, value);
40 }
41
42 virtual void AddBool(const char* name, bool value) OVERRIDE {
43 dictionary_->SetBoolean(name, value);
44 }
45
46 virtual void AddTimeDeltaInSecondsF(const char* name,
47 const base::TimeDelta& value) OVERRIDE {
48 dictionary_->SetDouble(name, value.InSecondsF());
49 }
50
51 virtual void AddGPUDevice(const gpu::GPUInfo::GPUDevice& device) OVERRIDE {
52 base::DictionaryValue* gpu_device = new base::DictionaryValue;
53
54 // Ideally this logic would be in GPUInfo::EnumerateFields, but
55 // describing nested objects would be difficult, and add
56 // undesirable state to the Enumerator.
57 gpu_device->SetInteger(kVendorId, device.vendor_id);
58 gpu_device->SetInteger(kDeviceId, device.device_id);
59 gpu_device->SetString(kVendorString, device.vendor_string);
60 gpu_device->SetString(kDeviceString, device.device_string);
61
62 if (!dictionary_->HasKey(kGPU)) {
pfeldman 2013/08/14 09:18:20 This code would go away if you simply enumerate th
Ken Russell (switch to Gerrit) 2013/08/14 19:33:16 Restructured so (nearly) all the enumeration code
63 dictionary_->Set(kGPU, gpu_device);
64 return;
65 }
66
67 base::ListValue* secondary_gpus = NULL;
68 if (dictionary_->HasKey(kSecondaryGPUs)) {
69 bool success = dictionary_->GetList(kSecondaryGPUs, &secondary_gpus);
70 DCHECK(success);
71 } else {
72 secondary_gpus = new base::ListValue;
73 dictionary_->Set(kSecondaryGPUs, secondary_gpus);
74 }
75
76 secondary_gpus->Append(gpu_device);
77 }
78
79 private:
80 base::DictionaryValue* dictionary_;
81 };
82
83 } // namespace
84
85 DevToolsSystemInfoHandler::DevToolsSystemInfoHandler() {
86 RegisterCommandHandler(devtools::SystemInfo::getGPUInfo::kName,
87 base::Bind(&DevToolsSystemInfoHandler::OnGetGPUInfo,
88 base::Unretained(this)));
89 }
90
91 DevToolsSystemInfoHandler::~DevToolsSystemInfoHandler() {
92 }
93
94 scoped_refptr<DevToolsProtocol::Response>
95 DevToolsSystemInfoHandler::OnGetGPUInfo(
96 scoped_refptr<DevToolsProtocol::Command> command) {
97 gpu::GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo();
98 base::DictionaryValue* result = new base::DictionaryValue;
99 GPUInfoEnumerator enumerator(result);
100 gpu_info.EnumerateFields(&enumerator);
101 return command->SuccessResponse(result);
102 }
103
104 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_system_info_handler.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698