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
3 // found in the LICENSE file.
5 #include "sync/engine/store_timestamps_command.h"
7 #include "sync/internal_api/public/base/model_type.h"
8 #include "sync/sessions/status_controller.h"
9 #include "sync/sessions/sync_session.h"
10 #include "sync/syncable/directory.h"
14 StoreTimestampsCommand::StoreTimestampsCommand() {}
15 StoreTimestampsCommand::~StoreTimestampsCommand() {}
17 SyncerError
StoreTimestampsCommand::ExecuteImpl(
18 sessions::SyncSession
* session
) {
19 syncable::Directory
* dir
= session
->context()->directory();
21 const sync_pb::GetUpdatesResponse
& updates
=
22 session
->status_controller().updates_response().get_updates();
24 sessions::StatusController
* status
= session
->mutable_status_controller();
26 // 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
29 ModelTypeSet forward_progress_types
;
30 for (int i
= 0; i
< updates
.new_progress_marker_size(); ++i
) {
32 GetModelTypeFromSpecificsFieldNumber(
33 updates
.new_progress_marker(i
).data_type_id());
34 if (model
== UNSPECIFIED
|| model
== TOP_LEVEL_FOLDER
) {
35 NOTREACHED() << "Unintelligible server response.";
38 forward_progress_types
.Put(model
);
39 dir
->SetDownloadProgress(model
, updates
.new_progress_marker(i
));
41 DCHECK(!forward_progress_types
.Empty() ||
42 updates
.changes_remaining() == 0);
44 DVLOG_IF(1, !forward_progress_types
.Empty())
45 << "Get Updates got new progress marker for types: "
46 << ModelTypeSetToString(forward_progress_types
)
47 << " out of possible: "
48 << ModelTypeSetToString(status
->updates_request_types());
50 if (updates
.has_changes_remaining()) {
51 int64 changes_left
= updates
.changes_remaining();
52 DVLOG(1) << "Changes remaining: " << changes_left
;
53 status
->set_num_server_changes_remaining(changes_left
);