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" | |
13 #include "sync/internal_api/public/base/model_type_payload_map.h" | 12 #include "sync/internal_api/public/base/model_type_payload_map.h" |
14 #include "sync/syncable/directory.h" | 13 #include "sync/syncable/directory.h" |
15 | 14 |
16 using sync_pb::DebugInfo; | 15 using sync_pb::DebugInfo; |
17 | 16 |
18 namespace syncer { | 17 namespace syncer { |
19 using sessions::StatusController; | 18 using sessions::StatusController; |
20 using sessions::SyncSession; | 19 using sessions::SyncSession; |
21 using std::string; | 20 using std::string; |
22 | 21 |
23 DownloadUpdatesCommand::DownloadUpdatesCommand( | 22 DownloadUpdatesCommand::DownloadUpdatesCommand( |
24 bool create_mobile_bookmarks_folder) | 23 bool create_mobile_bookmarks_folder) |
25 : create_mobile_bookmarks_folder_(create_mobile_bookmarks_folder) {} | 24 : create_mobile_bookmarks_folder_(create_mobile_bookmarks_folder) {} |
26 | 25 |
27 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} | 26 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} |
28 | 27 |
29 SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { | 28 SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { |
30 ClientToServerMessage client_to_server_message; | 29 sync_pb::ClientToServerMessage client_to_server_message; |
31 ClientToServerResponse update_response; | 30 sync_pb::ClientToServerResponse update_response; |
32 | 31 |
33 client_to_server_message.set_share(session->context()->account_name()); | 32 client_to_server_message.set_share(session->context()->account_name()); |
34 client_to_server_message.set_message_contents( | 33 client_to_server_message.set_message_contents( |
35 ClientToServerMessage::GET_UPDATES); | 34 sync_pb::ClientToServerMessage::GET_UPDATES); |
36 GetUpdatesMessage* get_updates = | 35 sync_pb::GetUpdatesMessage* get_updates = |
37 client_to_server_message.mutable_get_updates(); | 36 client_to_server_message.mutable_get_updates(); |
38 get_updates->set_create_mobile_bookmarks_folder( | 37 get_updates->set_create_mobile_bookmarks_folder( |
39 create_mobile_bookmarks_folder_); | 38 create_mobile_bookmarks_folder_); |
40 | 39 |
41 syncable::Directory* dir = session->context()->directory(); | 40 syncable::Directory* dir = session->context()->directory(); |
42 | 41 |
43 // Request updates for all enabled types. | 42 // Request updates for all enabled types. |
44 const ModelTypeSet enabled_types = | 43 const ModelTypeSet enabled_types = |
45 GetRoutingInfoTypes(session->routing_info()); | 44 GetRoutingInfoTypes(session->routing_info()); |
46 DVLOG(1) << "Getting updates for types " | 45 DVLOG(1) << "Getting updates for types " |
(...skipping 20 matching lines...) Expand all Loading... |
67 // this to false, the server would send just the non-container items | 66 // this to false, the server would send just the non-container items |
68 // (e.g. Bookmark URLs but not their containing folders). | 67 // (e.g. Bookmark URLs but not their containing folders). |
69 get_updates->set_fetch_folders(true); | 68 get_updates->set_fetch_folders(true); |
70 | 69 |
71 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. | 70 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. |
72 get_updates->mutable_caller_info()->set_source( | 71 get_updates->mutable_caller_info()->set_source( |
73 session->source().updates_source); | 72 session->source().updates_source); |
74 get_updates->mutable_caller_info()->set_notifications_enabled( | 73 get_updates->mutable_caller_info()->set_notifications_enabled( |
75 session->context()->notifications_enabled()); | 74 session->context()->notifications_enabled()); |
76 | 75 |
| 76 SyncerProtoUtil::SetProtocolVersion(&client_to_server_message); |
77 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); | 77 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); |
78 | 78 |
79 DebugInfo* debug_info = client_to_server_message.mutable_debug_info(); | 79 DebugInfo* debug_info = client_to_server_message.mutable_debug_info(); |
80 | 80 |
81 AppendClientDebugInfoIfNeeded(session, debug_info); | 81 AppendClientDebugInfoIfNeeded(session, debug_info); |
82 | 82 |
83 SyncerError result = SyncerProtoUtil::PostClientToServerMessage( | 83 SyncerError result = SyncerProtoUtil::PostClientToServerMessage( |
84 client_to_server_message, | 84 client_to_server_message, |
85 &update_response, | 85 &update_response, |
86 session); | 86 session); |
(...skipping 29 matching lines...) Expand all Loading... |
116 // could be null in some unit tests. | 116 // could be null in some unit tests. |
117 if (session->context()->debug_info_getter()) { | 117 if (session->context()->debug_info_getter()) { |
118 session->context()->debug_info_getter()->GetAndClearDebugInfo( | 118 session->context()->debug_info_getter()->GetAndClearDebugInfo( |
119 debug_info); | 119 debug_info); |
120 } | 120 } |
121 session->mutable_status_controller()->set_debug_info_sent(); | 121 session->mutable_status_controller()->set_debug_info_sent(); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 } // namespace syncer | 125 } // namespace syncer |
OLD | NEW |