Index: content/browser/devtools/protocol/system_info_handler.cc |
diff --git a/content/browser/devtools/protocol/system_info_handler.cc b/content/browser/devtools/protocol/system_info_handler.cc |
index 007e4d795cac625ec72c4ff8bd3101d2d9ae63d5..a1c76d3ff48fc6c2bd754ee3528353d970ba162c 100644 |
--- a/content/browser/devtools/protocol/system_info_handler.cc |
+++ b/content/browser/devtools/protocol/system_info_handler.cc |
@@ -4,10 +4,82 @@ |
#include "content/browser/devtools/protocol/system_info_handler.h" |
+#include "content/browser/gpu/compositor_util.h" |
+#include "content/browser/gpu/gpu_data_manager_impl.h" |
+#include "gpu/config/gpu_info.h" |
+ |
namespace content { |
namespace devtools { |
namespace system_info { |
+namespace { |
+ |
+class AuxGPUInfoEnumerator : public gpu::GPUInfo::Enumerator { |
+ public: |
+ AuxGPUInfoEnumerator(base::DictionaryValue* dictionary) |
+ : dictionary_(dictionary), |
+ in_aux_attributes_(false) { } |
+ |
+ 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.
|
+ if (in_aux_attributes_) |
+ dictionary_->SetDouble(name, value); |
+ } |
+ |
+ virtual void AddInt(const char* name, int value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetInteger(name, value); |
+ } |
+ |
+ virtual void AddString(const char* name, const std::string& value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetString(name, value); |
+ } |
+ |
+ virtual void AddBool(const char* name, bool value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetBoolean(name, value); |
+ } |
+ |
+ virtual void AddTimeDeltaInSecondsF(const char* name, |
+ const base::TimeDelta& value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetDouble(name, value.InSecondsF()); |
+ } |
+ |
+ virtual void BeginGPUDevice() override { |
+ } |
+ |
+ virtual void EndGPUDevice() override { |
+ } |
+ |
+ virtual void BeginVideoEncodeAcceleratorSupportedProfile() override {} |
+ |
+ virtual void EndVideoEncodeAcceleratorSupportedProfile() override {} |
+ |
+ virtual void BeginAuxAttributes() override { |
+ in_aux_attributes_ = true; |
+ } |
+ |
+ virtual void EndAuxAttributes() override { |
+ in_aux_attributes_ = false; |
+ } |
+ |
+ private: |
+ base::DictionaryValue* dictionary_; |
+ bool in_aux_attributes_; |
+}; |
+ |
+GPUDevice GPUDeviceToDictionary( |
dgozman
2014/10/28 10:19:58
I'd call this |GPUDeviceToProtocol| or something.
vkuzkokov
2014/10/28 11:57:50
Done.
|
+ const gpu::GPUInfo::GPUDevice& device) { |
+ return GPUDevice::Create().set_vendor_id(device.vendor_id) |
+ .set_device_id(device.device_id) |
+ .set_vendor_string(device.vendor_string) |
+ .set_device_string(device.device_string) |
+ .Pass(); |
+} |
+ |
+} // namespace |
+ |
typedef DevToolsProtocolClient::Response Response; |
SystemInfoHandler::SystemInfoHandler() { |
@@ -17,7 +89,32 @@ SystemInfoHandler::~SystemInfoHandler() { |
} |
Response SystemInfoHandler::GetInfo(SystemInfo* info) { |
- return Response::FallThrough(); |
+ gpu::GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); |
+ |
+ ListBuilder<GPUDevice> devices; |
+ devices.push_back(GPUDeviceToDictionary(gpu_info.gpu).Pass()); |
+ for (const auto& device : gpu_info.secondary_gpus) |
+ devices.push_back(GPUDeviceToDictionary(device).Pass()); |
+ |
+ scoped_ptr<base::DictionaryValue> aux_attributes(new base::DictionaryValue); |
+ AuxGPUInfoEnumerator enumerator(aux_attributes.get()); |
+ gpu_info.EnumerateFields(&enumerator); |
+ |
+ ListBuilder<std::string> workarounds; |
+ for (const std::string& workaround : GetDriverBugWorkarounds()) |
+ 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
|
+ |
+ *info = SystemInfo::Create() |
+ .set_model_name(gpu_info.machine_model_name) |
+ .set_model_version(gpu_info.machine_model_version) |
+ .set_gpu(GPUInfo::Create() |
+ .set_devices(devices.Pass()) |
+ .set_aux_attributes(aux_attributes.Pass()) |
+ .set_feature_status(make_scoped_ptr(GetFeatureStatus())) |
+ .set_driver_bug_workarounds(workarounds.Pass()) |
+ .Pass()) |
+ .Pass(); |
+ return Response::OK(); |
} |
} // namespace system_info |