Chromium Code Reviews| Index: remoting/host/json_host_config.cc |
| diff --git a/remoting/host/json_host_config.cc b/remoting/host/json_host_config.cc |
| index 4e8580c27cebc17a67150aa800c759ecb8f78a32..feb865877e336c23754c285aadb01141a8c98737 100644 |
| --- a/remoting/host/json_host_config.cc |
| +++ b/remoting/host/json_host_config.cc |
| @@ -9,22 +9,19 @@ |
| #include "base/json/json_reader.h" |
| #include "base/json/json_writer.h" |
| #include "base/location.h" |
| -#include "base/message_loop_proxy.h" |
| -#include "base/synchronization/lock.h" |
| #include "base/values.h" |
| namespace remoting { |
| -JsonHostConfig::JsonHostConfig( |
| - const FilePath& filename, |
| - base::MessageLoopProxy* file_message_loop_proxy) |
| - : filename_(filename), |
| - message_loop_proxy_(file_message_loop_proxy) { |
| +JsonHostConfig::JsonHostConfig(const FilePath& filename) |
| + : filename_(filename) { |
| } |
| JsonHostConfig::~JsonHostConfig() {} |
| bool JsonHostConfig::Read() { |
| + DCHECK(CalledOnValidThread()); |
| + |
| // TODO(sergeyu): Implement better error handling here. |
| std::string file_content; |
| if (!file_util::ReadFileToString(filename_, &file_content)) { |
| @@ -37,24 +34,20 @@ bool JsonHostConfig::Read() { |
| } |
| DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.release()); |
| - base::AutoLock auto_lock(lock_); |
| values_.reset(dictionary); |
| return true; |
| } |
| -void JsonHostConfig::Save() { |
| - message_loop_proxy_->PostTask( |
| - FROM_HERE, base::Bind(&JsonHostConfig::DoWrite, this)); |
| -} |
| +bool JsonHostConfig::Save() { |
| + DCHECK(CalledOnValidThread()); |
| -void JsonHostConfig::DoWrite() { |
| std::string file_content; |
| - base::AutoLock auto_lock(lock_); |
| base::JSONWriter::WriteWithOptions(values_.get(), |
| base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| &file_content); |
| // TODO(sergeyu): Move ImportantFileWriter to base and use it here. |
| - file_util::WriteFile(filename_, file_content.c_str(), file_content.size()); |
| + return file_util::WriteFile(filename_, file_content.c_str(), |
| + file_content.size()); |
|
Lambros
2012/04/06 22:26:46
WriteFile returns int: number of bytes written, or
Sergey Ulanov
2012/04/06 22:32:53
Done.
|
| } |
| } // namespace remoting |