| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 import app_specifics_pb2 | 24 import app_specifics_pb2 |
| 25 import autofill_specifics_pb2 | 25 import autofill_specifics_pb2 |
| 26 import bookmark_specifics_pb2 | 26 import bookmark_specifics_pb2 |
| 27 import get_updates_caller_info_pb2 | 27 import get_updates_caller_info_pb2 |
| 28 import extension_setting_specifics_pb2 | 28 import extension_setting_specifics_pb2 |
| 29 import extension_specifics_pb2 | 29 import extension_specifics_pb2 |
| 30 import history_delete_directive_specifics_pb2 | 30 import history_delete_directive_specifics_pb2 |
| 31 import nigori_specifics_pb2 | 31 import nigori_specifics_pb2 |
| 32 import password_specifics_pb2 | 32 import password_specifics_pb2 |
| 33 import preference_specifics_pb2 | 33 import preference_specifics_pb2 |
| 34 import push_notification_specifics_pb2 |
| 34 import search_engine_specifics_pb2 | 35 import search_engine_specifics_pb2 |
| 35 import session_specifics_pb2 | 36 import session_specifics_pb2 |
| 36 import sync_pb2 | 37 import sync_pb2 |
| 37 import sync_enums_pb2 | 38 import sync_enums_pb2 |
| 38 import theme_specifics_pb2 | 39 import theme_specifics_pb2 |
| 39 import typed_url_specifics_pb2 | 40 import typed_url_specifics_pb2 |
| 40 | 41 |
| 41 # An enumeration of the various kinds of data that can be synced. | 42 # An enumeration of the various kinds of data that can be synced. |
| 42 # Over the wire, this enumeration is not used: a sync object's type is | 43 # Over the wire, this enumeration is not used: a sync object's type is |
| 43 # inferred by which EntitySpecifics field it has. But in the context | 44 # inferred by which EntitySpecifics field it has. But in the context |
| 44 # of a program, it is useful to have an enumeration. | 45 # of a program, it is useful to have an enumeration. |
| 45 ALL_TYPES = ( | 46 ALL_TYPES = ( |
| 46 TOP_LEVEL, # The type of the 'Google Chrome' folder. | 47 TOP_LEVEL, # The type of the 'Google Chrome' folder. |
| 47 APPS, | 48 APPS, |
| 48 APP_NOTIFICATION, | 49 APP_NOTIFICATION, |
| 49 APP_SETTINGS, | 50 APP_SETTINGS, |
| 50 AUTOFILL, | 51 AUTOFILL, |
| 51 AUTOFILL_PROFILE, | 52 AUTOFILL_PROFILE, |
| 52 BOOKMARK, | 53 BOOKMARK, |
| 53 DEVICE_INFO, | 54 DEVICE_INFO, |
| 54 EXPERIMENTS, | 55 EXPERIMENTS, |
| 55 EXTENSIONS, | 56 EXTENSIONS, |
| 56 HISTORY_DELETE_DIRECTIVE, | 57 HISTORY_DELETE_DIRECTIVE, |
| 57 NIGORI, | 58 NIGORI, |
| 58 PASSWORD, | 59 PASSWORD, |
| 59 PREFERENCE, | 60 PREFERENCE, |
| 61 PUSH_NOTIFICATIONS, |
| 60 SEARCH_ENGINE, | 62 SEARCH_ENGINE, |
| 61 SESSION, | 63 SESSION, |
| 62 THEME, | 64 THEME, |
| 63 TYPED_URL, | 65 TYPED_URL, |
| 64 EXTENSION_SETTINGS) = range(19) | 66 EXTENSION_SETTINGS) = range(20) |
| 65 | 67 |
| 66 # An eumeration on the frequency at which the server should send errors | 68 # An eumeration on the frequency at which the server should send errors |
| 67 # to the client. This would be specified by the url that triggers the error. | 69 # to the client. This would be specified by the url that triggers the error. |
| 68 # Note: This enum should be kept in the same order as the enum in sync_test.h. | 70 # Note: This enum should be kept in the same order as the enum in sync_test.h. |
| 69 SYNC_ERROR_FREQUENCY = ( | 71 SYNC_ERROR_FREQUENCY = ( |
| 70 ERROR_FREQUENCY_NONE, | 72 ERROR_FREQUENCY_NONE, |
| 71 ERROR_FREQUENCY_ALWAYS, | 73 ERROR_FREQUENCY_ALWAYS, |
| 72 ERROR_FREQUENCY_TWO_THIRDS) = range(3) | 74 ERROR_FREQUENCY_TWO_THIRDS) = range(3) |
| 73 | 75 |
| 74 # Well-known server tag of the top level 'Google Chrome' folder. | 76 # Well-known server tag of the top level 'Google Chrome' folder. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 85 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], | 87 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], |
| 86 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], | 88 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], |
| 87 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], | 89 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], |
| 88 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], | 90 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], |
| 89 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], | 91 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], |
| 90 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], | 92 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], |
| 91 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], | 93 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], |
| 92 NIGORI: SYNC_TYPE_FIELDS['nigori'], | 94 NIGORI: SYNC_TYPE_FIELDS['nigori'], |
| 93 PASSWORD: SYNC_TYPE_FIELDS['password'], | 95 PASSWORD: SYNC_TYPE_FIELDS['password'], |
| 94 PREFERENCE: SYNC_TYPE_FIELDS['preference'], | 96 PREFERENCE: SYNC_TYPE_FIELDS['preference'], |
| 97 PUSH_NOTIFICATIONS: SYNC_TYPE_FIELDS["push_notifications"], |
| 95 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], | 98 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], |
| 96 SESSION: SYNC_TYPE_FIELDS['session'], | 99 SESSION: SYNC_TYPE_FIELDS['session'], |
| 97 THEME: SYNC_TYPE_FIELDS['theme'], | 100 THEME: SYNC_TYPE_FIELDS['theme'], |
| 98 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], | 101 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], |
| 99 } | 102 } |
| 100 | 103 |
| 101 # The parent ID used to indicate a top-level node. | 104 # The parent ID used to indicate a top-level node. |
| 102 ROOT_ID = '0' | 105 ROOT_ID = '0' |
| 103 | 106 |
| 104 # Unix time epoch in struct_time format. The tuple corresponds to UTC Wednesday | 107 # Unix time epoch in struct_time format. The tuple corresponds to UTC Wednesday |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 PermanentItem('google_chrome_history_delete_directives', | 459 PermanentItem('google_chrome_history_delete_directives', |
| 457 name='History Delete Directives', | 460 name='History Delete Directives', |
| 458 parent_tag=ROOT_ID, | 461 parent_tag=ROOT_ID, |
| 459 sync_type=HISTORY_DELETE_DIRECTIVE), | 462 sync_type=HISTORY_DELETE_DIRECTIVE), |
| 460 PermanentItem('google_chrome_nigori', name='Nigori', | 463 PermanentItem('google_chrome_nigori', name='Nigori', |
| 461 parent_tag=ROOT_ID, sync_type=NIGORI), | 464 parent_tag=ROOT_ID, sync_type=NIGORI), |
| 462 PermanentItem('google_chrome_passwords', name='Passwords', | 465 PermanentItem('google_chrome_passwords', name='Passwords', |
| 463 parent_tag=ROOT_ID, sync_type=PASSWORD), | 466 parent_tag=ROOT_ID, sync_type=PASSWORD), |
| 464 PermanentItem('google_chrome_preferences', name='Preferences', | 467 PermanentItem('google_chrome_preferences', name='Preferences', |
| 465 parent_tag=ROOT_ID, sync_type=PREFERENCE), | 468 parent_tag=ROOT_ID, sync_type=PREFERENCE), |
| 469 PermanentItem('google_chrome_preferences', name='Push Notifications', |
| 470 parent_tag=ROOT_ID, sync_type=PREFERENCE), |
| 466 PermanentItem('google_chrome_search_engines', name='Search Engines', | 471 PermanentItem('google_chrome_search_engines', name='Search Engines', |
| 467 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), | 472 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), |
| 468 PermanentItem('google_chrome_sessions', name='Sessions', | 473 PermanentItem('google_chrome_sessions', name='Sessions', |
| 469 parent_tag=ROOT_ID, sync_type=SESSION), | 474 parent_tag=ROOT_ID, sync_type=SESSION), |
| 470 PermanentItem('google_chrome_themes', name='Themes', | 475 PermanentItem('google_chrome_themes', name='Themes', |
| 471 parent_tag=ROOT_ID, sync_type=THEME), | 476 parent_tag=ROOT_ID, sync_type=THEME), |
| 472 PermanentItem('google_chrome_typed_urls', name='Typed URLs', | 477 PermanentItem('google_chrome_typed_urls', name='Typed URLs', |
| 473 parent_tag=ROOT_ID, sync_type=TYPED_URL), | 478 parent_tag=ROOT_ID, sync_type=TYPED_URL), |
| 474 ] | 479 ] |
| 475 | 480 |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) | 1329 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) |
| 1325 | 1330 |
| 1326 update_response.changes_remaining = remaining | 1331 update_response.changes_remaining = remaining |
| 1327 for entry in entries: | 1332 for entry in entries: |
| 1328 reply = update_response.entries.add() | 1333 reply = update_response.entries.add() |
| 1329 reply.CopyFrom(entry) | 1334 reply.CopyFrom(entry) |
| 1330 update_sieve.SaveProgress(new_timestamp, update_response) | 1335 update_sieve.SaveProgress(new_timestamp, update_response) |
| 1331 | 1336 |
| 1332 if update_request.need_encryption_key: | 1337 if update_request.need_encryption_key: |
| 1333 update_response.encryption_key = self.account.GetKey() | 1338 update_response.encryption_key = self.account.GetKey() |
| OLD | NEW |