OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "sync/engine/store_timestamps_command.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "sync/sessions/status_controller.h" | |
9 #include "sync/sessions/sync_session.h" | |
10 #include "sync/syncable/directory.h" | |
11 | |
12 namespace syncer { | |
13 | |
14 ModelTypeSet ProcessNewProgressMarkers( | |
15 const sync_pb::GetUpdatesResponse& response, | |
16 syncable::Directory* dir) { | |
17 ModelTypeSet forward_progress_types; | |
18 // If a marker was omitted for any one type, that indicates no | |
19 // change from the previous state. | |
20 for (int i = 0; i < response.new_progress_marker_size(); ++i) { | |
21 int field_number = response.new_progress_marker(i).data_type_id(); | |
22 ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number); | |
23 if (!IsRealDataType(model_type)) { | |
24 DLOG(WARNING) << "Unknown field number " << field_number; | |
25 continue; | |
26 } | |
27 forward_progress_types.Put(model_type); | |
28 dir->SetDownloadProgress(model_type, response.new_progress_marker(i)); | |
29 } | |
30 return forward_progress_types; | |
31 } | |
32 | |
33 StoreTimestampsCommand::StoreTimestampsCommand() {} | |
34 StoreTimestampsCommand::~StoreTimestampsCommand() {} | |
35 | |
36 SyncerError StoreTimestampsCommand::ExecuteImpl( | |
37 sessions::SyncSession* session) { | |
38 const sync_pb::GetUpdatesResponse& updates = | |
39 session->status_controller().updates_response().get_updates(); | |
40 | |
41 sessions::StatusController* status = session->mutable_status_controller(); | |
42 | |
43 ModelTypeSet forward_progress_types = | |
44 ProcessNewProgressMarkers(updates, session->context()->directory()); | |
45 DCHECK(!forward_progress_types.Empty() || | |
46 updates.changes_remaining() == 0); | |
47 if (VLOG_IS_ON(1)) { | |
48 DVLOG_IF(1, !forward_progress_types.Empty()) | |
49 << "Get Updates got new progress marker for types: " | |
50 << ModelTypeSetToString(forward_progress_types) | |
51 << " out of possible: " | |
52 << ModelTypeSetToString(status->updates_request_types()); | |
53 } | |
54 if (updates.has_changes_remaining()) { | |
55 int64 changes_left = updates.changes_remaining(); | |
56 DVLOG(1) << "Changes remaining: " << changes_left; | |
57 status->set_num_server_changes_remaining(changes_left); | |
58 } | |
59 | |
60 return SYNCER_OK; | |
61 } | |
62 | |
63 } // namespace syncer | |
OLD | NEW |