| OLD | NEW |
| 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/download_updates_command.h" | 5 #include "sync/engine/download_updates_command.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "sync/engine/syncer.h" | 10 #include "sync/engine/syncer.h" |
| 11 #include "sync/engine/syncer_proto_util.h" | 11 #include "sync/engine/syncer_proto_util.h" |
| 12 #include "sync/engine/syncproto.h" | 12 #include "sync/engine/syncproto.h" |
| 13 #include "sync/internal_api/public/base/model_type_payload_map.h" | 13 #include "sync/internal_api/public/base/model_type_payload_map.h" |
| 14 #include "sync/syncable/directory.h" | 14 #include "sync/syncable/directory.h" |
| 15 | 15 |
| 16 using sync_pb::DebugInfo; | 16 using sync_pb::DebugInfo; |
| 17 | 17 |
| 18 namespace syncer { | 18 namespace syncer { |
| 19 using sessions::StatusController; | 19 using sessions::StatusController; |
| 20 using sessions::SyncSession; | 20 using sessions::SyncSession; |
| 21 using std::string; | 21 using std::string; |
| 22 using syncable::FIRST_REAL_MODEL_TYPE; | |
| 23 using syncable::MODEL_TYPE_COUNT; | |
| 24 using syncable::ModelTypeSet; | |
| 25 using syncable::ModelTypeSetToString; | |
| 26 | 22 |
| 27 DownloadUpdatesCommand::DownloadUpdatesCommand( | 23 DownloadUpdatesCommand::DownloadUpdatesCommand( |
| 28 bool create_mobile_bookmarks_folder) | 24 bool create_mobile_bookmarks_folder) |
| 29 : create_mobile_bookmarks_folder_(create_mobile_bookmarks_folder) {} | 25 : create_mobile_bookmarks_folder_(create_mobile_bookmarks_folder) {} |
| 30 | 26 |
| 31 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} | 27 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} |
| 32 | 28 |
| 33 SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { | 29 SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { |
| 34 ClientToServerMessage client_to_server_message; | 30 ClientToServerMessage client_to_server_message; |
| 35 ClientToServerResponse update_response; | 31 ClientToServerResponse update_response; |
| 36 | 32 |
| 37 client_to_server_message.set_share(session->context()->account_name()); | 33 client_to_server_message.set_share(session->context()->account_name()); |
| 38 client_to_server_message.set_message_contents( | 34 client_to_server_message.set_message_contents( |
| 39 ClientToServerMessage::GET_UPDATES); | 35 ClientToServerMessage::GET_UPDATES); |
| 40 GetUpdatesMessage* get_updates = | 36 GetUpdatesMessage* get_updates = |
| 41 client_to_server_message.mutable_get_updates(); | 37 client_to_server_message.mutable_get_updates(); |
| 42 get_updates->set_create_mobile_bookmarks_folder( | 38 get_updates->set_create_mobile_bookmarks_folder( |
| 43 create_mobile_bookmarks_folder_); | 39 create_mobile_bookmarks_folder_); |
| 44 | 40 |
| 45 syncable::Directory* dir = session->context()->directory(); | 41 syncable::Directory* dir = session->context()->directory(); |
| 46 | 42 |
| 47 // Request updates for all enabled types. | 43 // Request updates for all enabled types. |
| 48 const ModelTypeSet enabled_types = | 44 const ModelTypeSet enabled_types = |
| 49 GetRoutingInfoTypes(session->routing_info()); | 45 GetRoutingInfoTypes(session->routing_info()); |
| 50 DVLOG(1) << "Getting updates for types " | 46 DVLOG(1) << "Getting updates for types " |
| 51 << ModelTypeSetToString(enabled_types); | 47 << ModelTypeSetToString(enabled_types); |
| 52 DCHECK(!enabled_types.Empty()); | 48 DCHECK(!enabled_types.Empty()); |
| 53 | 49 |
| 54 const syncable::ModelTypePayloadMap& type_payload_map = | 50 const syncer::ModelTypePayloadMap& type_payload_map = |
| 55 session->source().types; | 51 session->source().types; |
| 56 for (ModelTypeSet::Iterator it = enabled_types.First(); | 52 for (ModelTypeSet::Iterator it = enabled_types.First(); |
| 57 it.Good(); it.Inc()) { | 53 it.Good(); it.Inc()) { |
| 58 sync_pb::DataTypeProgressMarker* progress_marker = | 54 sync_pb::DataTypeProgressMarker* progress_marker = |
| 59 get_updates->add_from_progress_marker(); | 55 get_updates->add_from_progress_marker(); |
| 60 dir->GetDownloadProgress(it.Get(), progress_marker); | 56 dir->GetDownloadProgress(it.Get(), progress_marker); |
| 61 | 57 |
| 62 // Set notification hint if present. | 58 // Set notification hint if present. |
| 63 syncable::ModelTypePayloadMap::const_iterator type_payload = | 59 syncer::ModelTypePayloadMap::const_iterator type_payload = |
| 64 type_payload_map.find(it.Get()); | 60 type_payload_map.find(it.Get()); |
| 65 if (type_payload != type_payload_map.end()) { | 61 if (type_payload != type_payload_map.end()) { |
| 66 progress_marker->set_notification_hint(type_payload->second); | 62 progress_marker->set_notification_hint(type_payload->second); |
| 67 } | 63 } |
| 68 } | 64 } |
| 69 | 65 |
| 70 // We want folders for our associated types, always. If we were to set | 66 // We want folders for our associated types, always. If we were to set |
| 71 // this to false, the server would send just the non-container items | 67 // this to false, the server would send just the non-container items |
| 72 // (e.g. Bookmark URLs but not their containing folders). | 68 // (e.g. Bookmark URLs but not their containing folders). |
| 73 get_updates->set_fetch_folders(true); | 69 get_updates->set_fetch_folders(true); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // could be null in some unit tests. | 116 // could be null in some unit tests. |
| 121 if (session->context()->debug_info_getter()) { | 117 if (session->context()->debug_info_getter()) { |
| 122 session->context()->debug_info_getter()->GetAndClearDebugInfo( | 118 session->context()->debug_info_getter()->GetAndClearDebugInfo( |
| 123 debug_info); | 119 debug_info); |
| 124 } | 120 } |
| 125 session->mutable_status_controller()->set_debug_info_sent(); | 121 session->mutable_status_controller()->set_debug_info_sent(); |
| 126 } | 122 } |
| 127 } | 123 } |
| 128 | 124 |
| 129 } // namespace syncer | 125 } // namespace syncer |
| OLD | NEW |