Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / remoting / host / in_memory_host_config.cc
blob486b2019af1014f379f95647aa571b8007057b69
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/host/in_memory_host_config.h"
7 #include "base/logging.h"
8 #include "base/values.h"
10 namespace remoting {
12 InMemoryHostConfig::InMemoryHostConfig()
13 : values_(new base::DictionaryValue()) {
16 InMemoryHostConfig::~InMemoryHostConfig() {}
18 bool InMemoryHostConfig::GetString(const std::string& path,
19 std::string* out_value) const {
20 DCHECK(CalledOnValidThread());
21 return values_->GetString(path, out_value);
24 bool InMemoryHostConfig::GetBoolean(const std::string& path,
25 bool* out_value) const {
26 DCHECK(CalledOnValidThread());
27 return values_->GetBoolean(path, out_value);
30 bool InMemoryHostConfig::Save() {
31 // Saving in-memory host config is not supported.
32 NOTREACHED();
33 return false;
36 void InMemoryHostConfig::SetString(const std::string& path,
37 const std::string& in_value) {
38 DCHECK(CalledOnValidThread());
39 values_->SetString(path, in_value);
42 void InMemoryHostConfig::SetBoolean(const std::string& path, bool in_value) {
43 DCHECK(CalledOnValidThread());
44 values_->SetBoolean(path, in_value);
47 bool InMemoryHostConfig::CopyFrom(const base::DictionaryValue* dictionary) {
48 bool result = true;
50 for (base::DictionaryValue::Iterator it(*dictionary); !it.IsAtEnd();
51 it.Advance()) {
52 std::string str_value;
53 bool bool_value;
54 if (it.value().GetAsString(&str_value)) {
55 SetString(it.key(), str_value);
56 } else if (it.value().GetAsBoolean(&bool_value)) {
57 SetBoolean(it.key(), bool_value);
58 } else {
59 result = false;
63 return result;
66 } // namespace remoting