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

Side by Side Diff: chrome/browser/sync/engine/syncer.cc

Issue 333041: Take 2 at browser_sync::ExtensionsActivityMonitor.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/engine/syncer.h ('k') | chrome/browser/sync/engine/syncer_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE entry. 3 // found in the LICENSE entry.
4 4
5 #include "chrome/browser/sync/engine/syncer.h" 5 #include "chrome/browser/sync/engine/syncer.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/message_loop.h"
9 #include "chrome/browser/chrome_thread.h"
8 #include "chrome/browser/sync/engine/apply_updates_command.h" 10 #include "chrome/browser/sync/engine/apply_updates_command.h"
9 #include "chrome/browser/sync/engine/build_and_process_conflict_sets_command.h" 11 #include "chrome/browser/sync/engine/build_and_process_conflict_sets_command.h"
10 #include "chrome/browser/sync/engine/build_commit_command.h" 12 #include "chrome/browser/sync/engine/build_commit_command.h"
11 #include "chrome/browser/sync/engine/conflict_resolver.h" 13 #include "chrome/browser/sync/engine/conflict_resolver.h"
12 #include "chrome/browser/sync/engine/download_updates_command.h" 14 #include "chrome/browser/sync/engine/download_updates_command.h"
13 #include "chrome/browser/sync/engine/get_commit_ids_command.h" 15 #include "chrome/browser/sync/engine/get_commit_ids_command.h"
14 #include "chrome/browser/sync/engine/net/server_connection_manager.h" 16 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
15 #include "chrome/browser/sync/engine/post_commit_message_command.h" 17 #include "chrome/browser/sync/engine/post_commit_message_command.h"
16 #include "chrome/browser/sync/engine/process_commit_response_command.h" 18 #include "chrome/browser/sync/engine/process_commit_response_command.h"
17 #include "chrome/browser/sync/engine/process_updates_command.h" 19 #include "chrome/browser/sync/engine/process_updates_command.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 dirman_(dirman), 61 dirman_(dirman),
60 command_channel_(NULL), 62 command_channel_(NULL),
61 model_safe_worker_(model_safe_worker), 63 model_safe_worker_(model_safe_worker),
62 updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN), 64 updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN),
63 notifications_enabled_(false), 65 notifications_enabled_(false),
64 pre_conflict_resolution_function_(NULL) { 66 pre_conflict_resolution_function_(NULL) {
65 SyncerEvent shutdown = { SyncerEvent::SHUTDOWN_USE_WITH_CARE }; 67 SyncerEvent shutdown = { SyncerEvent::SHUTDOWN_USE_WITH_CARE };
66 syncer_event_channel_.reset(new SyncerEventChannel(shutdown)); 68 syncer_event_channel_.reset(new SyncerEventChannel(shutdown));
67 shutdown_channel_.reset(new ShutdownChannel(this)); 69 shutdown_channel_.reset(new ShutdownChannel(this));
68 70
71 extensions_monitor_ = new ExtensionsActivityMonitor();
72
69 ScopedDirLookup dir(dirman_, account_name_); 73 ScopedDirLookup dir(dirman_, account_name_);
70 // The directory must be good here. 74 // The directory must be good here.
71 CHECK(dir.good()); 75 CHECK(dir.good());
72 } 76 }
73 77
74 Syncer::~Syncer() {} 78 Syncer::~Syncer() {
79 if (!ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE,
80 extensions_monitor_)) {
81 // In unittests, there may be no UI thread, so the above will fail.
82 delete extensions_monitor_;
83 }
84 extensions_monitor_ = NULL;
85 }
75 86
76 void Syncer::RequestNudge(int milliseconds) { 87 void Syncer::RequestNudge(int milliseconds) {
77 SyncerEvent event; 88 SyncerEvent event;
78 event.what_happened = SyncerEvent::REQUEST_SYNC_NUDGE; 89 event.what_happened = SyncerEvent::REQUEST_SYNC_NUDGE;
79 event.nudge_delay_milliseconds = milliseconds; 90 event.nudge_delay_milliseconds = milliseconds;
80 channel()->NotifyListeners(event); 91 channel()->NotifyListeners(event);
81 } 92 }
82 93
83 bool Syncer::SyncShare() { 94 bool Syncer::SyncShare() {
84 SyncProcessState state(dirman_, account_name_, connection_manager_, 95 SyncProcessState state(dirman_, account_name_, connection_manager_,
85 &resolver_, syncer_event_channel_.get(), 96 &resolver_, syncer_event_channel_.get(),
86 model_safe_worker()); 97 model_safe_worker());
87 return SyncShare(&state); 98 return SyncShare(&state);
88 } 99 }
89 100
90 bool Syncer::SyncShare(SyncProcessState* process_state) { 101 bool Syncer::SyncShare(SyncProcessState* process_state) {
91 SyncCycleState cycle_state; 102 SyncCycleState cycle_state;
92 SyncerSession session(&cycle_state, process_state); 103 SyncerSession session(&cycle_state, process_state);
93 session.set_source(TestAndSetUpdatesSource()); 104 session.set_source(TestAndSetUpdatesSource());
94 session.set_notifications_enabled(notifications_enabled()); 105 session.set_notifications_enabled(notifications_enabled());
106 // This isn't perfect, as we can end up bundling extensions activity
107 // intended for the next session into the current one. We could do a
108 // test-and-reset as with the source, but note that also falls short if
109 // the commit request fails (due to lost connection, for example), as we will
110 // fall all the way back to the syncer thread main loop in that case, and
111 // wind up creating a new session when a connection is established, losing
112 // the records set here on the original attempt. This should provide us
113 // with the right data "most of the time", and we're only using this for
114 // analysis purposes, so Law of Large Numbers FTW.
115 extensions_monitor_->GetAndClearRecords(
116 session.mutable_extensions_activity());
95 SyncShare(&session, SYNCER_BEGIN, SYNCER_END); 117 SyncShare(&session, SYNCER_BEGIN, SYNCER_END);
96 return session.HasMoreToSync(); 118 return session.HasMoreToSync();
97 } 119 }
98 120
99 bool Syncer::SyncShare(SyncerStep first_step, SyncerStep last_step) { 121 bool Syncer::SyncShare(SyncerStep first_step, SyncerStep last_step) {
100 SyncCycleState cycle_state; 122 SyncCycleState cycle_state;
101 SyncProcessState state(dirman_, account_name_, connection_manager_, 123 SyncProcessState state(dirman_, account_name_, connection_manager_,
102 &resolver_, syncer_event_channel_.get(), 124 &resolver_, syncer_event_channel_.get(),
103 model_safe_worker()); 125 model_safe_worker());
104 SyncerSession session(&cycle_state, &state); 126 SyncerSession session(&cycle_state, &state);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 220 }
199 case POST_COMMIT_MESSAGE: { 221 case POST_COMMIT_MESSAGE: {
200 LOG(INFO) << "Posting a commit request"; 222 LOG(INFO) << "Posting a commit request";
201 PostCommitMessageCommand post_commit_command; 223 PostCommitMessageCommand post_commit_command;
202 post_commit_command.Execute(session); 224 post_commit_command.Execute(session);
203 next_step = PROCESS_COMMIT_RESPONSE; 225 next_step = PROCESS_COMMIT_RESPONSE;
204 break; 226 break;
205 } 227 }
206 case PROCESS_COMMIT_RESPONSE: { 228 case PROCESS_COMMIT_RESPONSE: {
207 LOG(INFO) << "Processing the commit response"; 229 LOG(INFO) << "Processing the commit response";
208 ProcessCommitResponseCommand process_response_command; 230 ProcessCommitResponseCommand process_response_command(
231 extensions_monitor_);
209 process_response_command.Execute(session); 232 process_response_command.Execute(session);
210 next_step = BUILD_AND_PROCESS_CONFLICT_SETS; 233 next_step = BUILD_AND_PROCESS_CONFLICT_SETS;
211 break; 234 break;
212 } 235 }
213 case BUILD_AND_PROCESS_CONFLICT_SETS: { 236 case BUILD_AND_PROCESS_CONFLICT_SETS: {
214 LOG(INFO) << "Building and Processing Conflict Sets"; 237 LOG(INFO) << "Building and Processing Conflict Sets";
215 BuildAndProcessConflictSetsCommand build_process_conflict_sets; 238 BuildAndProcessConflictSetsCommand build_process_conflict_sets;
216 build_process_conflict_sets.Execute(session); 239 build_process_conflict_sets.Execute(session);
217 if (session->conflict_sets_built()) 240 if (session->conflict_sets_built())
218 next_step = SYNCER_END; 241 next_step = SYNCER_END;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 entry.id_string().c_str(), 354 entry.id_string().c_str(),
332 entry.parent_id_string().c_str(), 355 entry.parent_id_string().c_str(),
333 entry.version(), 356 entry.version(),
334 entry.mtime(), ServerTimeToClientTime(entry.mtime()), 357 entry.mtime(), ServerTimeToClientTime(entry.mtime()),
335 entry.ctime(), ServerTimeToClientTime(entry.ctime()), 358 entry.ctime(), ServerTimeToClientTime(entry.ctime()),
336 entry.name().c_str(), entry.sync_timestamp(), 359 entry.name().c_str(), entry.sync_timestamp(),
337 entry.deleted() ? "deleted, ":""); 360 entry.deleted() ? "deleted, ":"");
338 } 361 }
339 362
340 } // namespace browser_sync 363 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer.h ('k') | chrome/browser/sync/engine/syncer_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698