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

Side by Side Diff: trunk/src/sync/engine/syncer.cc

Issue 23658030: Revert 222154 "sync: Gracefully handle very early shutdown" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/sync/engine/syncer.h ('k') | trunk/src/sync/engine/syncer_proto_util_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/engine/syncer.h" 5 #include "sync/engine/syncer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "sync/engine/apply_control_data_updates.h" 13 #include "sync/engine/apply_control_data_updates.h"
14 #include "sync/engine/apply_updates_and_resolve_conflicts_command.h" 14 #include "sync/engine/apply_updates_and_resolve_conflicts_command.h"
15 #include "sync/engine/build_commit_command.h" 15 #include "sync/engine/build_commit_command.h"
16 #include "sync/engine/commit.h" 16 #include "sync/engine/commit.h"
17 #include "sync/engine/conflict_resolver.h" 17 #include "sync/engine/conflict_resolver.h"
18 #include "sync/engine/download.h" 18 #include "sync/engine/download.h"
19 #include "sync/engine/net/server_connection_manager.h" 19 #include "sync/engine/net/server_connection_manager.h"
20 #include "sync/engine/process_commit_response_command.h" 20 #include "sync/engine/process_commit_response_command.h"
21 #include "sync/engine/syncer_types.h" 21 #include "sync/engine/syncer_types.h"
22 #include "sync/internal_api/public/base/cancelation_signal.h"
23 #include "sync/internal_api/public/base/unique_position.h" 22 #include "sync/internal_api/public/base/unique_position.h"
24 #include "sync/internal_api/public/util/syncer_error.h" 23 #include "sync/internal_api/public/util/syncer_error.h"
25 #include "sync/sessions/nudge_tracker.h" 24 #include "sync/sessions/nudge_tracker.h"
26 #include "sync/syncable/mutable_entry.h" 25 #include "sync/syncable/mutable_entry.h"
27 #include "sync/syncable/syncable-inl.h" 26 #include "sync/syncable/syncable-inl.h"
28 27
29 using base::Time; 28 using base::Time;
30 using base::TimeDelta; 29 using base::TimeDelta;
31 using sync_pb::ClientCommand; 30 using sync_pb::ClientCommand;
32 31
33 namespace syncer { 32 namespace syncer {
34 33
35 // TODO(akalin): We may want to propagate this switch up 34 // TODO(akalin): We may want to propagate this switch up
36 // eventually. 35 // eventually.
37 #if defined(OS_ANDROID) || defined(OS_IOS) 36 #if defined(OS_ANDROID) || defined(OS_IOS)
38 static const bool kCreateMobileBookmarksFolder = true; 37 static const bool kCreateMobileBookmarksFolder = true;
39 #else 38 #else
40 static const bool kCreateMobileBookmarksFolder = false; 39 static const bool kCreateMobileBookmarksFolder = false;
41 #endif 40 #endif
42 41
43 using sessions::StatusController; 42 using sessions::StatusController;
44 using sessions::SyncSession; 43 using sessions::SyncSession;
45 using sessions::NudgeTracker; 44 using sessions::NudgeTracker;
46 45
47 Syncer::Syncer(syncer::CancelationSignal* cancelation_signal) 46 Syncer::Syncer()
48 : cancelation_signal_(cancelation_signal) { 47 : early_exit_requested_(false) {
49 } 48 }
50 49
51 Syncer::~Syncer() {} 50 Syncer::~Syncer() {}
52 51
53 bool Syncer::ExitRequested() { 52 bool Syncer::ExitRequested() {
54 return cancelation_signal_->IsStopRequested(); 53 base::AutoLock lock(early_exit_requested_lock_);
54 return early_exit_requested_;
55 }
56
57 void Syncer::RequestEarlyExit() {
58 base::AutoLock lock(early_exit_requested_lock_);
59 early_exit_requested_ = true;
55 } 60 }
56 61
57 bool Syncer::NormalSyncShare(ModelTypeSet request_types, 62 bool Syncer::NormalSyncShare(ModelTypeSet request_types,
58 const NudgeTracker& nudge_tracker, 63 const NudgeTracker& nudge_tracker,
59 SyncSession* session) { 64 SyncSession* session) {
60 HandleCycleBegin(session); 65 HandleCycleBegin(session);
61 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types); 66 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types);
62 if (nudge_tracker.IsGetUpdatesRequired() || 67 if (nudge_tracker.IsGetUpdatesRequired() ||
63 session->context()->ShouldFetchUpdatesBeforeCommit()) { 68 session->context()->ShouldFetchUpdatesBeforeCommit()) {
64 if (!DownloadAndApplyUpdates( 69 if (!DownloadAndApplyUpdates(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { 159 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) {
155 if (!ExitRequested()) { 160 if (!ExitRequested()) {
156 session->SendSyncCycleEndEventNotification(source); 161 session->SendSyncCycleEndEventNotification(source);
157 return true; 162 return true;
158 } else { 163 } else {
159 return false; 164 return false;
160 } 165 }
161 } 166 }
162 167
163 } // namespace syncer 168 } // namespace syncer
OLDNEW
« no previous file with comments | « trunk/src/sync/engine/syncer.h ('k') | trunk/src/sync/engine/syncer_proto_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698