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 "chrome/browser/sync/engine/store_timestamps_command.h" | |
6 | |
7 #include "chrome/browser/sync/sessions/status_controller.h" | |
8 #include "chrome/browser/sync/sessions/sync_session.h" | |
9 #include "chrome/browser/sync/syncable/model_type.h" | |
10 #include "chrome/browser/sync/syncable/syncable.h" | |
11 | |
12 namespace browser_sync { | |
13 | |
14 StoreTimestampsCommand::StoreTimestampsCommand() {} | |
15 StoreTimestampsCommand::~StoreTimestampsCommand() {} | |
16 | |
17 SyncerError StoreTimestampsCommand::ExecuteImpl( | |
18 sessions::SyncSession* session) { | |
19 syncable::Directory* dir = session->context()->directory(); | |
20 | |
21 const GetUpdatesResponse& updates = | |
22 session->status_controller().updates_response().get_updates(); | |
23 | |
24 sessions::StatusController* status = session->mutable_status_controller(); | |
25 | |
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 | |
28 // state. | |
29 syncable::ModelTypeSet forward_progress_types; | |
30 for (int i = 0; i < updates.new_progress_marker_size(); ++i) { | |
31 syncable::ModelType model = | |
32 syncable::GetModelTypeFromSpecificsFieldNumber( | |
33 updates.new_progress_marker(i).data_type_id()); | |
34 if (model == syncable::UNSPECIFIED || model == syncable::TOP_LEVEL_FOLDER) { | |
35 NOTREACHED() << "Unintelligible server response."; | |
36 continue; | |
37 } | |
38 forward_progress_types.Put(model); | |
39 dir->SetDownloadProgress(model, updates.new_progress_marker(i)); | |
40 } | |
41 DCHECK(!forward_progress_types.Empty() || | |
42 updates.changes_remaining() == 0); | |
43 if (VLOG_IS_ON(1)) { | |
44 DVLOG_IF(1, !forward_progress_types.Empty()) | |
45 << "Get Updates got new progress marker for types: " | |
46 << syncable::ModelTypeSetToString(forward_progress_types) | |
47 << " out of possible: " | |
48 << syncable::ModelTypeSetToString(status->updates_request_types()); | |
49 } | |
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); | |
54 } | |
55 | |
56 return SYNCER_OK; | |
57 } | |
58 | |
59 } // namespace browser_sync | |
OLD | NEW |