feat: Implementation of getGPUInfo API. (#13486)
* Implementation of getGPUInfo API. * Clear promise set * Changes to promise usage * Minor fixes * Fix linux build * Update spec * Fix lint (linter didn't run on windows locally) * Test running single test for CI * Update spec
This commit is contained in:
parent
638311b6b3
commit
5c108728d6
13 changed files with 529 additions and 127 deletions
102
atom/browser/api/gpu_info_enumerator.cc
Normal file
102
atom/browser/api/gpu_info_enumerator.cc
Normal file
|
@ -0,0 +1,102 @@
|
|||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/gpu_info_enumerator.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace atom {
|
||||
|
||||
GPUInfoEnumerator::GPUInfoEnumerator()
|
||||
: value_stack(), current(std::make_unique<base::DictionaryValue>()) {}
|
||||
|
||||
GPUInfoEnumerator::~GPUInfoEnumerator() {}
|
||||
|
||||
void GPUInfoEnumerator::AddInt64(const char* name, int64_t value) {
|
||||
current->SetInteger(name, value);
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::AddInt(const char* name, int value) {
|
||||
current->SetInteger(name, value);
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::AddString(const char* name, const std::string& value) {
|
||||
if (!value.empty())
|
||||
current->SetString(name, value);
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::AddBool(const char* name, bool value) {
|
||||
current->SetBoolean(name, value);
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::AddTimeDeltaInSecondsF(const char* name,
|
||||
const base::TimeDelta& value) {
|
||||
current->SetInteger(name, value.InMilliseconds());
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::BeginGPUDevice() {
|
||||
value_stack.push(std::move(current));
|
||||
current = std::make_unique<base::DictionaryValue>();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::EndGPUDevice() {
|
||||
auto& top_value = value_stack.top();
|
||||
// GPUDevice can be more than one. So create a list of all.
|
||||
// The first one is the active GPU device.
|
||||
if (top_value->HasKey(kGPUDeviceKey)) {
|
||||
base::ListValue* list;
|
||||
top_value->GetList(kGPUDeviceKey, &list);
|
||||
list->Append(std::move(current));
|
||||
} else {
|
||||
auto gpus = std::make_unique<base::ListValue>();
|
||||
gpus->Append(std::move(current));
|
||||
top_value->SetList(kGPUDeviceKey, std::move(gpus));
|
||||
}
|
||||
current = std::move(top_value);
|
||||
value_stack.pop();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::BeginVideoDecodeAcceleratorSupportedProfile() {
|
||||
value_stack.push(std::move(current));
|
||||
current = std::make_unique<base::DictionaryValue>();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::EndVideoDecodeAcceleratorSupportedProfile() {
|
||||
auto& top_value = value_stack.top();
|
||||
top_value->SetDictionary(kVideoDecodeAcceleratorSupportedProfileKey,
|
||||
std::move(current));
|
||||
current = std::move(top_value);
|
||||
value_stack.pop();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::BeginVideoEncodeAcceleratorSupportedProfile() {
|
||||
value_stack.push(std::move(current));
|
||||
current = std::make_unique<base::DictionaryValue>();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::EndVideoEncodeAcceleratorSupportedProfile() {
|
||||
auto& top_value = value_stack.top();
|
||||
top_value->SetDictionary(kVideoEncodeAcceleratorSupportedProfileKey,
|
||||
std::move(current));
|
||||
current = std::move(top_value);
|
||||
value_stack.pop();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::BeginAuxAttributes() {
|
||||
value_stack.push(std::move(current));
|
||||
current = std::make_unique<base::DictionaryValue>();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::EndAuxAttributes() {
|
||||
auto& top_value = value_stack.top();
|
||||
top_value->SetDictionary(kAuxAttributesKey, std::move(current));
|
||||
current = std::move(top_value);
|
||||
value_stack.pop();
|
||||
}
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> GPUInfoEnumerator::GetDictionary() {
|
||||
return std::move(current);
|
||||
}
|
||||
|
||||
} // namespace atom
|
Loading…
Add table
Add a link
Reference in a new issue