| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 8 #include "base/file_util.h" |
| 8 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 10 #include "base/location.h" | 11 #include "base/location.h" |
| 11 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 13 #include "base/task.h" | 14 #include "base/task.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 | 16 |
| 16 namespace remoting { | 17 namespace remoting { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 37 } | 38 } |
| 38 | 39 |
| 39 DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.release()); | 40 DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.release()); |
| 40 base::AutoLock auto_lock(lock_); | 41 base::AutoLock auto_lock(lock_); |
| 41 values_.reset(dictionary); | 42 values_.reset(dictionary); |
| 42 return true; | 43 return true; |
| 43 } | 44 } |
| 44 | 45 |
| 45 void JsonHostConfig::Save() { | 46 void JsonHostConfig::Save() { |
| 46 message_loop_proxy_->PostTask( | 47 message_loop_proxy_->PostTask( |
| 47 FROM_HERE, NewRunnableMethod(this, &JsonHostConfig::DoWrite)); | 48 FROM_HERE, base::Bind(&JsonHostConfig::DoWrite, this)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void JsonHostConfig::DoWrite() { | 51 void JsonHostConfig::DoWrite() { |
| 51 std::string file_content; | 52 std::string file_content; |
| 52 base::AutoLock auto_lock(lock_); | 53 base::AutoLock auto_lock(lock_); |
| 53 base::JSONWriter::Write(values_.get(), true, &file_content); | 54 base::JSONWriter::Write(values_.get(), true, &file_content); |
| 54 // TODO(sergeyu): Move ImportantFileWriter to base and use it here. | 55 // TODO(sergeyu): Move ImportantFileWriter to base and use it here. |
| 55 file_util::WriteFile(filename_, file_content.c_str(), file_content.size()); | 56 file_util::WriteFile(filename_, file_content.c_str(), file_content.size()); |
| 56 } | 57 } |
| 57 | 58 |
| 58 } // namespace remoting | 59 } // namespace remoting |
| OLD | NEW |