#include "chrome/browser/sync/glue/sync_backend_host_impl.h"
#include "base/command_line.h"
+#include "base/logging.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/invalidation/invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/network_time/network_time_tracker.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/sync_backend_host_core.h"
#include "chrome/browser/sync/glue/sync_backend_registrar.h"
#include "chrome/common/chrome_switches.h"
+#include "components/invalidation/invalidation_service.h"
#include "components/sync_driver/sync_frontend.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/browser/browser_thread.h"
invalidation::InvalidationServiceFactory::GetForProfile(profile)),
invalidation_handler_registered_(false),
weak_ptr_factory_(this) {
+ CHECK(invalidator_);
core_ = new SyncBackendHostCore(
name_,
profile_->GetPath().Append(kSyncDataFolderName),
// Stop listening for and forwarding locally-triggered sync refresh requests.
notification_registrar_.RemoveAll();
+ // Stop non-blocking sync types from sending any more requests to the syncer.
+ sync_core_proxy_.reset();
+
DCHECK(registrar_->sync_thread()->IsRunning());
registrar_->RequestWorkerStopOnUIThread();
return core_->sync_manager()->GetUserShare();
}
+scoped_ptr<syncer::SyncCoreProxy> SyncBackendHostImpl::GetSyncCoreProxy() {
+ return scoped_ptr<syncer::SyncCoreProxy>(sync_core_proxy_->Clone());
+}
+
SyncBackendHostImpl::Status SyncBackendHostImpl::GetDetailedStatus() {
DCHECK(initialized());
return core_->sync_manager()->GetDetailedStatus();
return core_->synced_device_tracker();
}
-void SyncBackendHostImpl::SetForwardProtocolEvents(bool forward) {
+void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
+ registrar_->sync_thread()->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding,
+ core_));
+}
+
+void SyncBackendHostImpl::DisableProtocolEventForwarding() {
+ registrar_->sync_thread()->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &SyncBackendHostCore::DisableProtocolEventForwarding,
+ core_));
+}
+
+void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() {
+ DCHECK(initialized());
+ registrar_->sync_thread()->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding,
+ core_));
+}
+
+void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() {
DCHECK(initialized());
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
- base::Bind(&SyncBackendHostCore::SetForwardProtocolEvents,
- core_, forward));
+ base::Bind(
+ &SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding,
+ core_));
+}
+
+void SyncBackendHostImpl::GetAllNodesForTypes(
+ syncer::ModelTypeSet types,
+ base::Callback<void(const std::vector<syncer::ModelType>&,
+ ScopedVector<base::ListValue>)> callback) {
+ DCHECK(initialized());
+ registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
+ base::Bind(
+ &SyncBackendHostCore::GetAllNodesForTypes,
+ core_,
+ types,
+ frontend_loop_->message_loop_proxy(),
+ callback));
}
void SyncBackendHostImpl::InitCore(scoped_ptr<DoInitializeOptions> options) {
void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop(
const syncer::WeakHandle<syncer::JsBackend> js_backend,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>
- debug_info_listener) {
+ debug_info_listener,
+ syncer::SyncCoreProxy* sync_core_proxy) {
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
+
+ sync_core_proxy_ = sync_core_proxy->Clone();
+
if (!frontend_)
return;
frontend_->OnProtocolEvent(*scoped_event);
}
+void SyncBackendHostImpl::HandleDirectoryCommitCountersUpdatedOnFrontendLoop(
+ syncer::ModelType type,
+ const syncer::CommitCounters& counters) {
+ if (!frontend_)
+ return;
+ frontend_->OnDirectoryTypeCommitCounterUpdated(type, counters);
+}
+
+void SyncBackendHostImpl::HandleDirectoryUpdateCountersUpdatedOnFrontendLoop(
+ syncer::ModelType type,
+ const syncer::UpdateCounters& counters) {
+ if (!frontend_)
+ return;
+ frontend_->OnDirectoryTypeUpdateCounterUpdated(type, counters);
+}
+
+void SyncBackendHostImpl::HandleDirectoryStatusCountersUpdatedOnFrontendLoop(
+ syncer::ModelType type,
+ const syncer::StatusCounters& counters) {
+ if (!frontend_)
+ return;
+ frontend_->OnDirectoryTypeStatusCounterUpdated(type, counters);
+}
+
base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() {
return registrar_->sync_thread()->message_loop();
}