diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 03:03:43 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 03:03:43 +0000 |
commit | 6f5366ac2dba6f208b5c2546b4f2c1a93bd4fbb1 (patch) | |
tree | 1985f6c9956989d5273e1c59a423723d4e37ca6c /chrome/browser/sync/engine/syncer.cc | |
parent | ed45566a74d2a8dae55ab4e2589ce5f0d78e49b2 (diff) | |
download | chromium_src-6f5366ac2dba6f208b5c2546b4f2c1a93bd4fbb1.zip chromium_src-6f5366ac2dba6f208b5c2546b4f2c1a93bd4fbb1.tar.gz chromium_src-6f5366ac2dba6f208b5c2546b4f2c1a93bd4fbb1.tar.bz2 |
Take 2 at browser_sync::ExtensionsActivityMonitor.
Original: http://codereview.chromium.org/325001/show
TEST=ExtensionsActivityMonitorTest
Review URL: http://codereview.chromium.org/333041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30313 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/engine/syncer.cc')
-rw-r--r-- | chrome/browser/sync/engine/syncer.cc | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/chrome/browser/sync/engine/syncer.cc b/chrome/browser/sync/engine/syncer.cc index de8b1b2..ee56bb9 100644 --- a/chrome/browser/sync/engine/syncer.cc +++ b/chrome/browser/sync/engine/syncer.cc @@ -5,6 +5,8 @@ #include "chrome/browser/sync/engine/syncer.h" #include "base/format_macros.h" +#include "base/message_loop.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/sync/engine/apply_updates_command.h" #include "chrome/browser/sync/engine/build_and_process_conflict_sets_command.h" #include "chrome/browser/sync/engine/build_commit_command.h" @@ -66,12 +68,21 @@ Syncer::Syncer( syncer_event_channel_.reset(new SyncerEventChannel(shutdown)); shutdown_channel_.reset(new ShutdownChannel(this)); + extensions_monitor_ = new ExtensionsActivityMonitor(); + ScopedDirLookup dir(dirman_, account_name_); // The directory must be good here. CHECK(dir.good()); } -Syncer::~Syncer() {} +Syncer::~Syncer() { + if (!ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE, + extensions_monitor_)) { + // In unittests, there may be no UI thread, so the above will fail. + delete extensions_monitor_; + } + extensions_monitor_ = NULL; +} void Syncer::RequestNudge(int milliseconds) { SyncerEvent event; @@ -92,6 +103,17 @@ bool Syncer::SyncShare(SyncProcessState* process_state) { SyncerSession session(&cycle_state, process_state); session.set_source(TestAndSetUpdatesSource()); session.set_notifications_enabled(notifications_enabled()); + // This isn't perfect, as we can end up bundling extensions activity + // intended for the next session into the current one. We could do a + // test-and-reset as with the source, but note that also falls short if + // the commit request fails (due to lost connection, for example), as we will + // fall all the way back to the syncer thread main loop in that case, and + // wind up creating a new session when a connection is established, losing + // the records set here on the original attempt. This should provide us + // with the right data "most of the time", and we're only using this for + // analysis purposes, so Law of Large Numbers FTW. + extensions_monitor_->GetAndClearRecords( + session.mutable_extensions_activity()); SyncShare(&session, SYNCER_BEGIN, SYNCER_END); return session.HasMoreToSync(); } @@ -205,7 +227,8 @@ void Syncer::SyncShare(SyncerSession* session, } case PROCESS_COMMIT_RESPONSE: { LOG(INFO) << "Processing the commit response"; - ProcessCommitResponseCommand process_response_command; + ProcessCommitResponseCommand process_response_command( + extensions_monitor_); process_response_command.Execute(session); next_step = BUILD_AND_PROCESS_CONFLICT_SETS; break; |