summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-07 14:25:29 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-07 14:25:29 +0000
commit4ae718e2916c224ba4acb8da9b4bc317ad4b018e (patch)
tree8d182cef38394aab1059b02e6014b4a9bcc45c12 /sync
parent3d0febf895ce3a17c40feea34516134f32890c5b (diff)
downloadchromium_src-4ae718e2916c224ba4acb8da9b4bc317ad4b018e.zip
chromium_src-4ae718e2916c224ba4acb8da9b4bc317ad4b018e.tar.gz
chromium_src-4ae718e2916c224ba4acb8da9b4bc317ad4b018e.tar.bz2
sync: Plumb per-type counter observers to UI
Implements the plumbing to get events from the DirectoryTypeDebugInfoEmitters in the ModelTypeRegistry, through the SyncManager, SyncBackendHostCore, and SyncBackendHost to the ProfileSyncService. At the moment, there are no observers register and no events are emitted. Future patches will include logic to update the counters and to expose their values on the about:sync page. BUG=328606 Review URL: https://codereview.chromium.org/269543020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-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
11 files changed, 134 insertions, 1 deletions
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;