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 2a0366e95900411c153f7dad7269facb2305eb05..d0fd5087d05cb49b22c5b7d35dd60ae7559b09f8 100644 |
--- a/content/browser/devtools/protocol/system_info_handler.cc |
+++ b/content/browser/devtools/protocol/system_info_handler.cc |
@@ -4,10 +4,79 @@ |
#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) { } |
+ |
+ void AddInt64(const char* name, int64 value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetDouble(name, value); |
+ } |
+ |
+ void AddInt(const char* name, int value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetInteger(name, value); |
+ } |
+ |
+ void AddString(const char* name, const std::string& value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetString(name, value); |
+ } |
+ |
+ void AddBool(const char* name, bool value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetBoolean(name, value); |
+ } |
+ |
+ void AddTimeDeltaInSecondsF(const char* name, |
+ const base::TimeDelta& value) override { |
+ if (in_aux_attributes_) |
+ dictionary_->SetDouble(name, value.InSecondsF()); |
+ } |
+ |
+ void BeginGPUDevice() override {} |
+ |
+ void EndGPUDevice() override {} |
+ |
+ void BeginVideoEncodeAcceleratorSupportedProfile() override {} |
+ |
+ void EndVideoEncodeAcceleratorSupportedProfile() override {} |
+ |
+ void BeginAuxAttributes() override { |
+ in_aux_attributes_ = true; |
+ } |
+ |
+ void EndAuxAttributes() override { |
+ in_aux_attributes_ = false; |
+ } |
+ |
+ private: |
+ base::DictionaryValue* dictionary_; |
+ bool in_aux_attributes_; |
+}; |
+ |
+scoped_refptr<GPUDevice> GPUDeviceToProtocol( |
+ 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); |
+} |
+ |
+} // namespace |
+ |
typedef DevToolsProtocolClient::Response Response; |
SystemInfoHandler::SystemInfoHandler() { |
@@ -16,8 +85,29 @@ SystemInfoHandler::SystemInfoHandler() { |
SystemInfoHandler::~SystemInfoHandler() { |
} |
-Response SystemInfoHandler::GetInfo(scoped_refptr<SystemInfo>* info) { |
- return Response::FallThrough(); |
+Response SystemInfoHandler::GetInfo( |
+ scoped_refptr<devtools::system_info::GPUInfo>* gpu, |
+ std::string* model_name, |
+ std::string* model_version) { |
+ gpu::GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); |
+ |
+ std::vector<scoped_refptr<GPUDevice>> devices; |
+ devices.push_back(GPUDeviceToProtocol(gpu_info.gpu)); |
+ for (const auto& device : gpu_info.secondary_gpus) |
+ devices.push_back(GPUDeviceToProtocol(device)); |
+ |
+ scoped_ptr<base::DictionaryValue> aux_attributes(new base::DictionaryValue); |
+ AuxGPUInfoEnumerator enumerator(aux_attributes.get()); |
+ gpu_info.EnumerateFields(&enumerator); |
+ |
+ *model_name = gpu_info.machine_model_name; |
+ *model_version = gpu_info.machine_model_version; |
+ *gpu = GPUInfo::Create() |
+ ->set_devices(devices) |
+ ->set_aux_attributes(aux_attributes.Pass()) |
+ ->set_feature_status(make_scoped_ptr(GetFeatureStatus())) |
+ ->set_driver_bug_workarounds(GetDriverBugWorkarounds()); |
+ return Response::OK(); |
} |
} // namespace system_info |