Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/syncer_proto_util.h" | 5 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 9 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 10 #include "chrome/browser/sync/engine/syncer.h" | 10 #include "chrome/browser/sync/engine/syncer.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 http_response.server_status = HttpResponse::SYNC_AUTH_ERROR; | 160 http_response.server_status = HttpResponse::SYNC_AUTH_ERROR; |
| 161 return false; | 161 return false; |
| 162 default: | 162 default: |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 return false; | 167 return false; |
| 168 } | 168 } |
| 169 | 169 |
| 170 namespace { | |
| 171 | |
| 172 // Helper function for an assertion in PostClientToServerMessage. | |
| 173 bool IsVeryFirstGetUpdates(const ClientToServerMessage& message) { | |
| 174 if (!message.has_get_updates()) | |
| 175 return false; | |
| 176 DCHECK(message.get_updates().from_progress_marker_size() > 0); | |
|
tim (not reviewing)
2011/01/11 19:14:23
nit - DCHECK_GT
ncarter (slow)
2011/01/13 00:06:13
Done.
| |
| 177 for (int i = 0; i < message.get_updates().from_progress_marker_size(); ++i) { | |
| 178 if (!message.get_updates().from_progress_marker(i).token().empty()) | |
| 179 return false; | |
| 180 } | |
| 181 return true; | |
| 182 } | |
| 183 | |
| 184 } // namespace | |
| 185 | |
| 170 // static | 186 // static |
| 171 bool SyncerProtoUtil::PostClientToServerMessage( | 187 bool SyncerProtoUtil::PostClientToServerMessage( |
| 172 const ClientToServerMessage& msg, | 188 const ClientToServerMessage& msg, |
| 173 ClientToServerResponse* response, | 189 ClientToServerResponse* response, |
| 174 SyncSession* session) { | 190 SyncSession* session) { |
| 175 | 191 |
| 176 CHECK(response); | 192 CHECK(response); |
| 177 DCHECK(msg.has_store_birthday() || (msg.has_get_updates() && | 193 DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated. |
| 178 msg.get_updates().has_from_timestamp() && | 194 DCHECK(!msg.get_updates().has_requested_types()); // Deprecated. |
| 179 msg.get_updates().from_timestamp() == 0)) | 195 DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg)) |
| 180 << "Must call AddRequestBirthday to set birthday."; | 196 << "Must call AddRequestBirthday to set birthday."; |
| 181 | 197 |
| 182 ScopedDirLookup dir(session->context()->directory_manager(), | 198 ScopedDirLookup dir(session->context()->directory_manager(), |
| 183 session->context()->account_name()); | 199 session->context()->account_name()); |
| 184 if (!dir.good()) | 200 if (!dir.good()) |
| 185 return false; | 201 return false; |
| 186 | 202 |
| 187 if (!PostAndProcessHeaders(session->context()->connection_manager(), session, | 203 if (!PostAndProcessHeaders(session->context()->connection_manager(), session, |
| 188 msg, response)) | 204 msg, response)) |
| 189 return false; | 205 return false; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 std::string SyncerProtoUtil::ClientToServerResponseDebugString( | 356 std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
| 341 const sync_pb::ClientToServerResponse& response) { | 357 const sync_pb::ClientToServerResponse& response) { |
| 342 // Add more handlers as needed. | 358 // Add more handlers as needed. |
| 343 std::string output; | 359 std::string output; |
| 344 if (response.has_get_updates()) | 360 if (response.has_get_updates()) |
| 345 output.append(GetUpdatesResponseString(response.get_updates())); | 361 output.append(GetUpdatesResponseString(response.get_updates())); |
| 346 return output; | 362 return output; |
| 347 } | 363 } |
| 348 | 364 |
| 349 } // namespace browser_sync | 365 } // namespace browser_sync |
| OLD | NEW |