| 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/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/stringprintf.h" | 8 #include "base/stringprintf.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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const sync_pb::ClientToServerResponse* response, | 86 const sync_pb::ClientToServerResponse* response, |
| 87 sessions::SyncSession* session) { | 87 sessions::SyncSession* session) { |
| 88 LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size()) | 88 LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size()) |
| 89 << "MIGRATION_DONE but no types specified."; | 89 << "MIGRATION_DONE but no types specified."; |
| 90 syncable::ModelTypeSet to_migrate; | 90 syncable::ModelTypeSet to_migrate; |
| 91 for (int i = 0; i < response->migrated_data_type_id_size(); i++) { | 91 for (int i = 0; i < response->migrated_data_type_id_size(); i++) { |
| 92 to_migrate.insert(syncable::GetModelTypeFromExtensionFieldNumber( | 92 to_migrate.insert(syncable::GetModelTypeFromExtensionFieldNumber( |
| 93 response->migrated_data_type_id(i))); | 93 response->migrated_data_type_id(i))); |
| 94 } | 94 } |
| 95 // TODO(akalin): This should be a set union. | 95 // TODO(akalin): This should be a set union. |
| 96 session->status_controller()->set_types_needing_local_migration(to_migrate); | 96 session->mutable_status_controller()-> |
| 97 set_types_needing_local_migration(to_migrate); |
| 97 } | 98 } |
| 98 | 99 |
| 99 // static | 100 // static |
| 100 bool SyncerProtoUtil::VerifyResponseBirthday(syncable::Directory* dir, | 101 bool SyncerProtoUtil::VerifyResponseBirthday(syncable::Directory* dir, |
| 101 const ClientToServerResponse* response) { | 102 const ClientToServerResponse* response) { |
| 102 | 103 |
| 103 std::string local_birthday = dir->store_birthday(); | 104 std::string local_birthday = dir->store_birthday(); |
| 104 | 105 |
| 105 if (local_birthday.empty()) { | 106 if (local_birthday.empty()) { |
| 106 if (!response->has_store_birthday()) { | 107 if (!response->has_store_birthday()) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } else if (response->has_error()) { | 307 } else if (response->has_error()) { |
| 307 // This is a new server. Just get the error from the protocol. | 308 // This is a new server. Just get the error from the protocol. |
| 308 sync_protocol_error = ConvertErrorPBToLocalType(response->error()); | 309 sync_protocol_error = ConvertErrorPBToLocalType(response->error()); |
| 309 } else { | 310 } else { |
| 310 // Legacy server implementation. Compute the error based on |error_code|. | 311 // Legacy server implementation. Compute the error based on |error_code|. |
| 311 sync_protocol_error = ConvertLegacyErrorCodeToNewError( | 312 sync_protocol_error = ConvertLegacyErrorCodeToNewError( |
| 312 response->error_code()); | 313 response->error_code()); |
| 313 } | 314 } |
| 314 | 315 |
| 315 // Now set the error into the status so the layers above us could read it. | 316 // Now set the error into the status so the layers above us could read it. |
| 316 sessions::StatusController* status = session->status_controller(); | 317 sessions::StatusController* status = session->mutable_status_controller(); |
| 317 status->set_sync_protocol_error(sync_protocol_error); | 318 status->set_sync_protocol_error(sync_protocol_error); |
| 318 | 319 |
| 319 // Inform the delegate of the error we got. | 320 // Inform the delegate of the error we got. |
| 320 session->delegate()->OnSyncProtocolError(session->TakeSnapshot()); | 321 session->delegate()->OnSyncProtocolError(session->TakeSnapshot()); |
| 321 | 322 |
| 322 // Now do any special handling for the error type and decide on the return | 323 // Now do any special handling for the error type and decide on the return |
| 323 // value. | 324 // value. |
| 324 switch (sync_protocol_error.error_type) { | 325 switch (sync_protocol_error.error_type) { |
| 325 case browser_sync::UNKNOWN_ERROR: | 326 case browser_sync::UNKNOWN_ERROR: |
| 326 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more " | 327 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more " |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 std::string SyncerProtoUtil::ClientToServerResponseDebugString( | 472 std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
| 472 const sync_pb::ClientToServerResponse& response) { | 473 const sync_pb::ClientToServerResponse& response) { |
| 473 // Add more handlers as needed. | 474 // Add more handlers as needed. |
| 474 std::string output; | 475 std::string output; |
| 475 if (response.has_get_updates()) | 476 if (response.has_get_updates()) |
| 476 output.append(GetUpdatesResponseString(response.get_updates())); | 477 output.append(GetUpdatesResponseString(response.get_updates())); |
| 477 return output; | 478 return output; |
| 478 } | 479 } |
| 479 | 480 |
| 480 } // namespace browser_sync | 481 } // namespace browser_sync |
| OLD | NEW |