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

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

Issue 10916174: Implement a bag of chips for sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 8 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
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/store_timestamps_command.h" 5 #include "sync/engine/store_timestamps_command.h"
6 6
7 #include "sync/engine/syncer_proto_util.h"
7 #include "sync/internal_api/public/base/model_type.h" 8 #include "sync/internal_api/public/base/model_type.h"
8 #include "sync/sessions/status_controller.h" 9 #include "sync/sessions/status_controller.h"
9 #include "sync/sessions/sync_session.h" 10 #include "sync/sessions/sync_session.h"
10 #include "sync/syncable/directory.h" 11 #include "sync/syncable/directory.h"
11 12
12 namespace syncer { 13 namespace syncer {
13 14
14 StoreTimestampsCommand::StoreTimestampsCommand() {} 15 StoreTimestampsCommand::StoreTimestampsCommand() {}
15 StoreTimestampsCommand::~StoreTimestampsCommand() {} 16 StoreTimestampsCommand::~StoreTimestampsCommand() {}
16 17
17 SyncerError StoreTimestampsCommand::ExecuteImpl( 18 SyncerError StoreTimestampsCommand::ExecuteImpl(
18 sessions::SyncSession* session) { 19 sessions::SyncSession* session) {
19 syncable::Directory* dir = session->context()->directory(); 20 syncable::Directory* dir = session->context()->directory();
20 21
21 const sync_pb::GetUpdatesResponse& updates = 22 const sync_pb::ClientToServerResponse& response =
22 session->status_controller().updates_response().get_updates(); 23 session->status_controller().updates_response();
24 const sync_pb::GetUpdatesResponse& updates = response.get_updates();
23 25
24 sessions::StatusController* status = session->mutable_status_controller(); 26 sessions::StatusController* status = session->mutable_status_controller();
25 27
28 // Persist a bag of chips if it has been sent by the server.
29 SyncerProtoUtil::PersistBagOfChips(dir, response);
30
26 // Update the progress marker tokens from the server result. If a marker 31 // Update the progress marker tokens from the server result. If a marker
27 // was omitted for any one type, that indicates no change from the previous 32 // was omitted for any one type, that indicates no change from the previous
28 // state. 33 // state.
29 ModelTypeSet forward_progress_types; 34 ModelTypeSet forward_progress_types;
30 for (int i = 0; i < updates.new_progress_marker_size(); ++i) { 35 for (int i = 0; i < updates.new_progress_marker_size(); ++i) {
31 ModelType model = 36 ModelType model =
32 GetModelTypeFromSpecificsFieldNumber( 37 GetModelTypeFromSpecificsFieldNumber(
33 updates.new_progress_marker(i).data_type_id()); 38 updates.new_progress_marker(i).data_type_id());
34 if (model == UNSPECIFIED || model == TOP_LEVEL_FOLDER) { 39 if (model == UNSPECIFIED || model == TOP_LEVEL_FOLDER) {
35 NOTREACHED() << "Unintelligible server response."; 40 NOTREACHED() << "Unintelligible server response.";
(...skipping 14 matching lines...) Expand all
50 if (updates.has_changes_remaining()) { 55 if (updates.has_changes_remaining()) {
51 int64 changes_left = updates.changes_remaining(); 56 int64 changes_left = updates.changes_remaining();
52 DVLOG(1) << "Changes remaining: " << changes_left; 57 DVLOG(1) << "Changes remaining: " << changes_left;
53 status->set_num_server_changes_remaining(changes_left); 58 status->set_num_server_changes_remaining(changes_left);
54 } 59 }
55 60
56 return SYNCER_OK; 61 return SYNCER_OK;
57 } 62 }
58 63
59 } // namespace syncer 64 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698