summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h8
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_core.cc44
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_core.h23
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl.cc42
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl.h24
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc9
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_mock.cc4
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_mock.h3
-rw-r--r--chrome/browser/sync/profile_sync_service.cc45
-rw-r--r--chrome/browser/sync/profile_sync_service.h16
-rw-r--r--components/sync_driver/sync_frontend.h27
-rw-r--r--sync/internal_api/public/sync_manager.h15
-rw-r--r--sync/internal_api/public/test/fake_sync_manager.h7
-rw-r--r--sync/internal_api/sync_backup_manager.cc11
-rw-r--r--sync/internal_api/sync_backup_manager.h8
-rw-r--r--sync/internal_api/sync_manager_impl.cc19
-rw-r--r--sync/internal_api/sync_manager_impl.h8
-rw-r--r--sync/internal_api/sync_rollback_manager_base.cc11
-rw-r--r--sync/internal_api/sync_rollback_manager_base.h8
-rw-r--r--sync/internal_api/test/fake_sync_manager.cc13
-rw-r--r--sync/sessions/model_type_registry.cc27
-rw-r--r--sync/sessions/model_type_registry.h8
22 files changed, 378 insertions, 2 deletions
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index e9fb105..96d9176 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -215,6 +215,14 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
base::Callback<void(const std::vector<syncer::ModelType>&,
ScopedVector<base::ListValue>)> type) = 0;
+ // Enables the sending of directory type debug counters. Also, for every
+ // time it is called, it makes an explicit request that updates to an update
+ // for all counters be emitted.
+ virtual void EnableDirectoryTypeDebugInfoForwarding() = 0;
+
+ // Disables the sending of directory type debug counters.
+ virtual void DisableDirectoryTypeDebugInfoForwarding() = 0;
+
virtual base::MessageLoop* GetSyncLoopForTesting() = 0;
DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
diff --git a/chrome/browser/sync/glue/sync_backend_host_core.cc b/chrome/browser/sync/glue/sync_backend_host_core.cc
index b5e2eb3..32b7da2 100644
--- a/chrome/browser/sync/glue/sync_backend_host_core.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_core.cc
@@ -15,7 +15,10 @@
#include "sync/internal_api/public/events/protocol_event.h"
#include "sync/internal_api/public/http_post_provider_factory.h"
#include "sync/internal_api/public/internal_components_factory.h"
+#include "sync/internal_api/public/sessions/commit_counters.h"
+#include "sync/internal_api/public/sessions/status_counters.h"
#include "sync/internal_api/public/sessions/sync_session_snapshot.h"
+#include "sync/internal_api/public/sessions/update_counters.h"
#include "sync/internal_api/public/sync_core_proxy.h"
#include "sync/internal_api/public/sync_manager.h"
#include "sync/internal_api/public/sync_manager_factory.h"
@@ -300,6 +303,33 @@ void SyncBackendHostCore::OnPassphraseTypeChanged(
type, passphrase_time);
}
+void SyncBackendHostCore::OnCommitCountersUpdated(
+ syncer::ModelType type,
+ const syncer::CommitCounters& counters) {
+ host_.Call(
+ FROM_HERE,
+ &SyncBackendHostImpl::HandleDirectoryCommitCountersUpdatedOnFrontendLoop,
+ type, counters);
+}
+
+void SyncBackendHostCore::OnUpdateCountersUpdated(
+ syncer::ModelType type,
+ const syncer::UpdateCounters& counters) {
+ host_.Call(
+ FROM_HERE,
+ &SyncBackendHostImpl::HandleDirectoryUpdateCountersUpdatedOnFrontendLoop,
+ type, counters);
+}
+
+void SyncBackendHostCore::OnStatusCountersUpdated(
+ syncer::ModelType type,
+ const syncer::StatusCounters& counters) {
+ host_.Call(
+ FROM_HERE,
+ &SyncBackendHostImpl::HandleDirectoryStatusCountersUpdatedOnFrontendLoop,
+ type, counters);
+}
+
void SyncBackendHostCore::OnActionableError(
const syncer::SyncProtocolError& sync_error) {
if (!sync_loop_)
@@ -548,6 +578,7 @@ void SyncBackendHostCore::DoDestroySyncManager() {
DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
if (sync_manager_) {
save_changes_timer_.reset();
+ DisableDirectoryTypeDebugInfoForwarding();
sync_manager_->RemoveObserver(this);
sync_manager_->ShutdownOnSyncThread();
sync_manager_.reset();
@@ -636,6 +667,19 @@ void SyncBackendHostCore::DisableProtocolEventForwarding() {
forward_protocol_events_ = false;
}
+void SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding() {
+ DCHECK(sync_manager_);
+ if (!sync_manager_->HasDirectoryTypeDebugInfoObserver(this))
+ sync_manager_->RegisterDirectoryTypeDebugInfoObserver(this);
+ sync_manager_->RequestEmitDebugInfo();
+}
+
+void SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding() {
+ DCHECK(sync_manager_);
+ if (sync_manager_->HasDirectoryTypeDebugInfoObserver(this))
+ sync_manager_->UnregisterDirectoryTypeDebugInfoObserver(this);
+}
+
void SyncBackendHostCore::DeleteSyncDataFolder() {
DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
if (base::DirectoryExists(sync_data_folder_path_)) {
diff --git a/chrome/browser/sync/glue/sync_backend_host_core.h b/chrome/browser/sync/glue/sync_backend_host_core.h
index eb267a6..4ae89c7 100644
--- a/chrome/browser/sync/glue/sync_backend_host_core.h
+++ b/chrome/browser/sync/glue/sync_backend_host_core.h
@@ -11,6 +11,7 @@
#include "chrome/browser/sync/glue/sync_backend_host_impl.h"
#include "components/sync_driver/system_encryptor.h"
#include "sync/internal_api/public/base/cancelation_signal.h"
+#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
#include "sync/internal_api/public/sync_encryption_handler.h"
#include "url/gurl.h"
@@ -79,7 +80,8 @@ struct DoConfigureSyncerTypes {
class SyncBackendHostCore
: public base::RefCountedThreadSafe<SyncBackendHostCore>,
public syncer::SyncEncryptionHandler::Observer,
- public syncer::SyncManager::Observer {
+ public syncer::SyncManager::Observer,
+ public syncer::TypeDebugInfoObserver {
public:
SyncBackendHostCore(const std::string& name,
const base::FilePath& sync_data_folder_path,
@@ -121,6 +123,17 @@ class SyncBackendHostCore
virtual void OnPassphraseTypeChanged(syncer::PassphraseType type,
base::Time passphrase_time) OVERRIDE;
+ // TypeDebugInfoObserver implementation
+ virtual void OnCommitCountersUpdated(
+ syncer::ModelType type,
+ const syncer::CommitCounters& counters) OVERRIDE;
+ virtual void OnUpdateCountersUpdated(
+ syncer::ModelType type,
+ const syncer::UpdateCounters& counters) OVERRIDE;
+ virtual void OnStatusCountersUpdated(
+ syncer::ModelType type,
+ const syncer::StatusCounters& counters) OVERRIDE;
+
// Forwards an invalidation state change to the sync manager.
void DoOnInvalidatorStateChange(syncer::InvalidatorState state);
@@ -212,6 +225,14 @@ class SyncBackendHostCore
void SendBufferedProtocolEventsAndEnableForwarding();
void DisableProtocolEventForwarding();
+ // Enables the forwarding of directory type debug counters to the
+ // SyncBackendHost. Also requests that updates to all counters be
+ // emitted right away to initialize any new listeners' states.
+ void EnableDirectoryTypeDebugInfoForwarding();
+
+ // Disables forwarding of directory type debug counters.
+ void DisableDirectoryTypeDebugInfoForwarding();
+
// Delete the sync data folder to cleanup backend data. Happens the first
// time sync is enabled for a user (to prevent accidentally reusing old
// sync databases), as well as shutdown when you're no longer syncing.
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.cc b/chrome/browser/sync/glue/sync_backend_host_impl.cc
index ac4eacd..cee5863 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_impl.cc
@@ -500,6 +500,24 @@ void SyncBackendHostImpl::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::DisableDirectoryTypeDebugInfoForwarding,
+ core_));
+}
+
void SyncBackendHostImpl::GetAllNodesForTypes(
syncer::ModelTypeSet types,
base::Callback<void(const std::vector<syncer::ModelType>&,
@@ -796,6 +814,30 @@ void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop(
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();
}
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.h b/chrome/browser/sync/glue/sync_backend_host_impl.h
index 9ba56b3..1a156dc 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl.h
+++ b/chrome/browser/sync/glue/sync_backend_host_impl.h
@@ -21,6 +21,7 @@
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/configure_reason.h"
#include "sync/internal_api/public/sessions/sync_session_snapshot.h"
+#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
#include "sync/internal_api/public/sync_manager.h"
#include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
#include "sync/internal_api/public/util/unrecoverable_error_handler.h"
@@ -127,6 +128,8 @@ class SyncBackendHostImpl
virtual SyncedDeviceTracker* GetSyncedDeviceTracker() const OVERRIDE;
virtual void RequestBufferedProtocolEventsAndEnableForwarding() OVERRIDE;
virtual void DisableProtocolEventForwarding() OVERRIDE;
+ virtual void EnableDirectoryTypeDebugInfoForwarding() OVERRIDE;
+ virtual void DisableDirectoryTypeDebugInfoForwarding() OVERRIDE;
virtual void GetAllNodesForTypes(
syncer::ModelTypeSet types,
base::Callback<void(const std::vector<syncer::ModelType>&,
@@ -183,6 +186,27 @@ class SyncBackendHostImpl
// forwarding these events.
void HandleProtocolEventOnFrontendLoop(syncer::ProtocolEvent* event);
+ // Forwards a directory commit counter update to the frontend loop. Will not
+ // be called unless a call to EnableDirectoryTypeDebugInfoForwarding()
+ // explicitly requested that we start forwarding these events.
+ void HandleDirectoryCommitCountersUpdatedOnFrontendLoop(
+ syncer::ModelType type,
+ const syncer::CommitCounters& counters);
+
+ // Forwards a directory update counter update to the frontend loop. Will not
+ // be called unless a call to EnableDirectoryTypeDebugInfoForwarding()
+ // explicitly requested that we start forwarding these events.
+ void HandleDirectoryUpdateCountersUpdatedOnFrontendLoop(
+ syncer::ModelType type,
+ const syncer::UpdateCounters& counters);
+
+ // Forwards a directory status counter update to the frontend loop. Will not
+ // be called unless a call to EnableDirectoryTypeDebugInfoForwarding()
+ // explicitly requested that we start forwarding these events.
+ void HandleDirectoryStatusCountersUpdatedOnFrontendLoop(
+ syncer::ModelType type,
+ const syncer::StatusCounters& counters);
+
SyncFrontend* frontend() { return frontend_; }
private:
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc b/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
index 239c38b..1d2ce7d 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
@@ -32,6 +32,9 @@
#include "sync/internal_api/public/engine/model_safe_worker.h"
#include "sync/internal_api/public/http_bridge_network_resources.h"
#include "sync/internal_api/public/network_resources.h"
+#include "sync/internal_api/public/sessions/commit_counters.h"
+#include "sync/internal_api/public/sessions/status_counters.h"
+#include "sync/internal_api/public/sessions/update_counters.h"
#include "sync/internal_api/public/sync_manager_factory.h"
#include "sync/internal_api/public/test/fake_sync_manager.h"
#include "sync/internal_api/public/util/experiments.h"
@@ -87,6 +90,12 @@ class MockSyncFrontend : public SyncFrontend {
MOCK_METHOD0(OnEncryptionComplete, void());
MOCK_METHOD1(OnMigrationNeededForTypes, void(syncer::ModelTypeSet));
MOCK_METHOD1(OnProtocolEvent, void(const syncer::ProtocolEvent&));
+ MOCK_METHOD2(OnDirectoryTypeCommitCounterUpdated,
+ void(syncer::ModelType, const syncer::CommitCounters&));
+ MOCK_METHOD2(OnDirectoryTypeUpdateCounterUpdated,
+ void(syncer::ModelType, const syncer::UpdateCounters&));
+ MOCK_METHOD2(OnDirectoryTypeStatusCounterUpdated,
+ void(syncer::ModelType, const syncer::StatusCounters&));
MOCK_METHOD1(OnExperimentsChanged,
void(const syncer::Experiments&));
MOCK_METHOD1(OnActionableError,
diff --git a/chrome/browser/sync/glue/sync_backend_host_mock.cc b/chrome/browser/sync/glue/sync_backend_host_mock.cc
index aee76c6..b1257a0 100644
--- a/chrome/browser/sync/glue/sync_backend_host_mock.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_mock.cc
@@ -118,6 +118,10 @@ void SyncBackendHostMock::RequestBufferedProtocolEventsAndEnableForwarding() {}
void SyncBackendHostMock::DisableProtocolEventForwarding() {}
+void SyncBackendHostMock::EnableDirectoryTypeDebugInfoForwarding() {}
+
+void SyncBackendHostMock::DisableDirectoryTypeDebugInfoForwarding() {}
+
void SyncBackendHostMock::GetAllNodesForTypes(
syncer::ModelTypeSet types,
base::Callback<void(const std::vector<syncer::ModelType>& type,
diff --git a/chrome/browser/sync/glue/sync_backend_host_mock.h b/chrome/browser/sync/glue/sync_backend_host_mock.h
index 0b0782d..42cfeae 100644
--- a/chrome/browser/sync/glue/sync_backend_host_mock.h
+++ b/chrome/browser/sync/glue/sync_backend_host_mock.h
@@ -98,6 +98,9 @@ class SyncBackendHostMock : public SyncBackendHost {
virtual void RequestBufferedProtocolEventsAndEnableForwarding() OVERRIDE;
virtual void DisableProtocolEventForwarding() OVERRIDE;
+ virtual void EnableDirectoryTypeDebugInfoForwarding() OVERRIDE;
+ virtual void DisableDirectoryTypeDebugInfoForwarding() OVERRIDE;
+
virtual void GetAllNodesForTypes(
syncer::ModelTypeSet types,
base::Callback<void(const std::vector<syncer::ModelType>& type,
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 7df9aa7..dd3caaf 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -77,6 +77,7 @@
#include "sync/internal_api/public/configure_reason.h"
#include "sync/internal_api/public/http_bridge_network_resources.h"
#include "sync/internal_api/public/network_resources.h"
+#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
#include "sync/internal_api/public/sync_core_proxy.h"
#include "sync/internal_api/public/sync_encryption_handler.h"
#include "sync/internal_api/public/util/experiments.h"
@@ -554,6 +555,30 @@ void ProfileSyncService::OnProtocolEvent(
OnProtocolEvent(event));
}
+void ProfileSyncService::OnDirectoryTypeCommitCounterUpdated(
+ syncer::ModelType type,
+ const syncer::CommitCounters& counters) {
+ FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver,
+ type_debug_info_observers_,
+ OnCommitCountersUpdated(type, counters));
+}
+
+void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated(
+ syncer::ModelType type,
+ const syncer::UpdateCounters& counters) {
+ FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver,
+ type_debug_info_observers_,
+ OnUpdateCountersUpdated(type, counters));
+}
+
+void ProfileSyncService::OnDirectoryTypeStatusCounterUpdated(
+ syncer::ModelType type,
+ const syncer::StatusCounters& counters) {
+ FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver,
+ type_debug_info_observers_,
+ OnStatusCountersUpdated(type, counters));
+}
+
void ProfileSyncService::OnDataTypeRequestsSyncStartup(
syncer::ModelType type) {
DCHECK(syncer::UserTypes().Has(type));
@@ -935,6 +960,10 @@ void ProfileSyncService::OnBackendInitialized(
non_blocking_data_type_manager_.ConnectSyncBackend(
backend_->GetSyncCoreProxy());
+ if (type_debug_info_observers_.might_have_observers()) {
+ backend_->EnableDirectoryTypeDebugInfoForwarding();
+ }
+
// If we have a cached passphrase use it to decrypt/encrypt data now that the
// backend is initialized. We want to call this before notifying observers in
// case this operation affects the "passphrase required" status.
@@ -2106,6 +2135,22 @@ void ProfileSyncService::RemoveProtocolEventObserver(
}
}
+void ProfileSyncService::AddTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* type_debug_info_observer) {
+ type_debug_info_observers_.AddObserver(type_debug_info_observer);
+ if (type_debug_info_observers_.might_have_observers() && backend_) {
+ backend_->EnableDirectoryTypeDebugInfoForwarding();
+ }
+}
+
+void ProfileSyncService::RemoveTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* type_debug_info_observer) {
+ type_debug_info_observers_.RemoveObserver(type_debug_info_observer);
+ if (!type_debug_info_observers_.might_have_observers() && backend_) {
+ backend_->DisableDirectoryTypeDebugInfoForwarding();
+ }
+}
+
namespace {
class GetAllNodesRequestHelper
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 78b510d..bb600b6 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -72,7 +72,10 @@ class SyncSessionSnapshot;
namespace syncer {
class BaseTransaction;
class NetworkResources;
+struct CommitCounters;
+struct StatusCounters;
struct SyncCredentials;
+struct UpdateCounters;
struct UserShare;
} // namespace syncer
@@ -276,6 +279,9 @@ class ProfileSyncService : public ProfileSyncServiceBase,
void RemoveProtocolEventObserver(
browser_sync::ProtocolEventObserver* observer);
+ void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer);
+ void RemoveTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer);
+
// Asynchronously fetches base::Value representations of all sync nodes and
// returns them to the specified callback on this thread.
//
@@ -385,6 +391,15 @@ class ProfileSyncService : public ProfileSyncServiceBase,
bool success) OVERRIDE;
virtual void OnSyncCycleCompleted() OVERRIDE;
virtual void OnProtocolEvent(const syncer::ProtocolEvent& event) OVERRIDE;
+ virtual void OnDirectoryTypeCommitCounterUpdated(
+ syncer::ModelType type,
+ const syncer::CommitCounters& counters) OVERRIDE;
+ virtual void OnDirectoryTypeUpdateCounterUpdated(
+ syncer::ModelType type,
+ const syncer::UpdateCounters& counters) OVERRIDE;
+ virtual void OnDirectoryTypeStatusCounterUpdated(
+ syncer::ModelType type,
+ const syncer::StatusCounters& counters) OVERRIDE;
virtual void OnSyncConfigureRetry() OVERRIDE;
virtual void OnConnectionStatusChange(
syncer::ConnectionStatus status) OVERRIDE;
@@ -950,6 +965,7 @@ class ProfileSyncService : public ProfileSyncServiceBase,
ObserverList<ProfileSyncServiceBase::Observer> observers_;
ObserverList<browser_sync::ProtocolEventObserver> protocol_event_observers_;
+ ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_;
syncer::SyncJsController sync_js_controller_;
diff --git a/components/sync_driver/sync_frontend.h b/components/sync_driver/sync_frontend.h
index 47d76be..0a360a8 100644
--- a/components/sync_driver/sync_frontend.h
+++ b/components/sync_driver/sync_frontend.h
@@ -16,6 +16,9 @@ namespace syncer {
class DataTypeDebugInfoListener;
class JsBackend;
class ProtocolEvent;
+struct CommitCounters;
+struct StatusCounters;
+struct UpdateCounters;
} // namespace syncer
namespace sync_pb {
@@ -62,6 +65,30 @@ class SyncFrontend {
// is listening for it.
virtual void OnProtocolEvent(const syncer::ProtocolEvent& event) = 0;
+ // Called when we receive an updated commit counter for a directory type.
+ //
+ // Disabled by default. Enable by calling
+ // EnableDirectoryTypeDebugInfoForwarding() on the backend.
+ virtual void OnDirectoryTypeCommitCounterUpdated(
+ syncer::ModelType type,
+ const syncer::CommitCounters& counters) = 0;
+
+ // Called when we receive an updated update counter for a directory type.
+ //
+ // Disabled by default. Enable by calling
+ // EnableDirectoryTypeDebugInfoForwarding() on the backend.
+ virtual void OnDirectoryTypeUpdateCounterUpdated(
+ syncer::ModelType type,
+ const syncer::UpdateCounters& counters) = 0;
+
+ // Called when we receive an updated status counter for a directory type.
+ //
+ // Disabled by default. Enable by calling
+ // EnableDirectoryTypeDebugInfoForwarding() on the backend.
+ virtual void OnDirectoryTypeStatusCounterUpdated(
+ syncer::ModelType type,
+ const syncer::StatusCounters& counters) = 0;
+
// The status of the connection to the sync server has changed.
virtual void OnConnectionStatusChange(
syncer::ConnectionStatus status) = 0;
diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h
index 7488586..5b5f337 100644
--- a/sync/internal_api/public/sync_manager.h
+++ b/sync/internal_api/public/sync_manager.h
@@ -45,10 +45,11 @@ class HttpPostProviderFactory;
class InternalComponentsFactory;
class JsBackend;
class JsEventHandler;
+class ProtocolEvent;
class SyncCoreProxy;
class SyncEncryptionHandler;
-class ProtocolEvent;
class SyncScheduler;
+class TypeDebugInfoObserver;
struct Experiments;
struct UserShare;
@@ -361,6 +362,18 @@ class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler {
// Returns any buffered protocol events. Does not clear the buffer.
virtual ScopedVector<syncer::ProtocolEvent> GetBufferedProtocolEvents() = 0;
+
+ // Functions to manage registrations of DebugInfoObservers.
+ virtual void RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) = 0;
+ virtual void UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) = 0;
+ virtual bool HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) = 0;
+
+ // Request that all current counter values be emitted as though they had just
+ // been updated. Useful for initializing new observers' state.
+ virtual void RequestEmitDebugInfo() = 0;
};
} // namespace syncer
diff --git a/sync/internal_api/public/test/fake_sync_manager.h b/sync/internal_api/public/test/fake_sync_manager.h
index 55e4f3b..9b08831 100644
--- a/sync/internal_api/public/test/fake_sync_manager.h
+++ b/sync/internal_api/public/test/fake_sync_manager.h
@@ -130,6 +130,13 @@ class FakeSyncManager : public SyncManager {
virtual scoped_ptr<base::ListValue> GetAllNodesForType(
syncer::ModelType type) OVERRIDE;
virtual void RefreshTypes(ModelTypeSet types) OVERRIDE;
+ virtual void RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual bool HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void RequestEmitDebugInfo() OVERRIDE;
private:
scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
diff --git a/sync/internal_api/sync_backup_manager.cc b/sync/internal_api/sync_backup_manager.cc
index f255ae6..10215be 100644
--- a/sync/internal_api/sync_backup_manager.cc
+++ b/sync/internal_api/sync_backup_manager.cc
@@ -109,4 +109,15 @@ void SyncBackupManager::NormalizeEntries() {
unsynced_.clear();
}
+void SyncBackupManager::RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {}
+
+void SyncBackupManager::UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {}
+
+bool SyncBackupManager::HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) { return false; }
+
+void SyncBackupManager::RequestEmitDebugInfo() {}
+
} // namespace syncer
diff --git a/sync/internal_api/sync_backup_manager.h b/sync/internal_api/sync_backup_manager.h
index 1bee105..e6b9ca4 100644
--- a/sync/internal_api/sync_backup_manager.h
+++ b/sync/internal_api/sync_backup_manager.h
@@ -48,6 +48,14 @@ class SYNC_EXPORT_PRIVATE SyncBackupManager : public SyncRollbackManagerBase {
const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
syncable::BaseTransaction* trans) OVERRIDE;
+ virtual void RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual bool HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void RequestEmitDebugInfo() OVERRIDE;
+
private:
// Replaces local IDs with server IDs and clear unsynced bit of modified
// entries.
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 60bd3da..c2894b4 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -1126,6 +1126,25 @@ ScopedVector<syncer::ProtocolEvent>
return protocol_event_buffer_.GetBufferedProtocolEvents();
}
+void SyncManagerImpl::RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {
+ model_type_registry_->RegisterDirectoryTypeDebugInfoObserver(observer);
+}
+
+void SyncManagerImpl::UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {
+ model_type_registry_->UnregisterDirectoryTypeDebugInfoObserver(observer);
+}
+
+bool SyncManagerImpl::HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {
+ return model_type_registry_->HasDirectoryTypeDebugInfoObserver(observer);
+}
+
+void SyncManagerImpl::RequestEmitDebugInfo() {
+ model_type_registry_->RequestEmitDebugInfo();
+}
+
// static.
int SyncManagerImpl::GetDefaultNudgeDelay() {
return kDefaultNudgeDelayMilliseconds;
diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h
index 653e48a..9402737 100644
--- a/sync/internal_api/sync_manager_impl.h
+++ b/sync/internal_api/sync_manager_impl.h
@@ -35,6 +35,7 @@ namespace syncer {
class ModelTypeRegistry;
class SyncAPIServerConnectionManager;
class SyncCore;
+class TypeDebugInfoObserver;
class WriteNode;
class WriteTransaction;
@@ -121,6 +122,13 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
GetBufferedProtocolEvents() OVERRIDE;
virtual scoped_ptr<base::ListValue> GetAllNodesForType(
syncer::ModelType type) OVERRIDE;
+ virtual void RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual bool HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void RequestEmitDebugInfo() OVERRIDE;
// SyncEncryptionHandler::Observer implementation.
virtual void OnPassphraseRequired(
diff --git a/sync/internal_api/sync_rollback_manager_base.cc b/sync/internal_api/sync_rollback_manager_base.cc
index 98fcd48..7d425cc 100644
--- a/sync/internal_api/sync_rollback_manager_base.cc
+++ b/sync/internal_api/sync_rollback_manager_base.cc
@@ -319,4 +319,15 @@ void SyncRollbackManagerBase::InitBookmarkFolder(const std::string& folder) {
entry.PutSpecifics(specifics);
}
+void SyncRollbackManagerBase::RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {}
+
+void SyncRollbackManagerBase::UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {}
+
+bool SyncRollbackManagerBase::HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) { return false; }
+
+void SyncRollbackManagerBase::RequestEmitDebugInfo() {}
+
} // namespace syncer
diff --git a/sync/internal_api/sync_rollback_manager_base.h b/sync/internal_api/sync_rollback_manager_base.h
index d6ba564..ee8d4a3 100644
--- a/sync/internal_api/sync_rollback_manager_base.h
+++ b/sync/internal_api/sync_rollback_manager_base.h
@@ -113,6 +113,14 @@ class SYNC_EXPORT_PRIVATE SyncRollbackManagerBase :
const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
ModelTypeSet models_with_changes) OVERRIDE;
+ virtual void RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual bool HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+ virtual void RequestEmitDebugInfo() OVERRIDE;
+
private:
void NotifyInitializationSuccess();
void NotifyInitializationFailure();
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index c7873a8..5b0f121 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -253,6 +253,19 @@ void FakeSyncManager::RefreshTypes(ModelTypeSet types) {
last_refresh_request_types_ = types;
}
+void FakeSyncManager::RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {}
+
+void FakeSyncManager::UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {}
+
+bool FakeSyncManager::HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {
+ return false;
+}
+
+void FakeSyncManager::RequestEmitDebugInfo() {}
+
void FakeSyncManager::OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) {
// Do nothing.
diff --git a/sync/sessions/model_type_registry.cc b/sync/sessions/model_type_registry.cc
index 2b9e7cb..668f8da 100644
--- a/sync/sessions/model_type_registry.cc
+++ b/sync/sessions/model_type_registry.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "base/observer_list.h"
#include "sync/engine/directory_commit_contributor.h"
#include "sync/engine/directory_update_handler.h"
#include "sync/engine/non_blocking_type_processor_core.h"
@@ -164,6 +165,32 @@ ModelTypeRegistry::directory_type_debug_info_emitter_map() {
return &directory_type_debug_info_emitter_map_;
}
+void ModelTypeRegistry::RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {
+ if (!type_debug_info_observers_.HasObserver(observer))
+ type_debug_info_observers_.AddObserver(observer);
+}
+
+void ModelTypeRegistry::UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {
+ type_debug_info_observers_.RemoveObserver(observer);
+}
+
+bool ModelTypeRegistry::HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer) {
+ return type_debug_info_observers_.HasObserver(observer);
+}
+
+void ModelTypeRegistry::RequestEmitDebugInfo() {
+ for (DirectoryTypeDebugInfoEmitterMap::iterator it =
+ directory_type_debug_info_emitter_map_.begin();
+ it != directory_type_debug_info_emitter_map_.end(); ++it) {
+ it->second->EmitCommitCountersUpdate();
+ it->second->EmitUpdateCountersUpdate();
+ it->second->EmitStatusCountersUpdate();
+ }
+}
+
ModelTypeSet ModelTypeRegistry::GetEnabledDirectoryTypes() const {
return enabled_directory_types_;
}
diff --git a/sync/sessions/model_type_registry.h b/sync/sessions/model_type_registry.h
index 3ee36c7..20d6d20 100644
--- a/sync/sessions/model_type_registry.h
+++ b/sync/sessions/model_type_registry.h
@@ -73,6 +73,14 @@ class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
CommitContributorMap* commit_contributor_map();
DirectoryTypeDebugInfoEmitterMap* directory_type_debug_info_emitter_map();
+ void RegisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer);
+ void UnregisterDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer);
+ bool HasDirectoryTypeDebugInfoObserver(
+ syncer::TypeDebugInfoObserver* observer);
+ void RequestEmitDebugInfo();
+
private:
ModelTypeSet GetEnabledNonBlockingTypes() const;
ModelTypeSet GetEnabledDirectoryTypes() const;