summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 23:16:35 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 23:16:35 +0000
commit46231cd57654ee6ce1eac7e3b738441e0b58fc74 (patch)
treeb7ffa984fc169b45db6121255e085ea825fbec4e /sync
parent94318f6599f1e6df5888a298150b63136a8b1308 (diff)
downloadchromium_src-46231cd57654ee6ce1eac7e3b738441e0b58fc74.zip
chromium_src-46231cd57654ee6ce1eac7e3b738441e0b58fc74.tar.gz
chromium_src-46231cd57654ee6ce1eac7e3b738441e0b58fc74.tar.bz2
sync: Introduce classes for per-type counters
Introduces the classes required to support per-type debug information. This system will eventually replace much of the StatusController and ModelNeutralState. Adds three counter objects. There is one for counters incremented during a GetUpdates, one for counters incremented during a commit, and one for "status" indicators like the total number of sync entities. Adds the DirectoryTypeDebugInfoEmitter, which will manage these counters. There will be one instance of this object per enabled directory-style sync ModelType. It owns the counters that will be updated by the CommitContributors and UpdateHandlers. It also collaborates with the ModelTypeRegistry to allow these CommitContributors and UpdateHandlers to notify observers of updated counter state. Adds the TypeDebugInfoObserver, the interface for classes that listen for counter updates. At the moment, this code won't actually do much. The counters are never incrememnted, no observers register for counter change events, and no such events are generated. Those pieces will be added in future commits. BUG=328606 Review URL: https://codereview.chromium.org/254473008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/engine/directory_type_debug_info_emitter.cc26
-rw-r--r--sync/engine/directory_type_debug_info_emitter.h34
-rw-r--r--sync/internal_api/public/sessions/commit_counters.cc37
-rw-r--r--sync/internal_api/public/sessions/commit_counters.h30
-rw-r--r--sync/internal_api/public/sessions/status_counters.cc31
-rw-r--r--sync/internal_api/public/sessions/status_counters.h27
-rw-r--r--sync/internal_api/public/sessions/type_debug_info_observer.cc14
-rw-r--r--sync/internal_api/public/sessions/type_debug_info_observer.h35
-rw-r--r--sync/internal_api/public/sessions/update_counters.cc53
-rw-r--r--sync/internal_api/public/sessions/update_counters.h37
-rw-r--r--sync/internal_api/sync_manager_impl.cc2
-rw-r--r--sync/sessions/directory_type_debug_info_emitter.cc63
-rw-r--r--sync/sessions/directory_type_debug_info_emitter.h96
-rw-r--r--sync/sessions/model_type_registry.cc7
-rw-r--r--sync/sessions/model_type_registry.h9
-rw-r--r--sync/sync_core.gypi18
-rw-r--r--sync/sync_internal_api.gypi14
17 files changed, 457 insertions, 76 deletions
diff --git a/sync/engine/directory_type_debug_info_emitter.cc b/sync/engine/directory_type_debug_info_emitter.cc
deleted file mode 100644
index 6788786..0000000
--- a/sync/engine/directory_type_debug_info_emitter.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/engine/directory_type_debug_info_emitter.h"
-
-#include "sync/syncable/syncable_read_transaction.h"
-
-namespace syncer {
-
-DirectoryTypeDebugInfoEmitter::DirectoryTypeDebugInfoEmitter(
- syncable::Directory* directory,
- syncer::ModelType type)
- : directory_(directory),
- type_(type) {}
-
-DirectoryTypeDebugInfoEmitter::~DirectoryTypeDebugInfoEmitter() {}
-
-scoped_ptr<base::ListValue> DirectoryTypeDebugInfoEmitter::GetAllNodes() {
- syncable::ReadTransaction trans(FROM_HERE, directory_);
- scoped_ptr<base::ListValue> nodes(
- directory_->GetNodeDetailsForType(&trans, type_));
- return nodes.Pass();
-}
-
-} // namespace syncer
diff --git a/sync/engine/directory_type_debug_info_emitter.h b/sync/engine/directory_type_debug_info_emitter.h
deleted file mode 100644
index d2247dd..0000000
--- a/sync/engine/directory_type_debug_info_emitter.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_ENGINE_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
-#define SYNC_ENGINE_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
-
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/values.h"
-#include "sync/syncable/directory.h"
-
-namespace syncer {
-
-// Supports debugging requests for a certain directory type.
-class DirectoryTypeDebugInfoEmitter {
- public:
- DirectoryTypeDebugInfoEmitter(syncable::Directory* directory,
- syncer::ModelType type);
- virtual ~DirectoryTypeDebugInfoEmitter();
-
- // Returns a ListValue representation of all known nodes of this type.
- scoped_ptr<base::ListValue> GetAllNodes();
-
- private:
- syncable::Directory* directory_;
- ModelType type_;
-
- DISALLOW_COPY_AND_ASSIGN(DirectoryTypeDebugInfoEmitter);
-};
-
-} // namespace syncer
-
-#endif // SYNC_ENGINE_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
diff --git a/sync/internal_api/public/sessions/commit_counters.cc b/sync/internal_api/public/sessions/commit_counters.cc
new file mode 100644
index 0000000..6038ad2
--- /dev/null
+++ b/sync/internal_api/public/sessions/commit_counters.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/sessions/commit_counters.h"
+
+#include "base/json/json_string_value_serializer.h"
+#include "base/values.h"
+
+namespace syncer {
+
+CommitCounters::CommitCounters()
+ : num_commits_attempted(0),
+ num_commits_success(0),
+ num_commits_conflict(0),
+ num_commits_error(0) {}
+
+CommitCounters::~CommitCounters() {}
+
+scoped_ptr<base::DictionaryValue> CommitCounters::ToValue() const {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ value->SetInteger("numCommitsAttempted", num_commits_attempted);
+ value->SetInteger("numCommitsSuccess", num_commits_success);
+ value->SetInteger("numCommitsConflict", num_commits_conflict);
+ value->SetInteger("numCommitsError", num_commits_error);
+ return value.Pass();
+}
+
+std::string CommitCounters::ToString() const {
+ std::string result;
+ scoped_ptr<base::DictionaryValue> value = ToValue();
+ JSONStringValueSerializer serializer(&result);
+ serializer.Serialize(*value);
+ return result;
+}
+
+} // namespace syncer
diff --git a/sync/internal_api/public/sessions/commit_counters.h b/sync/internal_api/public/sessions/commit_counters.h
new file mode 100644
index 0000000..a069eb1
--- /dev/null
+++ b/sync/internal_api/public/sessions/commit_counters.h
@@ -0,0 +1,30 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_PUBLIC_SESSIONS_COMMIT_COUNTERS_H_
+#define SYNC_INTERNAL_API_PUBLIC_SESSIONS_COMMIT_COUNTERS_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "sync/base/sync_export.h"
+
+namespace syncer {
+
+// A class to maintain counts related to sync commit requests and responses.
+struct SYNC_EXPORT_PRIVATE CommitCounters {
+ CommitCounters();
+ ~CommitCounters();
+
+ scoped_ptr<base::DictionaryValue> ToValue() const;
+ std::string ToString() const;
+
+ int num_commits_attempted;
+ int num_commits_success;
+ int num_commits_conflict;
+ int num_commits_error;
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_COMMIT_COUNTERS_H_
diff --git a/sync/internal_api/public/sessions/status_counters.cc b/sync/internal_api/public/sessions/status_counters.cc
new file mode 100644
index 0000000..b3547d1
--- /dev/null
+++ b/sync/internal_api/public/sessions/status_counters.cc
@@ -0,0 +1,31 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/sessions/status_counters.h"
+
+#include "base/json/json_string_value_serializer.h"
+#include "base/values.h"
+
+namespace syncer {
+
+StatusCounters::StatusCounters()
+ : num_total_entries(0) {}
+
+StatusCounters::~StatusCounters() {}
+
+scoped_ptr<base::DictionaryValue> StatusCounters::ToValue() const {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ value->SetInteger("numTotalEntries", num_total_entries);
+ return value.Pass();
+}
+
+std::string StatusCounters::ToString() const {
+ std::string result;
+ scoped_ptr<base::DictionaryValue> value = ToValue();
+ JSONStringValueSerializer serializer(&result);
+ serializer.Serialize(*value);
+ return result;
+}
+
+} // namespace syncer
diff --git a/sync/internal_api/public/sessions/status_counters.h b/sync/internal_api/public/sessions/status_counters.h
new file mode 100644
index 0000000..bab8d8a
--- /dev/null
+++ b/sync/internal_api/public/sessions/status_counters.h
@@ -0,0 +1,27 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_PUBLIC_SESSIONS_STATUS_COUNTERS_H_
+#define SYNC_INTERNAL_API_PUBLIC_SESSIONS_STATUS_COUNTERS_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "sync/base/sync_export.h"
+
+namespace syncer {
+
+// A class to maintain counts related to the current status of a sync type.
+struct SYNC_EXPORT_PRIVATE StatusCounters {
+ StatusCounters();
+ ~StatusCounters();
+
+ scoped_ptr<base::DictionaryValue> ToValue() const;
+ std::string ToString() const;
+
+ size_t num_total_entries;
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_STATUS_COUNTERS_H_
diff --git a/sync/internal_api/public/sessions/type_debug_info_observer.cc b/sync/internal_api/public/sessions/type_debug_info_observer.cc
new file mode 100644
index 0000000..3255013
--- /dev/null
+++ b/sync/internal_api/public/sessions/type_debug_info_observer.cc
@@ -0,0 +1,14 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
+
+namespace syncer {
+
+TypeDebugInfoObserver::TypeDebugInfoObserver() {}
+
+TypeDebugInfoObserver::~TypeDebugInfoObserver() {}
+
+
+} // namespace syncer
diff --git a/sync/internal_api/public/sessions/type_debug_info_observer.h b/sync/internal_api/public/sessions/type_debug_info_observer.h
new file mode 100644
index 0000000..dc211c2
--- /dev/null
+++ b/sync/internal_api/public/sessions/type_debug_info_observer.h
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_PUBLIC_SESSIONS_TYPE_DEBUG_INFO_OBSERVER_H_
+#define SYNC_INTERNAL_API_PUBLIC_SESSIONS_TYPE_DEBUG_INFO_OBSERVER_H_
+
+#include "sync/internal_api/public/base/model_type.h"
+
+namespace syncer {
+
+struct CommitCounters;
+struct StatusCounters;
+struct UpdateCounters;
+
+// Interface for classes that observe per-type sync debug counters.
+class SYNC_EXPORT TypeDebugInfoObserver {
+ public:
+ TypeDebugInfoObserver();
+ virtual ~TypeDebugInfoObserver();
+
+ virtual void OnCommitCountersUpdated(
+ syncer::ModelType type,
+ const CommitCounters& counters) = 0;
+ virtual void OnUpdateCountersUpdated(
+ syncer::ModelType type,
+ const UpdateCounters& counters) = 0;
+ virtual void OnStatusCountersUpdated(
+ syncer::ModelType type,
+ const StatusCounters& counters) = 0;
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_TYPE_DEBUG_INFO_OBSERVER_H_
diff --git a/sync/internal_api/public/sessions/update_counters.cc b/sync/internal_api/public/sessions/update_counters.cc
new file mode 100644
index 0000000..0656baf
--- /dev/null
+++ b/sync/internal_api/public/sessions/update_counters.cc
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/sessions/update_counters.h"
+
+#include "base/json/json_string_value_serializer.h"
+#include "base/values.h"
+
+namespace syncer {
+
+UpdateCounters::UpdateCounters()
+ : num_updates_received(0),
+ num_reflected_updates_received(0),
+ num_tombstone_updates_received(0),
+ num_updates_applied(0),
+ num_hierarchy_conflict_application_failures(0),
+ num_encryption_conflict_application_failures(0),
+ num_server_overwrites(0),
+ num_local_overwrites(0) {}
+
+UpdateCounters::~UpdateCounters() {}
+
+scoped_ptr<base::DictionaryValue> UpdateCounters::ToValue() const {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+
+ value->SetInteger("numUpdatesReceived", num_updates_received);
+ value->SetInteger("numReflectedUpdatesReceived",
+ num_reflected_updates_received);
+ value->SetInteger("numTombstoneUpdatesReceived",
+ num_tombstone_updates_received);
+
+ value->SetInteger("numUpdatesApplied", num_updates_applied);
+ value->SetInteger("numHierarchyConflictApplicationFailures",
+ num_hierarchy_conflict_application_failures);
+ value->SetInteger("numEncryptionConflictApplicationFailures",
+ num_encryption_conflict_application_failures);
+
+ value->SetInteger("numServerOverwrites", num_server_overwrites);
+ value->SetInteger("numLocalOverwrites", num_local_overwrites);
+
+ return value.Pass();
+}
+
+std::string UpdateCounters::ToString() const {
+ std::string result;
+ scoped_ptr<base::DictionaryValue> value = ToValue();
+ JSONStringValueSerializer serializer(&result);
+ serializer.Serialize(*value);
+ return result;
+}
+
+} // namespace syncer
diff --git a/sync/internal_api/public/sessions/update_counters.h b/sync/internal_api/public/sessions/update_counters.h
new file mode 100644
index 0000000..506d341
--- /dev/null
+++ b/sync/internal_api/public/sessions/update_counters.h
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_PUBLIC_SESSIONS_UPDATE_COUNTERS_H_
+#define SYNC_INTERNAL_API_PUBLIC_SESSIONS_UPDATE_COUNTERS_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "sync/base/sync_export.h"
+
+namespace syncer {
+
+// A class to maintain counts related to the update requests and responses for
+// a particular sync type.
+struct SYNC_EXPORT_PRIVATE UpdateCounters {
+ UpdateCounters();
+ ~UpdateCounters();
+
+ scoped_ptr<base::DictionaryValue> ToValue() const;
+ std::string ToString() const;
+
+ int num_updates_received;
+ int num_reflected_updates_received;
+ int num_tombstone_updates_received;
+
+ int num_updates_applied;
+ int num_hierarchy_conflict_application_failures;
+ int num_encryption_conflict_application_failures;
+
+ int num_server_overwrites;
+ int num_local_overwrites;
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_UPDATE_COUNTERS_H_
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index a742690..60bd3da 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -16,7 +16,6 @@
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
-#include "sync/engine/directory_type_debug_info_emitter.h"
#include "sync/engine/sync_scheduler.h"
#include "sync/engine/syncer_types.h"
#include "sync/internal_api/change_reorder_buffer.h"
@@ -43,6 +42,7 @@
#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/protocol/proto_value_conversions.h"
#include "sync/protocol/sync.pb.h"
+#include "sync/sessions/directory_type_debug_info_emitter.h"
#include "sync/syncable/directory.h"
#include "sync/syncable/entry.h"
#include "sync/syncable/in_memory_directory_backing_store.h"
diff --git a/sync/sessions/directory_type_debug_info_emitter.cc b/sync/sessions/directory_type_debug_info_emitter.cc
new file mode 100644
index 0000000..9f55716
--- /dev/null
+++ b/sync/sessions/directory_type_debug_info_emitter.cc
@@ -0,0 +1,63 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/sessions/directory_type_debug_info_emitter.h"
+
+#include "sync/internal_api/public/sessions/status_counters.h"
+#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
+#include "sync/syncable/syncable_read_transaction.h"
+
+namespace syncer {
+
+DirectoryTypeDebugInfoEmitter::DirectoryTypeDebugInfoEmitter(
+ syncable::Directory* directory,
+ syncer::ModelType type,
+ ObserverList<TypeDebugInfoObserver>* observers)
+ : directory_(directory),
+ type_(type),
+ type_debug_info_observers_(observers) {}
+
+DirectoryTypeDebugInfoEmitter::DirectoryTypeDebugInfoEmitter()
+ : type_(UNSPECIFIED) {}
+
+DirectoryTypeDebugInfoEmitter::~DirectoryTypeDebugInfoEmitter() {}
+
+scoped_ptr<base::ListValue> DirectoryTypeDebugInfoEmitter::GetAllNodes() {
+ syncable::ReadTransaction trans(FROM_HERE, directory_);
+ scoped_ptr<base::ListValue> nodes(
+ directory_->GetNodeDetailsForType(&trans, type_));
+ return nodes.Pass();
+}
+
+const CommitCounters& DirectoryTypeDebugInfoEmitter::GetCommitCounters() const {
+ return commit_counters_;
+}
+
+CommitCounters* DirectoryTypeDebugInfoEmitter::GetMutableCommitCounters() {
+ return &commit_counters_;
+}
+
+void DirectoryTypeDebugInfoEmitter::EmitCommitCountersUpdate() {
+ FOR_EACH_OBSERVER(TypeDebugInfoObserver, (*type_debug_info_observers_),
+ OnCommitCountersUpdated(type_, commit_counters_));
+}
+
+const UpdateCounters& DirectoryTypeDebugInfoEmitter::GetUpdateCounters() const {
+ return update_counters_;
+}
+
+UpdateCounters* DirectoryTypeDebugInfoEmitter::GetMutableUpdateCounters() {
+ return &update_counters_;
+}
+
+void DirectoryTypeDebugInfoEmitter::EmitUpdateCountersUpdate() {
+ FOR_EACH_OBSERVER(TypeDebugInfoObserver, (*type_debug_info_observers_),
+ OnUpdateCountersUpdated(type_, update_counters_));
+}
+
+void DirectoryTypeDebugInfoEmitter::EmitStatusCountersUpdate() {
+ // TODO(rlarocque): Implement this. Part of crbug.com/328606.
+}
+
+} // namespace syncer
diff --git a/sync/sessions/directory_type_debug_info_emitter.h b/sync/sessions/directory_type_debug_info_emitter.h
new file mode 100644
index 0000000..0ba37d3
--- /dev/null
+++ b/sync/sessions/directory_type_debug_info_emitter.h
@@ -0,0 +1,96 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_SESSIONS_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
+#define SYNC_SESSIONS_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "base/values.h"
+#include "sync/base/sync_export.h"
+#include "sync/internal_api/public/sessions/commit_counters.h"
+#include "sync/internal_api/public/sessions/update_counters.h"
+#include "sync/syncable/directory.h"
+
+namespace syncer {
+
+class DirectoryCommitContributor;
+class TypeDebugInfoObserver;
+
+// Supports various kinds of debugging requests for a certain directory type.
+//
+// The GetAllNodes() function is used to help export a snapshot of all current
+// nodes to its caller. The complexity required to manage the request mostly
+// lives elsewhere.
+//
+// The Emit*() functions send updates to registered TypeDebugInfoObservers.
+// The DirectoryTypeDebugInfoEmitter does not directly own that list; it is
+// managed by the ModelTypeRegistry.
+//
+// For Update and Commit counters, the job of keeping the counters up to date
+// is delegated to the UpdateHandler and CommitContributors. For the Stats
+// counters, the emitter will use its type_ and directory_ members to fetch all
+// the required information on demand.
+class SYNC_EXPORT_PRIVATE DirectoryTypeDebugInfoEmitter {
+ public:
+ // Standard constructor for non-tests.
+ //
+ // The |directory| and |observers| arguments are not owned. Both may be
+ // modified outside of this object and both are expected to outlive this
+ // object.
+ DirectoryTypeDebugInfoEmitter(
+ syncable::Directory* directory,
+ syncer::ModelType type,
+ ObserverList<TypeDebugInfoObserver>* observers);
+
+ // A simple constructor for tests. Should not be used in real code.
+ DirectoryTypeDebugInfoEmitter();
+
+ virtual ~DirectoryTypeDebugInfoEmitter();
+
+ // Returns a ListValue representation of all known nodes of this type.
+ scoped_ptr<base::ListValue> GetAllNodes();
+
+ // Returns a reference to the current commit counters.
+ const CommitCounters& GetCommitCounters() const;
+
+ // Allows others to mutate the commit counters.
+ CommitCounters* GetMutableCommitCounters();
+
+ // Triggerss a commit counters update to registered observers.
+ void EmitCommitCountersUpdate();
+
+ // Returns a reference to the current update counters.
+ const UpdateCounters& GetUpdateCounters() const;
+
+ // Allows others to mutate the update counters.
+ UpdateCounters* GetMutableUpdateCounters();
+
+ // Triggers an update counters update to registered observers.
+ void EmitUpdateCountersUpdate();
+
+ // Triggers a status counters update to registered observers.
+ void EmitStatusCountersUpdate();
+
+ private:
+ syncable::Directory* directory_;
+
+ const ModelType type_;
+
+ CommitCounters commit_counters_;
+ UpdateCounters update_counters_;
+
+ // Because there are so many emitters that come into and out of existence, it
+ // doesn't make sense to have them manage their own observer list. They all
+ // share one observer list that is provided by their owner and which is
+ // guaranteed to outlive them.
+ ObserverList<TypeDebugInfoObserver>* type_debug_info_observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(DirectoryTypeDebugInfoEmitter);
+};
+
+} // namespace syncer
+
+#endif // SYNC_SESSIONS_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
diff --git a/sync/sessions/model_type_registry.cc b/sync/sessions/model_type_registry.cc
index fcf3996..a41a7f3 100644
--- a/sync/sessions/model_type_registry.cc
+++ b/sync/sessions/model_type_registry.cc
@@ -7,10 +7,10 @@
#include "base/bind.h"
#include "base/message_loop/message_loop_proxy.h"
#include "sync/engine/directory_commit_contributor.h"
-#include "sync/engine/directory_type_debug_info_emitter.h"
#include "sync/engine/directory_update_handler.h"
#include "sync/engine/non_blocking_type_processor_core.h"
#include "sync/internal_api/public/non_blocking_type_processor.h"
+#include "sync/sessions/directory_type_debug_info_emitter.h"
namespace syncer {
@@ -57,12 +57,13 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
DCHECK(worker_it != workers_map_.end());
scoped_refptr<ModelSafeWorker> worker = worker_it->second;
+ DirectoryTypeDebugInfoEmitter* emitter =
+ new DirectoryTypeDebugInfoEmitter(directory_, type,
+ &type_debug_info_observers_);
DirectoryCommitContributor* committer =
new DirectoryCommitContributor(directory_, type);
DirectoryUpdateHandler* updater =
new DirectoryUpdateHandler(directory_, type, worker);
- DirectoryTypeDebugInfoEmitter* emitter =
- new DirectoryTypeDebugInfoEmitter(directory_, type);
// These containers take ownership of their contents.
directory_commit_contributors_.push_back(committer);
diff --git a/sync/sessions/model_type_registry.h b/sync/sessions/model_type_registry.h
index 71d304f..3ee36c7 100644
--- a/sync/sessions/model_type_registry.h
+++ b/sync/sessions/model_type_registry.h
@@ -13,6 +13,7 @@
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/engine/model_safe_worker.h"
+#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
namespace syncer {
@@ -103,6 +104,14 @@ class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
// The set of enabled directory types.
ModelTypeSet enabled_directory_types_;
+ // The set of observers of per-type debug info.
+ //
+ // Each of the DirectoryTypeDebugInfoEmitters needs such a list. There's
+ // a lot of them, and their lifetimes are unpredictable, so it makes the
+ // book-keeping easier if we just store the list here. That way it's
+ // guaranteed to live as long as this sync backend.
+ ObserverList<TypeDebugInfoObserver> type_debug_info_observers_;
+
DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry);
};
diff --git a/sync/sync_core.gypi b/sync/sync_core.gypi
index e7019a0..5efe9ae 100644
--- a/sync/sync_core.gypi
+++ b/sync/sync_core.gypi
@@ -35,11 +35,11 @@
'engine/backoff_delay_provider.cc',
'engine/backoff_delay_provider.h',
'engine/commit.cc',
+ 'engine/commit.h',
'engine/commit_contribution.cc',
'engine/commit_contribution.h',
'engine/commit_contributor.cc',
'engine/commit_contributor.h',
- 'engine/commit.h',
'engine/commit_processor.cc',
'engine/commit_processor.h',
'engine/commit_util.cc',
@@ -54,8 +54,6 @@
'engine/directory_commit_contributor.h',
'engine/directory_update_handler.cc',
'engine/directory_update_handler.h',
- 'engine/directory_type_debug_info_emitter.cc',
- 'engine/directory_type_debug_info_emitter.h',
'engine/get_commit_ids.cc',
'engine/get_commit_ids.h',
'engine/get_updates_delegate.cc',
@@ -76,6 +74,10 @@
'engine/sync_cycle_event.h',
'engine/sync_engine_event_listener.cc',
'engine/sync_engine_event_listener.h',
+ 'engine/sync_scheduler.cc',
+ 'engine/sync_scheduler.h',
+ 'engine/sync_scheduler_impl.cc',
+ 'engine/sync_scheduler_impl.h',
'engine/syncer.cc',
'engine/syncer.h',
'engine/syncer_proto_util.cc',
@@ -83,10 +85,6 @@
'engine/syncer_types.h',
'engine/syncer_util.cc',
'engine/syncer_util.h',
- 'engine/sync_scheduler.cc',
- 'engine/sync_scheduler.h',
- 'engine/sync_scheduler_impl.cc',
- 'engine/sync_scheduler_impl.h',
'engine/traffic_logger.cc',
'engine/traffic_logger.h',
'engine/update_applicator.cc',
@@ -109,6 +107,8 @@
'sessions/data_type_tracker.cc',
'sessions/data_type_tracker.h',
'sessions/debug_info_getter.h',
+ 'sessions/directory_type_debug_info_emitter.cc',
+ 'sessions/directory_type_debug_info_emitter.h',
'sessions/model_type_registry.cc',
'sessions/model_type_registry.h',
'sessions/nudge_tracker.cc',
@@ -186,12 +186,12 @@
'util/extensions_activity.h',
'util/get_session_name.cc',
'util/get_session_name.h',
- 'util/get_session_name_ios.mm',
'util/get_session_name_ios.h',
+ 'util/get_session_name_ios.mm',
'util/get_session_name_linux.cc',
'util/get_session_name_linux.h',
- 'util/get_session_name_mac.mm',
'util/get_session_name_mac.h',
+ 'util/get_session_name_mac.mm',
'util/get_session_name_win.cc',
'util/get_session_name_win.h',
'util/logging.cc',
diff --git a/sync/sync_internal_api.gypi b/sync/sync_internal_api.gypi
index 2e677fe..2a0c274 100644
--- a/sync/sync_internal_api.gypi
+++ b/sync/sync_internal_api.gypi
@@ -95,10 +95,18 @@
'internal_api/public/non_blocking_type_processor.h',
'internal_api/public/read_node.h',
'internal_api/public/read_transaction.h',
+ 'internal_api/public/sessions/commit_counters.cc',
+ 'internal_api/public/sessions/commit_counters.h',
'internal_api/public/sessions/model_neutral_state.cc',
'internal_api/public/sessions/model_neutral_state.h',
+ 'internal_api/public/sessions/status_counters.cc',
+ 'internal_api/public/sessions/status_counters.h',
'internal_api/public/sessions/sync_session_snapshot.cc',
'internal_api/public/sessions/sync_session_snapshot.h',
+ 'internal_api/public/sessions/type_debug_info_observer.cc',
+ 'internal_api/public/sessions/type_debug_info_observer.h',
+ 'internal_api/public/sessions/update_counters.cc',
+ 'internal_api/public/sessions/update_counters.h',
'internal_api/public/sync_core_proxy.h',
'internal_api/public/sync_encryption_handler.cc',
'internal_api/public/sync_encryption_handler.h',
@@ -134,10 +142,10 @@
'internal_api/sync_manager_factory.cc',
'internal_api/sync_manager_impl.cc',
'internal_api/sync_manager_impl.h',
- 'internal_api/sync_rollback_manager_base.cc',
- 'internal_api/sync_rollback_manager_base.h',
'internal_api/sync_rollback_manager.cc',
- 'internal_api/sync_rollback_manager.h',
+ 'internal_api/sync_rollback_manager.h',
+ 'internal_api/sync_rollback_manager_base.cc',
+ 'internal_api/sync_rollback_manager_base.h',
'internal_api/syncapi_internal.cc',
'internal_api/syncapi_internal.h',
'internal_api/syncapi_server_connection_manager.cc',