| 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 bool CompositeHostConfig::AddConfigPath(const FilePath& path) { |
| 18 scoped_ptr<JsonHostConfig> config(new JsonHostConfig(path)); | 18 scoped_ptr<JsonHostConfig> config(new JsonHostConfig(path)); |
| 19 if (!config->Read()) { | 19 if (!config->Read()) { |
| 20 return false; | 20 return false; |
| 21 } | 21 } |
| 22 configs_.push_back(config.release()); | 22 configs_.push_back(config.release()); |
| 23 return true; | 23 return true; |
| 24 } | 24 } |
| 25 | 25 |
| 26 bool CompositeHostConfig::Reload() { |
| 27 bool result = true; |
| 28 for (ScopedVector<JsonHostConfig>::iterator it = configs_.begin(); |
| 29 it != configs_.end(); ++it) { |
| 30 result = result && (*it)->Read(); |
| 31 } |
| 32 return result; |
| 33 } |
| 34 |
| 26 bool CompositeHostConfig::GetString(const std::string& path, | 35 bool CompositeHostConfig::GetString(const std::string& path, |
| 27 std::string* out_value) const { | 36 std::string* out_value) const { |
| 28 for (std::vector<HostConfig*>::const_iterator it = configs_.begin(); | 37 for (ScopedVector<JsonHostConfig>::const_iterator it = configs_.begin(); |
| 29 it != configs_.end(); ++it) { | 38 it != configs_.end(); ++it) { |
| 30 if ((*it)->GetString(path, out_value)) | 39 if ((*it)->GetString(path, out_value)) |
| 31 return true; | 40 return true; |
| 32 } | 41 } |
| 33 return false; | 42 return false; |
| 34 } | 43 } |
| 35 | 44 |
| 36 bool CompositeHostConfig::GetBoolean(const std::string& path, | 45 bool CompositeHostConfig::GetBoolean(const std::string& path, |
| 37 bool* out_value) const { | 46 bool* out_value) const { |
| 38 for (std::vector<HostConfig*>::const_iterator it = configs_.begin(); | 47 for (ScopedVector<JsonHostConfig>::const_iterator it = configs_.begin(); |
| 39 it != configs_.end(); ++it) { | 48 it != configs_.end(); ++it) { |
| 40 if ((*it)->GetBoolean(path, out_value)) | 49 if ((*it)->GetBoolean(path, out_value)) |
| 41 return true; | 50 return true; |
| 42 } | 51 } |
| 43 return false; | 52 return false; |
| 44 } | 53 } |
| 45 | 54 |
| 46 } // namespace remoting | 55 } // namespace remoting |
| OLD | NEW |