OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/composite_host_config.h" | 5 #include "remoting/host/composite_host_config.h" |
6 | 6 |
7 #include "remoting/host/json_host_config.h" | 7 #include "remoting/host/json_host_config.h" |
8 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 | 10 |
11 CompositeHostConfig::CompositeHostConfig() { | 11 CompositeHostConfig::CompositeHostConfig() { |
12 } | 12 } |
13 | 13 |
14 CompositeHostConfig::~CompositeHostConfig() { | 14 CompositeHostConfig::~CompositeHostConfig() { |
15 } | 15 } |
16 | 16 |
17 bool CompositeHostConfig::AddConfigPath(const FilePath& path) { | 17 void CompositeHostConfig::AddConfigPath(const FilePath& path) { |
18 scoped_ptr<JsonHostConfig> config(new JsonHostConfig(path)); | 18 configs_.push_back(new JsonHostConfig(path)); |
19 if (!config->Read()) { | 19 } |
20 return false; | 20 |
| 21 bool CompositeHostConfig::Read() { |
| 22 bool result = true; |
| 23 for (ScopedVector<JsonHostConfig>::iterator it = configs_.begin(); |
| 24 it != configs_.end(); ++it) { |
| 25 result = result && (*it)->Read(); |
21 } | 26 } |
22 configs_.push_back(config.release()); | 27 return result; |
23 return true; | |
24 } | 28 } |
25 | 29 |
26 bool CompositeHostConfig::GetString(const std::string& path, | 30 bool CompositeHostConfig::GetString(const std::string& path, |
27 std::string* out_value) const { | 31 std::string* out_value) const { |
28 for (std::vector<HostConfig*>::const_iterator it = configs_.begin(); | 32 for (ScopedVector<JsonHostConfig>::const_iterator it = configs_.begin(); |
29 it != configs_.end(); ++it) { | 33 it != configs_.end(); ++it) { |
30 if ((*it)->GetString(path, out_value)) | 34 if ((*it)->GetString(path, out_value)) |
31 return true; | 35 return true; |
32 } | 36 } |
33 return false; | 37 return false; |
34 } | 38 } |
35 | 39 |
36 bool CompositeHostConfig::GetBoolean(const std::string& path, | 40 bool CompositeHostConfig::GetBoolean(const std::string& path, |
37 bool* out_value) const { | 41 bool* out_value) const { |
38 for (std::vector<HostConfig*>::const_iterator it = configs_.begin(); | 42 for (ScopedVector<JsonHostConfig>::const_iterator it = configs_.begin(); |
39 it != configs_.end(); ++it) { | 43 it != configs_.end(); ++it) { |
40 if ((*it)->GetBoolean(path, out_value)) | 44 if ((*it)->GetBoolean(path, out_value)) |
41 return true; | 45 return true; |
42 } | 46 } |
43 return false; | 47 return false; |
44 } | 48 } |
45 | 49 |
46 } // namespace remoting | 50 } // namespace remoting |
OLD | NEW |