1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#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() {
}
SystemInfoHandler::~SystemInfoHandler() {
}
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
} // namespace devtools
} // namespace content
|