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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 import search_engine_specifics_pb2 | 49 import search_engine_specifics_pb2 |
50 import session_specifics_pb2 | 50 import session_specifics_pb2 |
51 import sync_pb2 | 51 import sync_pb2 |
52 import sync_enums_pb2 | 52 import sync_enums_pb2 |
53 import synced_notification_app_info_specifics_pb2 | 53 import synced_notification_app_info_specifics_pb2 |
54 import synced_notification_data_pb2 | 54 import synced_notification_data_pb2 |
55 import synced_notification_render_pb2 | 55 import synced_notification_render_pb2 |
56 import synced_notification_specifics_pb2 | 56 import synced_notification_specifics_pb2 |
57 import theme_specifics_pb2 | 57 import theme_specifics_pb2 |
58 import typed_url_specifics_pb2 | 58 import typed_url_specifics_pb2 |
| 59 import wifi_credential_specifics_pb2 |
59 | 60 |
60 # An enumeration of the various kinds of data that can be synced. | 61 # An enumeration of the various kinds of data that can be synced. |
61 # Over the wire, this enumeration is not used: a sync object's type is | 62 # Over the wire, this enumeration is not used: a sync object's type is |
62 # inferred by which EntitySpecifics field it has. But in the context | 63 # inferred by which EntitySpecifics field it has. But in the context |
63 # of a program, it is useful to have an enumeration. | 64 # of a program, it is useful to have an enumeration. |
64 ALL_TYPES = ( | 65 ALL_TYPES = ( |
65 TOP_LEVEL, # The type of the 'Google Chrome' folder. | 66 TOP_LEVEL, # The type of the 'Google Chrome' folder. |
66 APPS, | 67 APPS, |
67 APP_LIST, | 68 APP_LIST, |
68 APP_NOTIFICATION, | 69 APP_NOTIFICATION, |
(...skipping 16 matching lines...) Expand all Loading... |
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) = range(31) | 96 FAVICON_TRACKING, |
| 97 WIFI_CREDENTIAL) = range(32) |
96 | 98 |
97 # 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 |
98 # 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. |
99 # 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. |
100 SYNC_ERROR_FREQUENCY = ( | 102 SYNC_ERROR_FREQUENCY = ( |
101 ERROR_FREQUENCY_NONE, | 103 ERROR_FREQUENCY_NONE, |
102 ERROR_FREQUENCY_ALWAYS, | 104 ERROR_FREQUENCY_ALWAYS, |
103 ERROR_FREQUENCY_TWO_THIRDS) = range(3) | 105 ERROR_FREQUENCY_TWO_THIRDS) = range(3) |
104 | 106 |
105 # Well-known server tag of the top level 'Google Chrome' folder. | 107 # Well-known server tag of the top level 'Google Chrome' folder. |
(...skipping 28 matching lines...) Expand all Loading... |
134 PASSWORD: SYNC_TYPE_FIELDS['password'], | 136 PASSWORD: SYNC_TYPE_FIELDS['password'], |
135 PREFERENCE: SYNC_TYPE_FIELDS['preference'], | 137 PREFERENCE: SYNC_TYPE_FIELDS['preference'], |
136 PRIORITY_PREFERENCE: SYNC_TYPE_FIELDS['priority_preference'], | 138 PRIORITY_PREFERENCE: SYNC_TYPE_FIELDS['priority_preference'], |
137 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], | 139 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], |
138 SESSION: SYNC_TYPE_FIELDS['session'], | 140 SESSION: SYNC_TYPE_FIELDS['session'], |
139 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], | 141 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], |
140 SYNCED_NOTIFICATION_APP_INFO: | 142 SYNCED_NOTIFICATION_APP_INFO: |
141 SYNC_TYPE_FIELDS["synced_notification_app_info"], | 143 SYNC_TYPE_FIELDS["synced_notification_app_info"], |
142 THEME: SYNC_TYPE_FIELDS['theme'], | 144 THEME: SYNC_TYPE_FIELDS['theme'], |
143 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], | 145 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], |
| 146 WIFI_CREDENTIAL: SYNC_TYPE_FIELDS["wifi_credential"], |
144 } | 147 } |
145 | 148 |
146 # The parent ID used to indicate a top-level node. | 149 # The parent ID used to indicate a top-level node. |
147 ROOT_ID = '0' | 150 ROOT_ID = '0' |
148 | 151 |
149 # Unix time epoch +1 day in struct_time format. The tuple corresponds to | 152 # Unix time epoch +1 day in struct_time format. The tuple corresponds to |
150 # UTC Thursday Jan 2 1970, 00:00:00, non-dst. | 153 # UTC Thursday Jan 2 1970, 00:00:00, non-dst. |
151 # We have to add one day after start of epoch, since in timezones with positive | 154 # We have to add one day after start of epoch, since in timezones with positive |
152 # UTC offset time.mktime throws an OverflowError, | 155 # UTC offset time.mktime throws an OverflowError, |
153 # rather then returning negative number. | 156 # rather then returning negative number. |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 name='Synced Notification App Info', | 562 name='Synced Notification App Info', |
560 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION_APP_INFO), | 563 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION_APP_INFO), |
561 PermanentItem('google_chrome_search_engines', name='Search Engines', | 564 PermanentItem('google_chrome_search_engines', name='Search Engines', |
562 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), | 565 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), |
563 PermanentItem('google_chrome_sessions', name='Sessions', | 566 PermanentItem('google_chrome_sessions', name='Sessions', |
564 parent_tag=ROOT_ID, sync_type=SESSION), | 567 parent_tag=ROOT_ID, sync_type=SESSION), |
565 PermanentItem('google_chrome_themes', name='Themes', | 568 PermanentItem('google_chrome_themes', name='Themes', |
566 parent_tag=ROOT_ID, sync_type=THEME), | 569 parent_tag=ROOT_ID, sync_type=THEME), |
567 PermanentItem('google_chrome_typed_urls', name='Typed URLs', | 570 PermanentItem('google_chrome_typed_urls', name='Typed URLs', |
568 parent_tag=ROOT_ID, sync_type=TYPED_URL), | 571 parent_tag=ROOT_ID, sync_type=TYPED_URL), |
| 572 PermanentItem('google_chrome_wifi_credentials', name='WiFi Credentials', |
| 573 parent_tag=ROOT_ID, sync_type=WIFI_CREDENTIAL), |
569 PermanentItem('google_chrome_dictionary', name='Dictionary', | 574 PermanentItem('google_chrome_dictionary', name='Dictionary', |
570 parent_tag=ROOT_ID, sync_type=DICTIONARY), | 575 parent_tag=ROOT_ID, sync_type=DICTIONARY), |
571 PermanentItem('google_chrome_articles', name='Articles', | 576 PermanentItem('google_chrome_articles', name='Articles', |
572 parent_tag=ROOT_ID, sync_type=ARTICLE), | 577 parent_tag=ROOT_ID, sync_type=ARTICLE), |
573 ] | 578 ] |
574 | 579 |
575 def __init__(self): | 580 def __init__(self): |
576 # Monotonically increasing version number. The next object change will | 581 # Monotonically increasing version number. The next object change will |
577 # take on this value + 1. | 582 # take on this value + 1. |
578 self._version = 0 | 583 self._version = 0 |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 | 1752 |
1748 Args: | 1753 Args: |
1749 sessions_commit_delay_seconds: The desired sync delay time for sessions. | 1754 sessions_commit_delay_seconds: The desired sync delay time for sessions. |
1750 """ | 1755 """ |
1751 if not self._client_command: | 1756 if not self._client_command: |
1752 self._client_command = client_commands_pb2.ClientCommand() | 1757 self._client_command = client_commands_pb2.ClientCommand() |
1753 | 1758 |
1754 self._client_command.sessions_commit_delay_seconds = \ | 1759 self._client_command.sessions_commit_delay_seconds = \ |
1755 sessions_commit_delay_seconds | 1760 sessions_commit_delay_seconds |
1756 return self._client_command | 1761 return self._client_command |
OLD | NEW |