| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/auth_watcher.h" | 9 #include "chrome/browser/sync/engine/auth_watcher.h" |
| 10 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 10 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| 79 | 79 |
| 80 // static | 80 // static |
| 81 bool SyncerProtoUtil::VerifyResponseBirthday(syncable::Directory* dir, | 81 bool SyncerProtoUtil::VerifyResponseBirthday(syncable::Directory* dir, |
| 82 const ClientToServerResponse* response) { | 82 const ClientToServerResponse* response) { |
| 83 | 83 |
| 84 std::string local_birthday = dir->store_birthday(); | 84 std::string local_birthday = dir->store_birthday(); |
| 85 | 85 |
| 86 // TODO(tim): Bug 46807. Check for new response code denoting a clear store |
| 87 // operation is in progress. |
| 88 |
| 86 if (local_birthday.empty()) { | 89 if (local_birthday.empty()) { |
| 87 if (!response->has_store_birthday()) { | 90 if (!response->has_store_birthday()) { |
| 88 LOG(WARNING) << "Expected a birthday on first sync."; | 91 LOG(WARNING) << "Expected a birthday on first sync."; |
| 89 return false; | 92 return false; |
| 90 } | 93 } |
| 91 | 94 |
| 92 LOG(INFO) << "New store birthday: " << response->store_birthday(); | 95 LOG(INFO) << "New store birthday: " << response->store_birthday(); |
| 93 dir->set_store_birthday(response->store_birthday()); | 96 dir->set_store_birthday(response->store_birthday()); |
| 94 return true; | 97 return true; |
| 95 } | 98 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 session->context()->auth_watcher(), | 185 session->context()->auth_watcher(), |
| 183 msg, | 186 msg, |
| 184 response)) { | 187 response)) { |
| 185 return false; | 188 return false; |
| 186 } | 189 } |
| 187 | 190 |
| 188 if (!VerifyResponseBirthday(dir, response)) { | 191 if (!VerifyResponseBirthday(dir, response)) { |
| 189 // TODO(ncarter): Add a unit test for the case where the syncer becomes | 192 // TODO(ncarter): Add a unit test for the case where the syncer becomes |
| 190 // stuck due to a bad birthday. | 193 // stuck due to a bad birthday. |
| 191 session->status_controller()->set_syncer_stuck(true); | 194 session->status_controller()->set_syncer_stuck(true); |
| 195 session->delegate()->OnShouldStopSyncingPermanently(); |
| 192 return false; | 196 return false; |
| 193 } | 197 } |
| 194 | 198 |
| 195 switch (response->error_code()) { | 199 switch (response->error_code()) { |
| 196 case ClientToServerResponse::SUCCESS: | 200 case ClientToServerResponse::SUCCESS: |
| 197 LogResponseProfilingData(*response); | 201 LogResponseProfilingData(*response); |
| 198 return true; | 202 return true; |
| 199 case ClientToServerResponse::NOT_MY_BIRTHDAY: | |
| 200 LOG(WARNING) << "Server thought we had wrong birthday."; | |
| 201 return false; | |
| 202 case ClientToServerResponse::THROTTLED: | 203 case ClientToServerResponse::THROTTLED: |
| 203 LOG(WARNING) << "Client silenced by server."; | 204 LOG(WARNING) << "Client silenced by server."; |
| 204 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + | 205 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + |
| 205 base::TimeDelta::FromSeconds(kSyncDelayAfterThrottled)); | 206 base::TimeDelta::FromSeconds(kSyncDelayAfterThrottled)); |
| 206 return false; | 207 return false; |
| 207 case ClientToServerResponse::USER_NOT_ACTIVATED: | 208 case ClientToServerResponse::USER_NOT_ACTIVATED: |
| 208 case ClientToServerResponse::AUTH_INVALID: | 209 case ClientToServerResponse::AUTH_INVALID: |
| 209 case ClientToServerResponse::ACCESS_DENIED: | 210 case ClientToServerResponse::ACCESS_DENIED: |
| 210 // WARNING: PostAndProcessHeaders contains a hack for this case. | 211 // WARNING: PostAndProcessHeaders contains a hack for this case. |
| 211 LOG(WARNING) << "SyncerProtoUtil: Authentication expired."; | 212 LOG(WARNING) << "SyncerProtoUtil: Authentication expired."; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 const sync_pb::ClientToServerResponse& response) { | 342 const sync_pb::ClientToServerResponse& response) { |
| 342 // Add more handlers as needed. | 343 // Add more handlers as needed. |
| 343 std::string output; | 344 std::string output; |
| 344 if (response.has_get_updates()) { | 345 if (response.has_get_updates()) { |
| 345 output.append(GetUpdatesResponseString(response.get_updates())); | 346 output.append(GetUpdatesResponseString(response.get_updates())); |
| 346 } | 347 } |
| 347 return output; | 348 return output; |
| 348 } | 349 } |
| 349 | 350 |
| 350 } // namespace browser_sync | 351 } // namespace browser_sync |
| OLD | NEW |