Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: sync/sessions/directory_type_debug_info_emitter.cc

Issue 254473008: sync: Introduce classes for per-type counters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/sessions/directory_type_debug_info_emitter.h ('k') | sync/sessions/model_type_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/sessions/directory_type_debug_info_emitter.cc
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 0000000000000000000000000000000000000000..9f557166ca3b5a7d8a6ebbf81f298c4a0111e696
--- /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
« no previous file with comments | « sync/sessions/directory_type_debug_info_emitter.h ('k') | sync/sessions/model_type_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698