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

Side by Side Diff: content/browser/devtools/protocol/system_info_handler.cc

Issue 665123002: [DevTools] Move SystemInfo domain to generated handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browserProtocol
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devtools/protocol/system_info_handler.h" 5 #include "content/browser/devtools/protocol/system_info_handler.h"
6 6
7 #include "content/browser/gpu/compositor_util.h"
8 #include "content/browser/gpu/gpu_data_manager_impl.h"
9 #include "gpu/config/gpu_info.h"
10
7 namespace content { 11 namespace content {
8 namespace devtools { 12 namespace devtools {
9 namespace system_info { 13 namespace system_info {
10 14
15 namespace {
16
17 class AuxGPUInfoEnumerator : public gpu::GPUInfo::Enumerator {
18 public:
19 AuxGPUInfoEnumerator(base::DictionaryValue* dictionary)
20 : dictionary_(dictionary),
21 in_aux_attributes_(false) { }
22
23 virtual void AddInt64(const char* name, int64 value) override {
dgozman 2014/10/28 10:19:58 nit: remove all "virtual" keywords from overrides
vkuzkokov 2014/10/28 11:57:50 Done.
24 if (in_aux_attributes_)
25 dictionary_->SetDouble(name, value);
26 }
27
28 virtual void AddInt(const char* name, int value) override {
29 if (in_aux_attributes_)
30 dictionary_->SetInteger(name, value);
31 }
32
33 virtual void AddString(const char* name, const std::string& value) override {
34 if (in_aux_attributes_)
35 dictionary_->SetString(name, value);
36 }
37
38 virtual void AddBool(const char* name, bool value) override {
39 if (in_aux_attributes_)
40 dictionary_->SetBoolean(name, value);
41 }
42
43 virtual void AddTimeDeltaInSecondsF(const char* name,
44 const base::TimeDelta& value) override {
45 if (in_aux_attributes_)
46 dictionary_->SetDouble(name, value.InSecondsF());
47 }
48
49 virtual void BeginGPUDevice() override {
50 }
51
52 virtual void EndGPUDevice() override {
53 }
54
55 virtual void BeginVideoEncodeAcceleratorSupportedProfile() override {}
56
57 virtual void EndVideoEncodeAcceleratorSupportedProfile() override {}
58
59 virtual void BeginAuxAttributes() override {
60 in_aux_attributes_ = true;
61 }
62
63 virtual void EndAuxAttributes() override {
64 in_aux_attributes_ = false;
65 }
66
67 private:
68 base::DictionaryValue* dictionary_;
69 bool in_aux_attributes_;
70 };
71
72 GPUDevice GPUDeviceToDictionary(
dgozman 2014/10/28 10:19:58 I'd call this |GPUDeviceToProtocol| or something.
vkuzkokov 2014/10/28 11:57:50 Done.
73 const gpu::GPUInfo::GPUDevice& device) {
74 return GPUDevice::Create().set_vendor_id(device.vendor_id)
75 .set_device_id(device.device_id)
76 .set_vendor_string(device.vendor_string)
77 .set_device_string(device.device_string)
78 .Pass();
79 }
80
81 } // namespace
82
11 typedef DevToolsProtocolClient::Response Response; 83 typedef DevToolsProtocolClient::Response Response;
12 84
13 SystemInfoHandler::SystemInfoHandler() { 85 SystemInfoHandler::SystemInfoHandler() {
14 } 86 }
15 87
16 SystemInfoHandler::~SystemInfoHandler() { 88 SystemInfoHandler::~SystemInfoHandler() {
17 } 89 }
18 90
19 Response SystemInfoHandler::GetInfo(SystemInfo* info) { 91 Response SystemInfoHandler::GetInfo(SystemInfo* info) {
20 return Response::FallThrough(); 92 gpu::GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo();
93
94 ListBuilder<GPUDevice> devices;
95 devices.push_back(GPUDeviceToDictionary(gpu_info.gpu).Pass());
96 for (const auto& device : gpu_info.secondary_gpus)
97 devices.push_back(GPUDeviceToDictionary(device).Pass());
98
99 scoped_ptr<base::DictionaryValue> aux_attributes(new base::DictionaryValue);
100 AuxGPUInfoEnumerator enumerator(aux_attributes.get());
101 gpu_info.EnumerateFields(&enumerator);
102
103 ListBuilder<std::string> workarounds;
104 for (const std::string& workaround : GetDriverBugWorkarounds())
105 workarounds.push_back(workaround);
dgozman 2014/10/28 10:19:58 Why don't we have ListBuilder(vector<string>) ?
vkuzkokov 2014/10/28 11:57:50 It has a single use (here) and should be discourag
106
107 *info = SystemInfo::Create()
108 .set_model_name(gpu_info.machine_model_name)
109 .set_model_version(gpu_info.machine_model_version)
110 .set_gpu(GPUInfo::Create()
111 .set_devices(devices.Pass())
112 .set_aux_attributes(aux_attributes.Pass())
113 .set_feature_status(make_scoped_ptr(GetFeatureStatus()))
114 .set_driver_bug_workarounds(workarounds.Pass())
115 .Pass())
116 .Pass();
117 return Response::OK();
21 } 118 }
22 119
23 } // namespace system_info 120 } // namespace system_info
24 } // namespace devtools 121 } // namespace devtools
25 } // namespace content 122 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698