diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 17:34:29 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 17:34:29 +0000 |
commit | 2218af4b23e3622aabb44c3bf880ad57e0232c1b (patch) | |
tree | c6c12bc46c7cdaa5d34c99a90219470b115b0831 /sync/sessions | |
parent | 972c56574fa311333825f725b8361f875bb70aaa (diff) | |
download | chromium_src-2218af4b23e3622aabb44c3bf880ad57e0232c1b.zip chromium_src-2218af4b23e3622aabb44c3bf880ad57e0232c1b.tar.gz chromium_src-2218af4b23e3622aabb44c3bf880ad57e0232c1b.tar.bz2 |
sync: Populate entity counts in about:sync tab
Populates the count of entities per type in about:sync.
Includes C++ code to count and emit the set of deleted and non-deleted
counts, though for space reasons only the non-deleted count is displayed
on the about:sync page.
This calculation is somewhat expensive. It could be made cheaper by
having an index in the Directory to keep track of which entities belong
to which type, but that doesn't exist at the moment. For now, we just
avoid calculating these counts unless the about:sync page is open.
BUG=349301
Review URL: https://codereview.chromium.org/302283007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/sessions')
-rw-r--r-- | sync/sessions/directory_type_debug_info_emitter.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sync/sessions/directory_type_debug_info_emitter.cc b/sync/sessions/directory_type_debug_info_emitter.cc index 031d0eb..c8228d2 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 |