OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/engine/download_updates_command.h" | 5 #include "chrome/browser/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 "chrome/browser/sync/engine/syncer.h" | 10 #include "chrome/browser/sync/engine/syncer.h" |
11 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 11 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
12 #include "chrome/browser/sync/engine/syncproto.h" | 12 #include "chrome/browser/sync/engine/syncproto.h" |
13 #include "chrome/browser/sync/syncable/directory_manager.h" | 13 #include "chrome/browser/sync/syncable/directory_manager.h" |
14 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 14 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 | 16 |
17 using syncable::ScopedDirLookup; | 17 using syncable::ScopedDirLookup; |
18 | 18 |
19 using sync_pb::DebugInfo; | |
20 | |
21 namespace browser_sync { | 19 namespace browser_sync { |
22 using sessions::StatusController; | 20 using sessions::StatusController; |
23 using sessions::SyncSession; | 21 using sessions::SyncSession; |
24 using std::string; | 22 using std::string; |
25 using syncable::FIRST_REAL_MODEL_TYPE; | 23 using syncable::FIRST_REAL_MODEL_TYPE; |
26 using syncable::MODEL_TYPE_COUNT; | 24 using syncable::MODEL_TYPE_COUNT; |
27 | 25 |
28 DownloadUpdatesCommand::DownloadUpdatesCommand() {} | 26 DownloadUpdatesCommand::DownloadUpdatesCommand() {} |
29 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} | 27 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} |
30 | 28 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 get_updates->set_fetch_folders(true); | 76 get_updates->set_fetch_folders(true); |
79 | 77 |
80 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. | 78 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. |
81 get_updates->mutable_caller_info()->set_source( | 79 get_updates->mutable_caller_info()->set_source( |
82 session->TestAndSetSource().updates_source); | 80 session->TestAndSetSource().updates_source); |
83 get_updates->mutable_caller_info()->set_notifications_enabled( | 81 get_updates->mutable_caller_info()->set_notifications_enabled( |
84 session->context()->notifications_enabled()); | 82 session->context()->notifications_enabled()); |
85 | 83 |
86 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); | 84 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); |
87 | 85 |
88 DebugInfo* debug_info = client_to_server_message.mutable_debug_info(); | |
89 | |
90 AppendClientDebugInfoIfNeeded(session, debug_info); | |
91 | |
92 bool ok = SyncerProtoUtil::PostClientToServerMessage( | 86 bool ok = SyncerProtoUtil::PostClientToServerMessage( |
93 client_to_server_message, | 87 client_to_server_message, |
94 &update_response, | 88 &update_response, |
95 session); | 89 session); |
96 | 90 |
97 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( | 91 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( |
98 update_response); | 92 update_response); |
99 | 93 |
100 StatusController* status = session->status_controller(); | 94 StatusController* status = session->status_controller(); |
101 status->set_updates_request_types(enabled_types); | 95 status->set_updates_request_types(enabled_types); |
(...skipping 23 matching lines...) Expand all Loading... |
125 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | 119 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
126 if (target_datatypes[i]) { | 120 if (target_datatypes[i]) { |
127 requested_type_count++; | 121 requested_type_count++; |
128 syncable::AddDefaultExtensionValue(syncable::ModelTypeFromInt(i), | 122 syncable::AddDefaultExtensionValue(syncable::ModelTypeFromInt(i), |
129 filter_protobuf); | 123 filter_protobuf); |
130 } | 124 } |
131 } | 125 } |
132 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; | 126 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; |
133 } | 127 } |
134 | 128 |
135 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded( | |
136 sessions::SyncSession* session, | |
137 DebugInfo* debug_info) { | |
138 // We want to send the debug info only once per sync cycle. Check if it has | |
139 // already been sent. | |
140 if (!session->status_controller()->debug_info_sent()) { | |
141 VLOG(1) << "Sending client debug info ..."; | |
142 // could be null in some unit tests. | |
143 if (session->context()->debug_info_getter()) { | |
144 session->context()->debug_info_getter()->GetAndClearDebugInfo( | |
145 debug_info); | |
146 } | |
147 session->status_controller()->set_debug_info_sent(); | |
148 } | |
149 } | |
150 | |
151 | |
152 } // namespace browser_sync | 129 } // namespace browser_sync |
OLD | NEW |