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

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

Issue 2075012: Replace changes_channel with an observer list. (Closed)
Patch Set: Ready for checkin Created 10 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/sync/engine/syncer.h ('k') | chrome/browser/sync/engine/syncer_command.cc » ('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 file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/engine/syncer.h" 5 #include "chrome/browser/sync/engine/syncer.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/sync/engine/apply_updates_command.h" 10 #include "chrome/browser/sync/engine/apply_updates_command.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 namespace browser_sync { 49 namespace browser_sync {
50 50
51 using sessions::StatusController; 51 using sessions::StatusController;
52 using sessions::SyncSession; 52 using sessions::SyncSession;
53 using sessions::ConflictProgress; 53 using sessions::ConflictProgress;
54 54
55 Syncer::Syncer(sessions::SyncSessionContext* context) 55 Syncer::Syncer(sessions::SyncSessionContext* context)
56 : early_exit_requested_(false), 56 : early_exit_requested_(false),
57 max_commit_batch_size_(kDefaultMaxCommitBatchSize), 57 max_commit_batch_size_(kDefaultMaxCommitBatchSize),
58 syncer_event_channel_(new SyncerEventChannel(SyncerEvent( 58 syncer_event_channel_(new SyncerEventChannel()),
59 SyncerEvent::SHUTDOWN_USE_WITH_CARE))),
60 resolver_scoper_(context, &resolver_), 59 resolver_scoper_(context, &resolver_),
61 event_channel_scoper_(context, syncer_event_channel_.get()), 60 event_channel_scoper_(context, syncer_event_channel_.get()),
62 context_(context), 61 context_(context),
63 updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN), 62 updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN),
64 pre_conflict_resolution_closure_(NULL) { 63 pre_conflict_resolution_closure_(NULL) {
65 shutdown_channel_.reset(new ShutdownChannel(this)); 64 shutdown_channel_.reset(new ShutdownChannel());
66 65
67 ScopedDirLookup dir(context->directory_manager(), context->account_name()); 66 ScopedDirLookup dir(context->directory_manager(), context->account_name());
68 // The directory must be good here. 67 // The directory must be good here.
69 CHECK(dir.good()); 68 CHECK(dir.good());
70 } 69 }
71 70
71 Syncer::~Syncer() {
72 syncer_event_channel_->Notify(
73 SyncerEvent(SyncerEvent::SHUTDOWN_USE_WITH_CARE));
74 shutdown_channel_->Notify(SyncerShutdownEvent(this));
75 }
76
72 void Syncer::RequestNudge(int milliseconds) { 77 void Syncer::RequestNudge(int milliseconds) {
73 SyncerEvent event(SyncerEvent::REQUEST_SYNC_NUDGE); 78 SyncerEvent event(SyncerEvent::REQUEST_SYNC_NUDGE);
74 event.nudge_delay_milliseconds = milliseconds; 79 event.nudge_delay_milliseconds = milliseconds;
75 syncer_event_channel_->NotifyListeners(event); 80 syncer_event_channel_->Notify(event);
76 } 81 }
77 82
78 bool Syncer::SyncShare(sessions::SyncSession::Delegate* delegate) { 83 bool Syncer::SyncShare(sessions::SyncSession::Delegate* delegate) {
79 sessions::SyncSession session(context_, delegate); 84 sessions::SyncSession session(context_, delegate);
80 return SyncShare(&session); 85 return SyncShare(&session);
81 } 86 }
82 87
83 bool Syncer::SyncShare(sessions::SyncSession* session) { 88 bool Syncer::SyncShare(sessions::SyncSession* session) {
84 session->set_source(TestAndSetUpdatesSource()); 89 session->set_source(TestAndSetUpdatesSource());
85 // This isn't perfect, as we can end up bundling extensions activity 90 // This isn't perfect, as we can end up bundling extensions activity
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 entry->Put(SERVER_CTIME, 0); 317 entry->Put(SERVER_CTIME, 0);
313 entry->Put(SERVER_VERSION, 0); 318 entry->Put(SERVER_VERSION, 0);
314 entry->Put(SERVER_IS_DIR, false); 319 entry->Put(SERVER_IS_DIR, false);
315 entry->Put(SERVER_IS_DEL, false); 320 entry->Put(SERVER_IS_DEL, false);
316 entry->Put(IS_UNAPPLIED_UPDATE, false); 321 entry->Put(IS_UNAPPLIED_UPDATE, false);
317 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); 322 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance());
318 entry->Put(SERVER_POSITION_IN_PARENT, 0); 323 entry->Put(SERVER_POSITION_IN_PARENT, 0);
319 } 324 }
320 325
321 } // namespace browser_sync 326 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer.h ('k') | chrome/browser/sync/engine/syncer_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698