Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: remoting/host/json_host_config.cc

Issue 10007048: Cleanup and simplify HostConfig and JsonHostConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698