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

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: Rebased Created 6 years, 1 month 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 void AddInt64(const char* name, int64 value) override {
24 if (in_aux_attributes_)
25 dictionary_->SetDouble(name, value);
26 }
27
28 void AddInt(const char* name, int value) override {
29 if (in_aux_attributes_)
30 dictionary_->SetInteger(name, value);
31 }
32
33 void AddString(const char* name, const std::string& value) override {
34 if (in_aux_attributes_)
35 dictionary_->SetString(name, value);
36 }
37
38 void AddBool(const char* name, bool value) override {
39 if (in_aux_attributes_)
40 dictionary_->SetBoolean(name, value);
41 }
42
43 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 void BeginGPUDevice() override {}
50
51 void EndGPUDevice() override {}
52
53 void BeginVideoEncodeAcceleratorSupportedProfile() override {}
54
55 void EndVideoEncodeAcceleratorSupportedProfile() override {}
56
57 void BeginAuxAttributes() override {
58 in_aux_attributes_ = true;
59 }
60
61 void EndAuxAttributes() override {
62 in_aux_attributes_ = false;
63 }
64
65 private:
66 base::DictionaryValue* dictionary_;
67 bool in_aux_attributes_;
68 };
69
70 scoped_refptr<GPUDevice> GPUDeviceToProtocol(
71 const gpu::GPUInfo::GPUDevice& device) {
72 return GPUDevice::Create()->set_vendor_id(device.vendor_id)
73 ->set_device_id(device.device_id)
74 ->set_vendor_string(device.vendor_string)
75 ->set_device_string(device.device_string);
76 }
77
78 } // namespace
79
11 typedef DevToolsProtocolClient::Response Response; 80 typedef DevToolsProtocolClient::Response Response;
12 81
13 SystemInfoHandler::SystemInfoHandler() { 82 SystemInfoHandler::SystemInfoHandler() {
14 } 83 }
15 84
16 SystemInfoHandler::~SystemInfoHandler() { 85 SystemInfoHandler::~SystemInfoHandler() {
17 } 86 }
18 87
19 Response SystemInfoHandler::GetInfo(scoped_refptr<SystemInfo>* info) { 88 Response SystemInfoHandler::GetInfo(
20 return Response::FallThrough(); 89 scoped_refptr<devtools::system_info::GPUInfo>* gpu,
90 std::string* model_name,
91 std::string* model_version) {
92 gpu::GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo();
93
94 std::vector<scoped_refptr<GPUDevice>> devices;
95 devices.push_back(GPUDeviceToProtocol(gpu_info.gpu));
96 for (const auto& device : gpu_info.secondary_gpus)
97 devices.push_back(GPUDeviceToProtocol(device));
98
99 scoped_ptr<base::DictionaryValue> aux_attributes(new base::DictionaryValue);
100 AuxGPUInfoEnumerator enumerator(aux_attributes.get());
101 gpu_info.EnumerateFields(&enumerator);
102
103 *model_name = gpu_info.machine_model_name;
104 *model_version = gpu_info.machine_model_version;
105 *gpu = GPUInfo::Create()
106 ->set_devices(devices)
107 ->set_aux_attributes(aux_attributes.Pass())
108 ->set_feature_status(make_scoped_ptr(GetFeatureStatus()))
109 ->set_driver_bug_workarounds(GetDriverBugWorkarounds());
110 return Response::OK();
21 } 111 }
22 112
23 } // namespace system_info 113 } // namespace system_info
24 } // namespace devtools 114 } // namespace devtools
25 } // namespace content 115 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/system_info_handler.h ('k') | content/browser/gpu/compositor_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698