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"
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.
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
) {
50 for (base::DictionaryValue::Iterator
it(*dictionary
); !it
.IsAtEnd();
52 std::string str_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
);
66 } // namespace remoting