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

Unified Diff: content/browser/devtools/devtools_system_info_handler.cc

Issue 21682002: Expose GPU information to Telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed pfeldman's and nduca's review feedback. Rebased. Retested. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/devtools/devtools_system_info_handler.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/devtools/devtools_system_info_handler.cc
diff --git a/content/browser/devtools/devtools_system_info_handler.cc b/content/browser/devtools/devtools_system_info_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0351f9cb8c9d9abad798369663fa709ad1e7bd7b
--- /dev/null
+++ b/content/browser/devtools/devtools_system_info_handler.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2013 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/devtools_system_info_handler.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/values.h"
+#include "content/browser/devtools/devtools_protocol_constants.h"
+#include "content/browser/gpu/gpu_data_manager_impl.h"
+#include "gpu/config/gpu_info.h"
+
+namespace content {
+
+namespace {
+
+const char kGPU[] = "gpu";
+const char kVendorId[] = "vendorId";
+const char kDeviceId[] = "deviceId";
+const char kVendorString[] = "vendorString";
+const char kDeviceString[] = "deviceString";
+const char kSecondaryGPUs[] = "secondaryGpus";
pfeldman 2013/08/14 09:18:20 I don't see neither aux gpu attributes nor machine
Ken Russell (switch to Gerrit) 2013/08/14 19:33:16 Sorry, this was a mistake on my part. The code's b
+
+class GPUInfoEnumerator : public gpu::GPUInfo::Enumerator {
+ public:
+ GPUInfoEnumerator(base::DictionaryValue* dictionary)
+ : dictionary_(dictionary) { }
+
+ virtual void AddInt64(const char* name, int64 value) OVERRIDE {
+ dictionary_->SetDouble(name, value);
pfeldman 2013/08/14 09:18:20 I don't see these in the schema.
Ken Russell (switch to Gerrit) 2013/08/14 19:33:16 Fixed.
+ }
+
+ virtual void AddInt(const char* name, int value) OVERRIDE {
+ dictionary_->SetInteger(name, value);
+ }
+
+ virtual void AddString(const char* name, const std::string& value) OVERRIDE {
+ dictionary_->SetString(name, value);
+ }
+
+ virtual void AddBool(const char* name, bool value) OVERRIDE {
+ dictionary_->SetBoolean(name, value);
+ }
+
+ virtual void AddTimeDeltaInSecondsF(const char* name,
+ const base::TimeDelta& value) OVERRIDE {
+ dictionary_->SetDouble(name, value.InSecondsF());
+ }
+
+ virtual void AddGPUDevice(const gpu::GPUInfo::GPUDevice& device) OVERRIDE {
+ base::DictionaryValue* gpu_device = new base::DictionaryValue;
+
+ // Ideally this logic would be in GPUInfo::EnumerateFields, but
+ // describing nested objects would be difficult, and add
+ // undesirable state to the Enumerator.
+ gpu_device->SetInteger(kVendorId, device.vendor_id);
+ gpu_device->SetInteger(kDeviceId, device.device_id);
+ gpu_device->SetString(kVendorString, device.vendor_string);
+ gpu_device->SetString(kDeviceString, device.device_string);
+
+ if (!dictionary_->HasKey(kGPU)) {
pfeldman 2013/08/14 09:18:20 This code would go away if you simply enumerate th
Ken Russell (switch to Gerrit) 2013/08/14 19:33:16 Restructured so (nearly) all the enumeration code
+ dictionary_->Set(kGPU, gpu_device);
+ return;
+ }
+
+ base::ListValue* secondary_gpus = NULL;
+ if (dictionary_->HasKey(kSecondaryGPUs)) {
+ bool success = dictionary_->GetList(kSecondaryGPUs, &secondary_gpus);
+ DCHECK(success);
+ } else {
+ secondary_gpus = new base::ListValue;
+ dictionary_->Set(kSecondaryGPUs, secondary_gpus);
+ }
+
+ secondary_gpus->Append(gpu_device);
+ }
+
+ private:
+ base::DictionaryValue* dictionary_;
+};
+
+} // namespace
+
+DevToolsSystemInfoHandler::DevToolsSystemInfoHandler() {
+ RegisterCommandHandler(devtools::SystemInfo::getGPUInfo::kName,
+ base::Bind(&DevToolsSystemInfoHandler::OnGetGPUInfo,
+ base::Unretained(this)));
+}
+
+DevToolsSystemInfoHandler::~DevToolsSystemInfoHandler() {
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsSystemInfoHandler::OnGetGPUInfo(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ gpu::GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo();
+ base::DictionaryValue* result = new base::DictionaryValue;
+ GPUInfoEnumerator enumerator(result);
+ gpu_info.EnumerateFields(&enumerator);
+ return command->SuccessResponse(result);
+}
+
+} // namespace content
« no previous file with comments | « content/browser/devtools/devtools_system_info_handler.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698