Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """An implementation of the server side of the Chromium sync protocol. | 5 """An implementation of the server side of the Chromium sync protocol. |
| 6 | 6 |
| 7 The details of the protocol are described mostly by comments in the protocol | 7 The details of the protocol are described mostly by comments in the protocol |
| 8 buffer definition at chrome/browser/sync/protocol/sync.proto. | 8 buffer definition at chrome/browser/sync/protocol/sync.proto. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import cgi | 11 import cgi |
| 12 import copy | 12 import copy |
| 13 import operator | 13 import operator |
| 14 import pickle | 14 import pickle |
| 15 import random | 15 import random |
| 16 import sys | 16 import sys |
| 17 import threading | 17 import threading |
| 18 import time | 18 import time |
| 19 import urlparse | 19 import urlparse |
| 20 | 20 |
| 21 import app_notification_specifics_pb2 | 21 import app_notification_specifics_pb2 |
| 22 import app_setting_specifics_pb2 | 22 import app_setting_specifics_pb2 |
| 23 import app_specifics_pb2 | 23 import app_specifics_pb2 |
| 24 import autofill_specifics_pb2 | 24 import autofill_specifics_pb2 |
| 25 import bookmark_specifics_pb2 | 25 import bookmark_specifics_pb2 |
| 26 import get_updates_caller_info_pb2 | |
| 26 import extension_setting_specifics_pb2 | 27 import extension_setting_specifics_pb2 |
| 27 import extension_specifics_pb2 | 28 import extension_specifics_pb2 |
| 28 import nigori_specifics_pb2 | 29 import nigori_specifics_pb2 |
| 29 import password_specifics_pb2 | 30 import password_specifics_pb2 |
| 30 import preference_specifics_pb2 | 31 import preference_specifics_pb2 |
| 31 import search_engine_specifics_pb2 | 32 import search_engine_specifics_pb2 |
| 32 import session_specifics_pb2 | 33 import session_specifics_pb2 |
| 33 import sync_pb2 | 34 import sync_pb2 |
| 34 import sync_enums_pb2 | 35 import sync_enums_pb2 |
| 35 import theme_specifics_pb2 | 36 import theme_specifics_pb2 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 raise DataTypeIdNotRecognized | 210 raise DataTypeIdNotRecognized |
| 210 | 211 |
| 211 | 212 |
| 212 def SyncTypeToString(data_type): | 213 def SyncTypeToString(data_type): |
| 213 """Formats a sync type enum (from ALL_TYPES) to a human-readable string.""" | 214 """Formats a sync type enum (from ALL_TYPES) to a human-readable string.""" |
| 214 return SYNC_TYPE_TO_DESCRIPTOR[data_type].name | 215 return SYNC_TYPE_TO_DESCRIPTOR[data_type].name |
| 215 | 216 |
| 216 | 217 |
| 217 def CallerInfoToString(caller_info_source): | 218 def CallerInfoToString(caller_info_source): |
| 218 """Formats a GetUpdatesSource enum value to a readable string.""" | 219 """Formats a GetUpdatesSource enum value to a readable string.""" |
| 219 return sync_pb2.GetUpdatesCallerInfo.DESCRIPTOR.enum_types_by_name[ | 220 return get_updates_caller_info_pb2.GetUpdatesCallerInfo \ |
|
tim (not reviewing)
2012/03/23 20:21:06
You can give out/Debug/run_testserver --sync-test
| |
| 220 'GetUpdatesSource'].values_by_number[caller_info_source].name | 221 .DESCRIPTOR.enum_types_by_name['GetUpdatesSource'] \ |
| 222 .values_by_number[caller_info_source].name | |
| 221 | 223 |
| 222 | 224 |
| 223 def ShortDatatypeListSummary(data_types): | 225 def ShortDatatypeListSummary(data_types): |
| 224 """Formats compactly a list of sync types (python enums) for human eyes. | 226 """Formats compactly a list of sync types (python enums) for human eyes. |
| 225 | 227 |
| 226 This function is intended for use by logging. If the list of datatypes | 228 This function is intended for use by logging. If the list of datatypes |
| 227 contains almost all of the values, the return value will be expressed | 229 contains almost all of the values, the return value will be expressed |
| 228 in terms of the datatypes that aren't set. | 230 in terms of the datatypes that aren't set. |
| 229 """ | 231 """ |
| 230 included = set(data_types) - set([TOP_LEVEL]) | 232 included = set(data_types) - set([TOP_LEVEL]) |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 | 1255 |
| 1254 update_sieve.CheckMigrationState() | 1256 update_sieve.CheckMigrationState() |
| 1255 | 1257 |
| 1256 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) | 1258 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) |
| 1257 | 1259 |
| 1258 update_response.changes_remaining = remaining | 1260 update_response.changes_remaining = remaining |
| 1259 for entry in entries: | 1261 for entry in entries: |
| 1260 reply = update_response.entries.add() | 1262 reply = update_response.entries.add() |
| 1261 reply.CopyFrom(entry) | 1263 reply.CopyFrom(entry) |
| 1262 update_sieve.SaveProgress(new_timestamp, update_response) | 1264 update_sieve.SaveProgress(new_timestamp, update_response) |
| OLD | NEW |