| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """An implementation of the server side of the Chromium sync protocol. | 6 """An implementation of the server side of the Chromium sync protocol. |
| 7 | 7 |
| 8 The details of the protocol are described mostly by comments in the protocol | 8 The details of the protocol are described mostly by comments in the protocol |
| 9 buffer definition at chrome/browser/sync/protocol/sync.proto. | 9 buffer definition at chrome/browser/sync/protocol/sync.proto. |
| 10 """ | 10 """ |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 self.account.error.error_description = '' | 978 self.account.error.error_description = '' |
| 979 response = ('Error = %d, action = %d, url = %s, description = %s' % | 979 response = ('Error = %d, action = %d, url = %s, description = %s' % |
| 980 (self.account.error.error_type, self.account.error.action, | 980 (self.account.error.error_type, self.account.error.action, |
| 981 self.account.error.url, | 981 self.account.error.url, |
| 982 self.account.error.error_description)) | 982 self.account.error.error_description)) |
| 983 except error: | 983 except error: |
| 984 response = 'Could not parse url' | 984 response = 'Could not parse url' |
| 985 code = 400 | 985 code = 400 |
| 986 finally: | 986 finally: |
| 987 self.account_lock.release() | 987 self.account_lock.release() |
| 988 return (code, '<html><title>Migration: %d</title><H1>%d %s</H1></html>' % | 988 return (code, '<html><title>SetError: %d</title><H1>%d %s</H1></html>' % |
| 989 (code, code, response)) | 989 (code, code, response)) |
| 990 | 990 |
| 991 def HandleCreateBirthdayError(self): | 991 def HandleCreateBirthdayError(self): |
| 992 self.account.ResetStoreBirthday() | 992 self.account.ResetStoreBirthday() |
| 993 return ( | 993 return ( |
| 994 200, | 994 200, |
| 995 '<html><title>Birthday error</title><H1>Birthday error</H1></html>') | 995 '<html><title>Birthday error</title><H1>Birthday error</H1></html>') |
| 996 | 996 |
| 997 def HandleSetTransientError(self): | 997 def HandleSetTransientError(self): |
| 998 self.transient_error = True | 998 self.transient_error = True |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 print_context('<-') | 1079 print_context('<-') |
| 1080 print 'TRANSIENT_ERROR' | 1080 print 'TRANSIENT_ERROR' |
| 1081 response.store_birthday = self.account.store_birthday | 1081 response.store_birthday = self.account.store_birthday |
| 1082 response.error_code = sync_pb2.ClientToServerResponse.TRANSIENT_ERROR | 1082 response.error_code = sync_pb2.ClientToServerResponse.TRANSIENT_ERROR |
| 1083 return (200, response.SerializeToString()) | 1083 return (200, response.SerializeToString()) |
| 1084 except SyncError, error: | 1084 except SyncError, error: |
| 1085 print_context('<-') | 1085 print_context('<-') |
| 1086 print 'ERROR' | 1086 print 'ERROR' |
| 1087 response.store_birthday = self.account.store_birthday | 1087 response.store_birthday = self.account.store_birthday |
| 1088 response.error.error_type = self.account.error.error_type | 1088 response.error.error_type = self.account.error.error_type |
| 1089 response.error.url = self.account.url | 1089 response.error.url = self.account.error.url |
| 1090 response.error.error_description = self.account.error_description | 1090 response.error.error_description = self.account.error.error_description |
| 1091 response.error.action = self.account.error.action | 1091 response.error.action = self.account.error.action |
| 1092 return (200, response.SerializeToString()) | 1092 return (200, response.SerializeToString()) |
| 1093 finally: | 1093 finally: |
| 1094 self.account_lock.release() | 1094 self.account_lock.release() |
| 1095 | 1095 |
| 1096 def HandleCommit(self, commit_message, commit_response): | 1096 def HandleCommit(self, commit_message, commit_response): |
| 1097 """Respond to a Commit request by updating the user's account state. | 1097 """Respond to a Commit request by updating the user's account state. |
| 1098 | 1098 |
| 1099 Commit attempts stop after the first error, returning a CONFLICT result | 1099 Commit attempts stop after the first error, returning a CONFLICT result |
| 1100 for any unattempted entries. | 1100 for any unattempted entries. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 | 1157 |
| 1158 update_sieve.CheckMigrationState() | 1158 update_sieve.CheckMigrationState() |
| 1159 | 1159 |
| 1160 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) | 1160 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) |
| 1161 | 1161 |
| 1162 update_response.changes_remaining = remaining | 1162 update_response.changes_remaining = remaining |
| 1163 for entry in entries: | 1163 for entry in entries: |
| 1164 reply = update_response.entries.add() | 1164 reply = update_response.entries.add() |
| 1165 reply.CopyFrom(entry) | 1165 reply.CopyFrom(entry) |
| 1166 update_sieve.SaveProgress(new_timestamp, update_response) | 1166 update_sieve.SaveProgress(new_timestamp, update_response) |
| OLD | NEW |