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

Unified Diff: sync/sessions/directory_type_debug_info_emitter.cc

Issue 302283007: sync: Populate entity counts in about:sync tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/internal_api/public/sessions/status_counters.cc ('k') | no next file » | 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
index 031d0eb756017f2f75288bc7e96aab688100f61e..c8228d23a4e85ff928eb48b3c2aa7c9153b68b1c 100644
--- a/sync/sessions/directory_type_debug_info_emitter.cc
+++ b/sync/sessions/directory_type_debug_info_emitter.cc
@@ -6,6 +6,7 @@
#include "sync/internal_api/public/sessions/status_counters.h"
#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
+#include "sync/syncable/entry.h"
#include "sync/syncable/syncable_read_transaction.h"
namespace syncer {
@@ -61,7 +62,27 @@ void DirectoryTypeDebugInfoEmitter::EmitUpdateCountersUpdate() {
}
void DirectoryTypeDebugInfoEmitter::EmitStatusCountersUpdate() {
- // TODO(rlarocque): Implement this. Part of crbug.com/328606.
+ // This is expensive. Avoid running this code unless about:sync is open.
+ if (!type_debug_info_observers_->might_have_observers())
+ return;
+
+ syncable::ReadTransaction trans(FROM_HERE, directory_);
+ std::vector<int64> result;
+ directory_->GetMetaHandlesOfType(&trans, type_, &result);
+
+ StatusCounters counters;
+ counters.num_entries_and_tombstones = result.size();
+
+ for (std::vector<int64>::const_iterator it = result.begin();
+ it != result.end(); ++it) {
+ syncable::Entry e(&trans, syncable::GET_BY_HANDLE, *it);
+ if (!e.GetIsDel()) {
+ counters.num_entries++;
+ }
+ }
+
+ FOR_EACH_OBSERVER(TypeDebugInfoObserver, (*type_debug_info_observers_),
+ OnStatusCountersUpdated(type_, counters));
}
} // namespace syncer
« no previous file with comments | « sync/internal_api/public/sessions/status_counters.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698