Index: sync/notifier/sync_system_resources.cc |
diff --git a/sync/notifier/chrome_system_resources.cc b/sync/notifier/sync_system_resources.cc |
similarity index 64% |
rename from sync/notifier/chrome_system_resources.cc |
rename to sync/notifier/sync_system_resources.cc |
index af4cf9a31695c452a8b51b8439ac1717a6b1872e..53286579af13e02efbd3248ad5daa93d90a6a93e 100644 |
--- a/sync/notifier/chrome_system_resources.cc |
+++ b/sync/notifier/sync_system_resources.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "sync/notifier/chrome_system_resources.h" |
+#include "sync/notifier/sync_system_resources.h" |
#include <cstdlib> |
#include <cstring> |
@@ -21,11 +21,11 @@ |
namespace syncer { |
-ChromeLogger::ChromeLogger() {} |
-ChromeLogger::~ChromeLogger() {} |
+SyncLogger::SyncLogger() {} |
+SyncLogger::~SyncLogger() {} |
-void ChromeLogger::Log(LogLevel level, const char* file, int line, |
- const char* format, ...) { |
+void SyncLogger::Log(LogLevel level, const char* file, int line, |
+ const char* format, ...) { |
logging::LogSeverity log_severity = -2; // VLOG(2) |
bool emit_log = false; |
switch (level) { |
@@ -56,12 +56,11 @@ void ChromeLogger::Log(LogLevel level, const char* file, int line, |
} |
} |
-void ChromeLogger::SetSystemResources( |
- invalidation::SystemResources* resources) { |
+void SyncLogger::SetSystemResources(invalidation::SystemResources* resources) { |
// Do nothing. |
} |
-ChromeScheduler::ChromeScheduler() |
+SyncInvalidationScheduler::SyncInvalidationScheduler() |
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
created_on_loop_(MessageLoop::current()), |
is_started_(false), |
@@ -69,12 +68,12 @@ ChromeScheduler::ChromeScheduler() |
CHECK(created_on_loop_); |
} |
-ChromeScheduler::~ChromeScheduler() { |
+SyncInvalidationScheduler::~SyncInvalidationScheduler() { |
CHECK_EQ(created_on_loop_, MessageLoop::current()); |
CHECK(is_stopped_); |
} |
-void ChromeScheduler::Start() { |
+void SyncInvalidationScheduler::Start() { |
CHECK_EQ(created_on_loop_, MessageLoop::current()); |
CHECK(!is_started_); |
is_started_ = true; |
@@ -82,7 +81,7 @@ void ChromeScheduler::Start() { |
weak_factory_.InvalidateWeakPtrs(); |
} |
-void ChromeScheduler::Stop() { |
+void SyncInvalidationScheduler::Stop() { |
CHECK_EQ(created_on_loop_, MessageLoop::current()); |
is_stopped_ = true; |
is_started_ = false; |
@@ -91,8 +90,8 @@ void ChromeScheduler::Stop() { |
posted_tasks_.clear(); |
} |
-void ChromeScheduler::Schedule(invalidation::TimeDelta delay, |
- invalidation::Closure* task) { |
+void SyncInvalidationScheduler::Schedule(invalidation::TimeDelta delay, |
+ invalidation::Closure* task) { |
DCHECK(invalidation::IsCallbackRepeatable(task)); |
CHECK_EQ(created_on_loop_, MessageLoop::current()); |
@@ -103,44 +102,44 @@ void ChromeScheduler::Schedule(invalidation::TimeDelta delay, |
posted_tasks_.insert(task); |
MessageLoop::current()->PostDelayedTask( |
- FROM_HERE, base::Bind(&ChromeScheduler::RunPostedTask, |
+ FROM_HERE, base::Bind(&SyncInvalidationScheduler::RunPostedTask, |
weak_factory_.GetWeakPtr(), task), |
delay); |
} |
-bool ChromeScheduler::IsRunningOnThread() const { |
+bool SyncInvalidationScheduler::IsRunningOnThread() const { |
return created_on_loop_ == MessageLoop::current(); |
} |
-invalidation::Time ChromeScheduler::GetCurrentTime() const { |
+invalidation::Time SyncInvalidationScheduler::GetCurrentTime() const { |
CHECK_EQ(created_on_loop_, MessageLoop::current()); |
return base::Time::Now(); |
} |
-void ChromeScheduler::SetSystemResources( |
+void SyncInvalidationScheduler::SetSystemResources( |
invalidation::SystemResources* resources) { |
// Do nothing. |
} |
-void ChromeScheduler::RunPostedTask(invalidation::Closure* task) { |
+void SyncInvalidationScheduler::RunPostedTask(invalidation::Closure* task) { |
CHECK_EQ(created_on_loop_, MessageLoop::current()); |
task->Run(); |
posted_tasks_.erase(task); |
delete task; |
} |
-ChromeStorage::ChromeStorage(StateWriter* state_writer, |
- invalidation::Scheduler* scheduler) |
+SyncStorage::SyncStorage(StateWriter* state_writer, |
+ invalidation::Scheduler* scheduler) |
: state_writer_(state_writer), |
scheduler_(scheduler) { |
DCHECK(state_writer_); |
DCHECK(scheduler_); |
} |
-ChromeStorage::~ChromeStorage() {} |
+SyncStorage::~SyncStorage() {} |
-void ChromeStorage::WriteKey(const std::string& key, const std::string& value, |
- invalidation::WriteKeyCallback* done) { |
+void SyncStorage::WriteKey(const std::string& key, const std::string& value, |
+ invalidation::WriteKeyCallback* done) { |
CHECK(state_writer_); |
// TODO(ghc): actually write key,value associations, and don't invoke the |
// callback until the operation completes. |
@@ -154,39 +153,39 @@ void ChromeStorage::WriteKey(const std::string& key, const std::string& value, |
scheduler_->Schedule( |
invalidation::Scheduler::NoDelay(), |
invalidation::NewPermanentCallback( |
- this, &ChromeStorage::RunAndDeleteWriteKeyCallback, |
+ this, &SyncStorage::RunAndDeleteWriteKeyCallback, |
done)); |
} |
-void ChromeStorage::ReadKey(const std::string& key, |
- invalidation::ReadKeyCallback* done) { |
+void SyncStorage::ReadKey(const std::string& key, |
+ invalidation::ReadKeyCallback* done) { |
DCHECK(scheduler_->IsRunningOnThread()) << "not running on scheduler thread"; |
RunAndDeleteReadKeyCallback(done, cached_state_); |
} |
-void ChromeStorage::DeleteKey(const std::string& key, |
- invalidation::DeleteKeyCallback* done) { |
+void SyncStorage::DeleteKey(const std::string& key, |
+ invalidation::DeleteKeyCallback* done) { |
// TODO(ghc): Implement. |
LOG(WARNING) << "ignoring call to DeleteKey(" << key << ", callback)"; |
} |
-void ChromeStorage::ReadAllKeys(invalidation::ReadAllKeysCallback* done) { |
+void SyncStorage::ReadAllKeys(invalidation::ReadAllKeysCallback* done) { |
// TODO(ghc): Implement. |
LOG(WARNING) << "ignoring call to ReadAllKeys(callback)"; |
} |
-void ChromeStorage::SetSystemResources( |
+void SyncStorage::SetSystemResources( |
invalidation::SystemResources* resources) { |
// Do nothing. |
} |
-void ChromeStorage::RunAndDeleteWriteKeyCallback( |
+void SyncStorage::RunAndDeleteWriteKeyCallback( |
invalidation::WriteKeyCallback* callback) { |
callback->Run(invalidation::Status(invalidation::Status::SUCCESS, "")); |
delete callback; |
} |
-void ChromeStorage::RunAndDeleteReadKeyCallback( |
+void SyncStorage::RunAndDeleteReadKeyCallback( |
invalidation::ReadKeyCallback* callback, const std::string& value) { |
callback->Run(std::make_pair( |
invalidation::Status(invalidation::Status::SUCCESS, ""), |
@@ -194,61 +193,61 @@ void ChromeStorage::RunAndDeleteReadKeyCallback( |
delete callback; |
} |
-ChromeSystemResources::ChromeSystemResources( |
+SyncSystemResources::SyncSystemResources( |
scoped_ptr<notifier::PushClient> push_client, |
StateWriter* state_writer) |
: is_started_(false), |
- logger_(new ChromeLogger()), |
- internal_scheduler_(new ChromeScheduler()), |
- listener_scheduler_(new ChromeScheduler()), |
- storage_(new ChromeStorage(state_writer, internal_scheduler_.get())), |
+ logger_(new SyncLogger()), |
+ internal_scheduler_(new SyncInvalidationScheduler()), |
+ listener_scheduler_(new SyncInvalidationScheduler()), |
+ storage_(new SyncStorage(state_writer, internal_scheduler_.get())), |
push_client_channel_(push_client.Pass()) { |
} |
-ChromeSystemResources::~ChromeSystemResources() { |
+SyncSystemResources::~SyncSystemResources() { |
Stop(); |
} |
-void ChromeSystemResources::Start() { |
+void SyncSystemResources::Start() { |
internal_scheduler_->Start(); |
listener_scheduler_->Start(); |
is_started_ = true; |
} |
-void ChromeSystemResources::Stop() { |
+void SyncSystemResources::Stop() { |
internal_scheduler_->Stop(); |
listener_scheduler_->Stop(); |
} |
-bool ChromeSystemResources::IsStarted() const { |
+bool SyncSystemResources::IsStarted() const { |
return is_started_; |
} |
-void ChromeSystemResources::set_platform(const std::string& platform) { |
+void SyncSystemResources::set_platform(const std::string& platform) { |
platform_ = platform; |
} |
-std::string ChromeSystemResources::platform() const { |
+std::string SyncSystemResources::platform() const { |
return platform_; |
} |
-ChromeLogger* ChromeSystemResources::logger() { |
+SyncLogger* SyncSystemResources::logger() { |
return logger_.get(); |
} |
-ChromeStorage* ChromeSystemResources::storage() { |
+SyncStorage* SyncSystemResources::storage() { |
return storage_.get(); |
} |
-PushClientChannel* ChromeSystemResources::network() { |
+PushClientChannel* SyncSystemResources::network() { |
return &push_client_channel_; |
} |
-ChromeScheduler* ChromeSystemResources::internal_scheduler() { |
+SyncInvalidationScheduler* SyncSystemResources::internal_scheduler() { |
return internal_scheduler_.get(); |
} |
-ChromeScheduler* ChromeSystemResources::listener_scheduler() { |
+SyncInvalidationScheduler* SyncSystemResources::listener_scheduler() { |
return listener_scheduler_.get(); |
} |