| 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/json_host_config.h" | 5 #include "remoting/host/json_host_config.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/important_file_writer.h" | 9 #include "base/files/important_file_writer.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 JsonHostConfig::JsonHostConfig(const base::FilePath& filename) | 18 JsonHostConfig::JsonHostConfig(const base::FilePath& filename) |
| 19 : filename_(filename) { | 19 : filename_(filename) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 JsonHostConfig::~JsonHostConfig() {} | 22 JsonHostConfig::~JsonHostConfig() {} |
| 23 | 23 |
| 24 bool JsonHostConfig::Read() { | 24 bool JsonHostConfig::Read() { |
| 25 DCHECK(CalledOnValidThread()); | 25 DCHECK(CalledOnValidThread()); |
| 26 | 26 |
| 27 // TODO(sergeyu): Implement better error handling here. | 27 // TODO(sergeyu): Implement better error handling here. |
| 28 std::string file_content; | 28 std::string file_content; |
| 29 if (!file_util::ReadFileToString(filename_, &file_content)) { | 29 if (!base::ReadFileToString(filename_, &file_content)) { |
| 30 LOG(WARNING) << "Failed to read " << filename_.value(); | 30 LOG(WARNING) << "Failed to read " << filename_.value(); |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 | 33 |
| 34 return SetSerializedData(file_content); | 34 return SetSerializedData(file_content); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool JsonHostConfig::Save() { | 37 bool JsonHostConfig::Save() { |
| 38 DCHECK(CalledOnValidThread()); | 38 DCHECK(CalledOnValidThread()); |
| 39 | 39 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 54 LOG(WARNING) << "Failed to parse " << filename_.value(); | 54 LOG(WARNING) << "Failed to parse " << filename_.value(); |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.release()); | 58 DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.release()); |
| 59 values_.reset(dictionary); | 59 values_.reset(dictionary); |
| 60 return true; | 60 return true; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace remoting | 63 } // namespace remoting |
| OLD | NEW |