Chromium Code Reviews| 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 | |
| 19 namespace browser_sync { | 21 namespace browser_sync { |
| 20 using sessions::StatusController; | 22 using sessions::StatusController; |
| 21 using sessions::SyncSession; | 23 using sessions::SyncSession; |
| 22 using std::string; | 24 using std::string; |
| 23 using syncable::FIRST_REAL_MODEL_TYPE; | 25 using syncable::FIRST_REAL_MODEL_TYPE; |
| 24 using syncable::MODEL_TYPE_COUNT; | 26 using syncable::MODEL_TYPE_COUNT; |
| 25 | 27 |
| 26 DownloadUpdatesCommand::DownloadUpdatesCommand() {} | 28 DownloadUpdatesCommand::DownloadUpdatesCommand() {} |
| 27 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} | 29 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} |
| 28 | 30 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 get_updates->set_fetch_folders(true); | 78 get_updates->set_fetch_folders(true); |
| 77 | 79 |
| 78 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. | 80 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. |
| 79 get_updates->mutable_caller_info()->set_source( | 81 get_updates->mutable_caller_info()->set_source( |
| 80 session->TestAndSetSource().updates_source); | 82 session->TestAndSetSource().updates_source); |
| 81 get_updates->mutable_caller_info()->set_notifications_enabled( | 83 get_updates->mutable_caller_info()->set_notifications_enabled( |
| 82 session->context()->notifications_enabled()); | 84 session->context()->notifications_enabled()); |
| 83 | 85 |
| 84 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); | 86 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); |
| 85 | 87 |
| 88 AppendClientDebugInfoIfNeeded(session, &client_to_server_message); | |
|
tim (not reviewing)
2011/10/13 16:04:14
This method should take a DebugInfo*, not ClientTo
lipalani1
2011/10/13 21:39:18
Done.
| |
| 89 | |
| 86 bool ok = SyncerProtoUtil::PostClientToServerMessage( | 90 bool ok = SyncerProtoUtil::PostClientToServerMessage( |
| 87 client_to_server_message, | 91 client_to_server_message, |
| 88 &update_response, | 92 &update_response, |
| 89 session); | 93 session); |
| 90 | 94 |
| 91 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( | 95 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( |
| 92 update_response); | 96 update_response); |
| 93 | 97 |
| 94 StatusController* status = session->status_controller(); | 98 StatusController* status = session->status_controller(); |
| 95 status->set_updates_request_types(enabled_types); | 99 status->set_updates_request_types(enabled_types); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 119 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | 123 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
| 120 if (target_datatypes[i]) { | 124 if (target_datatypes[i]) { |
| 121 requested_type_count++; | 125 requested_type_count++; |
| 122 syncable::AddDefaultExtensionValue(syncable::ModelTypeFromInt(i), | 126 syncable::AddDefaultExtensionValue(syncable::ModelTypeFromInt(i), |
| 123 filter_protobuf); | 127 filter_protobuf); |
| 124 } | 128 } |
| 125 } | 129 } |
| 126 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; | 130 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; |
| 127 } | 131 } |
| 128 | 132 |
| 133 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded( | |
| 134 sessions::SyncSession* session, | |
| 135 sync_pb::ClientToServerMessage* client_to_server_message) { | |
| 136 // We want to send the debug info only once per sync cycle. Check if it has | |
| 137 // already been sent. | |
| 138 if (!session->status_controller()->debug_info_sent()) { | |
|
tim (not reviewing)
2011/10/13 16:04:14
The getter should track this. If we're building t
tim (not reviewing)
2011/10/13 16:08:22
It occurred to me that maybe you were mimicing wha
lipalani1
2011/10/13 21:39:18
Keeping the getter as the data only object. After
lipalani1
2011/10/13 21:39:18
Done.
| |
| 139 VLOG(1) << "Sending client debug info ..."; | |
| 140 DebugInfo* debug_info = client_to_server_message->mutable_debug_info(); | |
| 141 // could be null in some unit tests. | |
| 142 if (session->context()->debug_info_getter()) { | |
| 143 session->context()->debug_info_getter()->GetAndClearDebugInfo( | |
| 144 debug_info); | |
| 145 } | |
| 146 session->status_controller()->set_debug_info_sent(true); | |
| 147 } | |
| 148 } | |
| 149 | |
| 150 | |
| 129 } // namespace browser_sync | 151 } // namespace browser_sync |
| OLD | NEW |