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

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

Issue 891123003: Revert of Sync commit errors should temporarily re-enable trigger pre-commit getupdates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « sync/engine/syncer.h ('k') | sync/engine/syncer_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/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 : cancelation_signal_(cancelation_signal) { 48 : cancelation_signal_(cancelation_signal) {
49 } 49 }
50 50
51 Syncer::~Syncer() {} 51 Syncer::~Syncer() {}
52 52
53 bool Syncer::ExitRequested() { 53 bool Syncer::ExitRequested() {
54 return cancelation_signal_->IsSignalled(); 54 return cancelation_signal_->IsSignalled();
55 } 55 }
56 56
57 bool Syncer::NormalSyncShare(ModelTypeSet request_types, 57 bool Syncer::NormalSyncShare(ModelTypeSet request_types,
58 NudgeTracker* nudge_tracker, 58 const NudgeTracker& nudge_tracker,
59 SyncSession* session) { 59 SyncSession* session) {
60 HandleCycleBegin(session); 60 HandleCycleBegin(session);
61 if (nudge_tracker->IsGetUpdatesRequired() || 61 if (nudge_tracker.IsGetUpdatesRequired() ||
62 session->context()->ShouldFetchUpdatesBeforeCommit()) { 62 session->context()->ShouldFetchUpdatesBeforeCommit()) {
63 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types); 63 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types);
64 NormalGetUpdatesDelegate normal_delegate(*nudge_tracker); 64 NormalGetUpdatesDelegate normal_delegate(nudge_tracker);
65 GetUpdatesProcessor get_updates_processor( 65 GetUpdatesProcessor get_updates_processor(
66 session->context()->model_type_registry()->update_handler_map(), 66 session->context()->model_type_registry()->update_handler_map(),
67 normal_delegate); 67 normal_delegate);
68 if (!DownloadAndApplyUpdates( 68 if (!DownloadAndApplyUpdates(
69 request_types, 69 request_types,
70 session, 70 session,
71 &get_updates_processor, 71 &get_updates_processor,
72 kCreateMobileBookmarksFolder)) { 72 kCreateMobileBookmarksFolder)) {
73 return HandleCycleEnd(session, nudge_tracker->GetLegacySource()); 73 return HandleCycleEnd(session, nudge_tracker.GetLegacySource());
74 } 74 }
75 } 75 }
76 76
77 VLOG(1) << "Committing from types " << ModelTypeSetToString(request_types); 77 VLOG(1) << "Committing from types " << ModelTypeSetToString(request_types);
78 CommitProcessor commit_processor( 78 CommitProcessor commit_processor(
79 session->context()->model_type_registry()->commit_contributor_map()); 79 session->context()->model_type_registry()->commit_contributor_map());
80 SyncerError commit_result = BuildAndPostCommits(request_types, nudge_tracker, 80 SyncerError commit_result =
81 session, &commit_processor); 81 BuildAndPostCommits(request_types, session, &commit_processor);
82 session->mutable_status_controller()->set_commit_result(commit_result); 82 session->mutable_status_controller()->set_commit_result(commit_result);
83 83
84 return HandleCycleEnd(session, nudge_tracker->GetLegacySource()); 84 return HandleCycleEnd(session, nudge_tracker.GetLegacySource());
85 } 85 }
86 86
87 bool Syncer::ConfigureSyncShare( 87 bool Syncer::ConfigureSyncShare(
88 ModelTypeSet request_types, 88 ModelTypeSet request_types,
89 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, 89 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
90 SyncSession* session) { 90 SyncSession* session) {
91 VLOG(1) << "Configuring types " << ModelTypeSetToString(request_types); 91 VLOG(1) << "Configuring types " << ModelTypeSetToString(request_types);
92 HandleCycleBegin(session); 92 HandleCycleBegin(session);
93 ConfigureGetUpdatesDelegate configure_delegate(source); 93 ConfigureGetUpdatesDelegate configure_delegate(source);
94 GetUpdatesProcessor get_updates_processor( 94 GetUpdatesProcessor get_updates_processor(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 session->status_controller().num_hierarchy_conflicts() > 0); 153 session->status_controller().num_hierarchy_conflicts() > 0);
154 session->SendEventNotification(SyncCycleEvent::STATUS_CHANGED); 154 session->SendEventNotification(SyncCycleEvent::STATUS_CHANGED);
155 } 155 }
156 156
157 if (ExitRequested()) 157 if (ExitRequested())
158 return false; 158 return false;
159 return true; 159 return true;
160 } 160 }
161 161
162 SyncerError Syncer::BuildAndPostCommits(ModelTypeSet requested_types, 162 SyncerError Syncer::BuildAndPostCommits(ModelTypeSet requested_types,
163 sessions::NudgeTracker* nudge_tracker,
164 sessions::SyncSession* session, 163 sessions::SyncSession* session,
165 CommitProcessor* commit_processor) { 164 CommitProcessor* commit_processor) {
166 // The ExitRequested() check is unnecessary, since we should start getting 165 // The ExitRequested() check is unnecessary, since we should start getting
167 // errors from the ServerConnectionManager if an exist has been requested. 166 // errors from the ServerConnectionManager if an exist has been requested.
168 // However, it doesn't hurt to check it anyway. 167 // However, it doesn't hurt to check it anyway.
169 while (!ExitRequested()) { 168 while (!ExitRequested()) {
170 scoped_ptr<Commit> commit( 169 scoped_ptr<Commit> commit(
171 Commit::Init( 170 Commit::Init(
172 requested_types, 171 requested_types,
173 session->context()->GetEnabledTypes(), 172 session->context()->GetEnabledTypes(),
174 session->context()->max_commit_batch_size(), 173 session->context()->max_commit_batch_size(),
175 session->context()->account_name(), 174 session->context()->account_name(),
176 session->context()->directory()->cache_guid(), 175 session->context()->directory()->cache_guid(),
177 commit_processor, 176 commit_processor,
178 session->context()->extensions_activity())); 177 session->context()->extensions_activity()));
179 if (!commit) { 178 if (!commit) {
180 break; 179 break;
181 } 180 }
182 181
183 SyncerError error = commit->PostAndProcessResponse( 182 SyncerError error = commit->PostAndProcessResponse(
184 nudge_tracker, session, session->mutable_status_controller(), 183 session,
184 session->mutable_status_controller(),
185 session->context()->extensions_activity()); 185 session->context()->extensions_activity());
186 commit->CleanUp(); 186 commit->CleanUp();
187 if (error != SYNCER_OK) { 187 if (error != SYNCER_OK) {
188 return error; 188 return error;
189 } 189 }
190 } 190 }
191 191
192 return SYNCER_OK; 192 return SYNCER_OK;
193 } 193 }
194 194
195 void Syncer::HandleCycleBegin(SyncSession* session) { 195 void Syncer::HandleCycleBegin(SyncSession* session) {
196 session->mutable_status_controller()->UpdateStartTime(); 196 session->mutable_status_controller()->UpdateStartTime();
197 session->SendEventNotification(SyncCycleEvent::SYNC_CYCLE_BEGIN); 197 session->SendEventNotification(SyncCycleEvent::SYNC_CYCLE_BEGIN);
198 } 198 }
199 199
200 bool Syncer::HandleCycleEnd( 200 bool Syncer::HandleCycleEnd(
201 SyncSession* session, 201 SyncSession* session,
202 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { 202 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) {
203 if (!ExitRequested()) { 203 if (!ExitRequested()) {
204 session->SendSyncCycleEndEventNotification(source); 204 session->SendSyncCycleEndEventNotification(source);
205 return true; 205 return true;
206 } else { 206 } else {
207 return false; 207 return false;
208 } 208 }
209 } 209 }
210 210
211 } // namespace syncer 211 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer.h ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698