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

Side by Side Diff: sync/sessions/status_controller.cc

Issue 10210009: sync: Loop committing items without downloading updates (v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 7 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 | « sync/sessions/status_controller.h ('k') | sync/sessions/status_controller_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/sessions/status_controller.h" 5 #include "sync/sessions/status_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "sync/protocol/sync_protocol_error.h" 10 #include "sync/protocol/sync_protocol_error.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 void StatusController::UpdateStartTime() { 136 void StatusController::UpdateStartTime() {
137 sync_start_time_ = base::Time::Now(); 137 sync_start_time_ = base::Time::Now();
138 } 138 }
139 139
140 void StatusController::set_num_successful_bookmark_commits(int value) { 140 void StatusController::set_num_successful_bookmark_commits(int value) {
141 if (shared_.syncer_status.value().num_successful_bookmark_commits != value) 141 if (shared_.syncer_status.value().num_successful_bookmark_commits != value)
142 shared_.syncer_status.mutate()->num_successful_bookmark_commits = value; 142 shared_.syncer_status.mutate()->num_successful_bookmark_commits = value;
143 } 143 }
144 144
145 void StatusController::set_unsynced_handles(
146 const std::vector<int64>& unsynced_handles) {
147 if (!operator==(unsynced_handles, shared_.unsynced_handles.value())) {
148 *(shared_.unsynced_handles.mutate()) = unsynced_handles;
149 }
150 }
151
152 void StatusController::increment_num_successful_bookmark_commits() { 145 void StatusController::increment_num_successful_bookmark_commits() {
153 set_num_successful_bookmark_commits( 146 set_num_successful_bookmark_commits(
154 shared_.syncer_status.value().num_successful_bookmark_commits + 1); 147 shared_.syncer_status.value().num_successful_bookmark_commits + 1);
155 } 148 }
156 149
157 void StatusController::increment_num_successful_commits() { 150 void StatusController::increment_num_successful_commits() {
158 shared_.syncer_status.mutate()->num_successful_commits++; 151 shared_.syncer_status.mutate()->num_successful_commits++;
159 } 152 }
160 153
161 void StatusController::increment_num_local_overwrites() { 154 void StatusController::increment_num_local_overwrites() {
(...skipping 11 matching lines...) Expand all
173 166
174 void StatusController::set_last_download_updates_result( 167 void StatusController::set_last_download_updates_result(
175 const SyncerError result) { 168 const SyncerError result) {
176 shared_.error.mutate()->last_download_updates_result = result; 169 shared_.error.mutate()->last_download_updates_result = result;
177 } 170 }
178 171
179 void StatusController::set_last_post_commit_result(const SyncerError result) { 172 void StatusController::set_last_post_commit_result(const SyncerError result) {
180 shared_.error.mutate()->last_post_commit_result = result; 173 shared_.error.mutate()->last_post_commit_result = result;
181 } 174 }
182 175
176 SyncerError StatusController::last_post_commit_result() const {
177 return shared_.error.value().last_post_commit_result;
178 }
179
183 void StatusController::set_last_process_commit_response_result( 180 void StatusController::set_last_process_commit_response_result(
184 const SyncerError result) { 181 const SyncerError result) {
185 shared_.error.mutate()->last_process_commit_response_result = result; 182 shared_.error.mutate()->last_process_commit_response_result = result;
186 } 183 }
187 184
188 void StatusController::set_commit_set(const OrderedCommitSet& commit_set) { 185 SyncerError StatusController::last_process_commit_response_result() const {
189 DCHECK(!group_restriction_in_effect_); 186 return shared_.error.value().last_process_commit_response_result;
190 shared_.commit_set = commit_set;
191 } 187 }
192 188
193 void StatusController::update_conflicts_resolved(bool resolved) { 189 void StatusController::update_conflicts_resolved(bool resolved) {
194 shared_.control_params.conflicts_resolved |= resolved; 190 shared_.control_params.conflicts_resolved |= resolved;
195 } 191 }
196 void StatusController::reset_conflicts_resolved() { 192 void StatusController::reset_conflicts_resolved() {
197 shared_.control_params.conflicts_resolved = false; 193 shared_.control_params.conflicts_resolved = false;
198 } 194 }
199 void StatusController::set_items_committed() {
200 shared_.control_params.items_committed = true;
201 }
202 195
203 // Returns the number of updates received from the sync server. 196 // Returns the number of updates received from the sync server.
204 int64 StatusController::CountUpdates() const { 197 int64 StatusController::CountUpdates() const {
205 const ClientToServerResponse& updates = shared_.updates_response; 198 const ClientToServerResponse& updates = shared_.updates_response;
206 if (updates.has_get_updates()) { 199 if (updates.has_get_updates()) {
207 return updates.get_updates().entries().size(); 200 return updates.get_updates().entries().size();
208 } else { 201 } else {
209 return 0; 202 return 0;
210 } 203 }
211 } 204 }
212 205
213 bool StatusController::CurrentCommitIdProjectionHasIndex(size_t index) {
214 OrderedCommitSet::Projection proj =
215 shared_.commit_set.GetCommitIdProjection(group_restriction_);
216 return std::binary_search(proj.begin(), proj.end(), index);
217 }
218
219 bool StatusController::HasConflictingUpdates() const { 206 bool StatusController::HasConflictingUpdates() const {
220 DCHECK(!group_restriction_in_effect_) 207 DCHECK(!group_restriction_in_effect_)
221 << "HasConflictingUpdates applies to all ModelSafeGroups"; 208 << "HasConflictingUpdates applies to all ModelSafeGroups";
222 std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it = 209 std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
223 per_model_group_.begin(); 210 per_model_group_.begin();
224 for (; it != per_model_group_.end(); ++it) { 211 for (; it != per_model_group_.end(); ++it) {
225 if (it->second->update_progress.HasConflictingUpdates()) 212 if (it->second->update_progress.HasConflictingUpdates())
226 return true; 213 return true;
227 } 214 }
228 return false; 215 return false;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 void StatusController::set_debug_info_sent() { 294 void StatusController::set_debug_info_sent() {
308 shared_.control_params.debug_info_sent = true; 295 shared_.control_params.debug_info_sent = true;
309 } 296 }
310 297
311 bool StatusController::debug_info_sent() const { 298 bool StatusController::debug_info_sent() const {
312 return shared_.control_params.debug_info_sent; 299 return shared_.control_params.debug_info_sent;
313 } 300 }
314 301
315 } // namespace sessions 302 } // namespace sessions
316 } // namespace browser_sync 303 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/sessions/status_controller.h ('k') | sync/sessions/status_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698