| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 # of a program, it is useful to have an enumeration. | 62 # of a program, it is useful to have an enumeration. |
| 63 ALL_TYPES = ( | 63 ALL_TYPES = ( |
| 64 TOP_LEVEL, # The type of the 'Google Chrome' folder. | 64 TOP_LEVEL, # The type of the 'Google Chrome' folder. |
| 65 APPS, | 65 APPS, |
| 66 APP_LIST, | 66 APP_LIST, |
| 67 APP_NOTIFICATION, | 67 APP_NOTIFICATION, |
| 68 APP_SETTINGS, | 68 APP_SETTINGS, |
| 69 ARTICLE, | 69 ARTICLE, |
| 70 AUTOFILL, | 70 AUTOFILL, |
| 71 AUTOFILL_PROFILE, | 71 AUTOFILL_PROFILE, |
| 72 AUTOFILL_WALLET, |
| 72 AUTOFILL_WALLET_METADATA, | 73 AUTOFILL_WALLET_METADATA, |
| 73 BOOKMARK, | 74 BOOKMARK, |
| 74 DEVICE_INFO, | 75 DEVICE_INFO, |
| 75 DICTIONARY, | 76 DICTIONARY, |
| 76 EXPERIMENTS, | 77 EXPERIMENTS, |
| 77 EXTENSIONS, | 78 EXTENSIONS, |
| 78 HISTORY_DELETE_DIRECTIVE, | 79 HISTORY_DELETE_DIRECTIVE, |
| 79 MANAGED_USER_SETTING, | 80 MANAGED_USER_SETTING, |
| 80 MANAGED_USER_SHARED_SETTING, | 81 MANAGED_USER_SHARED_SETTING, |
| 81 MANAGED_USER_WHITELIST, | 82 MANAGED_USER_WHITELIST, |
| 82 MANAGED_USER, | 83 MANAGED_USER, |
| 83 NIGORI, | 84 NIGORI, |
| 84 PASSWORD, | 85 PASSWORD, |
| 85 PREFERENCE, | 86 PREFERENCE, |
| 86 PRIORITY_PREFERENCE, | 87 PRIORITY_PREFERENCE, |
| 87 SEARCH_ENGINE, | 88 SEARCH_ENGINE, |
| 88 SESSION, | 89 SESSION, |
| 89 SYNCED_NOTIFICATION, | 90 SYNCED_NOTIFICATION, |
| 90 SYNCED_NOTIFICATION_APP_INFO, | 91 SYNCED_NOTIFICATION_APP_INFO, |
| 91 THEME, | 92 THEME, |
| 92 TYPED_URL, | 93 TYPED_URL, |
| 93 EXTENSION_SETTINGS, | 94 EXTENSION_SETTINGS, |
| 94 FAVICON_IMAGES, | 95 FAVICON_IMAGES, |
| 95 FAVICON_TRACKING, | 96 FAVICON_TRACKING, |
| 96 WIFI_CREDENTIAL) = range(33) | 97 WIFI_CREDENTIAL) = range(34) |
| 97 | 98 |
| 98 # An enumeration on the frequency at which the server should send errors | 99 # An enumeration on the frequency at which the server should send errors |
| 99 # to the client. This would be specified by the url that triggers the error. | 100 # to the client. This would be specified by the url that triggers the error. |
| 100 # Note: This enum should be kept in the same order as the enum in sync_test.h. | 101 # Note: This enum should be kept in the same order as the enum in sync_test.h. |
| 101 SYNC_ERROR_FREQUENCY = ( | 102 SYNC_ERROR_FREQUENCY = ( |
| 102 ERROR_FREQUENCY_NONE, | 103 ERROR_FREQUENCY_NONE, |
| 103 ERROR_FREQUENCY_ALWAYS, | 104 ERROR_FREQUENCY_ALWAYS, |
| 104 ERROR_FREQUENCY_TWO_THIRDS) = range(3) | 105 ERROR_FREQUENCY_TWO_THIRDS) = range(3) |
| 105 | 106 |
| 106 # Well-known server tag of the top level 'Google Chrome' folder. | 107 # Well-known server tag of the top level 'Google Chrome' folder. |
| 107 TOP_LEVEL_FOLDER_TAG = 'google_chrome' | 108 TOP_LEVEL_FOLDER_TAG = 'google_chrome' |
| 108 | 109 |
| 109 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding | 110 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding |
| 110 # to that datatype. Note that TOP_LEVEL has no such token. | 111 # to that datatype. Note that TOP_LEVEL has no such token. |
| 111 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name | 112 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name |
| 112 SYNC_TYPE_TO_DESCRIPTOR = { | 113 SYNC_TYPE_TO_DESCRIPTOR = { |
| 113 APP_LIST: SYNC_TYPE_FIELDS['app_list'], | 114 APP_LIST: SYNC_TYPE_FIELDS['app_list'], |
| 114 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], | 115 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], |
| 115 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], | 116 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], |
| 116 APPS: SYNC_TYPE_FIELDS['app'], | 117 APPS: SYNC_TYPE_FIELDS['app'], |
| 117 ARTICLE: SYNC_TYPE_FIELDS['article'], | 118 ARTICLE: SYNC_TYPE_FIELDS['article'], |
| 118 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], | 119 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], |
| 119 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], | 120 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], |
| 121 AUTOFILL_WALLET: SYNC_TYPE_FIELDS['autofill_wallet'], |
| 120 AUTOFILL_WALLET_METADATA: SYNC_TYPE_FIELDS['wallet_metadata'], | 122 AUTOFILL_WALLET_METADATA: SYNC_TYPE_FIELDS['wallet_metadata'], |
| 121 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], | 123 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], |
| 122 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], | 124 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], |
| 123 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'], | 125 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'], |
| 124 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], | 126 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], |
| 125 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], | 127 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], |
| 126 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], | 128 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], |
| 127 FAVICON_IMAGES: SYNC_TYPE_FIELDS['favicon_image'], | 129 FAVICON_IMAGES: SYNC_TYPE_FIELDS['favicon_image'], |
| 128 FAVICON_TRACKING: SYNC_TYPE_FIELDS['favicon_tracking'], | 130 FAVICON_TRACKING: SYNC_TYPE_FIELDS['favicon_tracking'], |
| 129 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], | 131 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), | 508 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), |
| 507 PermanentItem('other_bookmarks', name='Other Bookmarks', | 509 PermanentItem('other_bookmarks', name='Other Bookmarks', |
| 508 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), | 510 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), |
| 509 PermanentItem('synced_bookmarks', name='Synced Bookmarks', | 511 PermanentItem('synced_bookmarks', name='Synced Bookmarks', |
| 510 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK, | 512 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK, |
| 511 create_by_default=False), | 513 create_by_default=False), |
| 512 PermanentItem('google_chrome_autofill', name='Autofill', | 514 PermanentItem('google_chrome_autofill', name='Autofill', |
| 513 parent_tag=ROOT_ID, sync_type=AUTOFILL), | 515 parent_tag=ROOT_ID, sync_type=AUTOFILL), |
| 514 PermanentItem('google_chrome_autofill_profiles', name='Autofill Profiles', | 516 PermanentItem('google_chrome_autofill_profiles', name='Autofill Profiles', |
| 515 parent_tag=ROOT_ID, sync_type=AUTOFILL_PROFILE), | 517 parent_tag=ROOT_ID, sync_type=AUTOFILL_PROFILE), |
| 518 PermanentItem('google_chrome_autofill_wallet', |
| 519 name='Autofill Wallet Items', parent_tag=ROOT_ID, |
| 520 sync_type=AUTOFILL_WALLET), |
| 516 PermanentItem('google_chrome_autofill_wallet_metadata', | 521 PermanentItem('google_chrome_autofill_wallet_metadata', |
| 517 name='Autofill Wallet Metadata', parent_tag=ROOT_ID, | 522 name='Autofill Wallet Metadata', parent_tag=ROOT_ID, |
| 518 sync_type=AUTOFILL_WALLET_METADATA), | 523 sync_type=AUTOFILL_WALLET_METADATA), |
| 519 PermanentItem('google_chrome_device_info', name='Device Info', | 524 PermanentItem('google_chrome_device_info', name='Device Info', |
| 520 parent_tag=ROOT_ID, sync_type=DEVICE_INFO), | 525 parent_tag=ROOT_ID, sync_type=DEVICE_INFO), |
| 521 PermanentItem('google_chrome_experiments', name='Experiments', | 526 PermanentItem('google_chrome_experiments', name='Experiments', |
| 522 parent_tag=ROOT_ID, sync_type=EXPERIMENTS), | 527 parent_tag=ROOT_ID, sync_type=EXPERIMENTS), |
| 523 PermanentItem('google_chrome_extension_settings', | 528 PermanentItem('google_chrome_extension_settings', |
| 524 name='Extension Settings', | 529 name='Extension Settings', |
| 525 parent_tag=ROOT_ID, sync_type=EXTENSION_SETTINGS), | 530 parent_tag=ROOT_ID, sync_type=EXTENSION_SETTINGS), |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 | 1627 |
| 1623 Args: | 1628 Args: |
| 1624 sessions_commit_delay_seconds: The desired sync delay time for sessions. | 1629 sessions_commit_delay_seconds: The desired sync delay time for sessions. |
| 1625 """ | 1630 """ |
| 1626 if not self._client_command: | 1631 if not self._client_command: |
| 1627 self._client_command = client_commands_pb2.ClientCommand() | 1632 self._client_command = client_commands_pb2.ClientCommand() |
| 1628 | 1633 |
| 1629 self._client_command.sessions_commit_delay_seconds = \ | 1634 self._client_command.sessions_commit_delay_seconds = \ |
| 1630 sessions_commit_delay_seconds | 1635 sessions_commit_delay_seconds |
| 1631 return self._client_command | 1636 return self._client_command |
| OLD | NEW |