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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 import search_engine_specifics_pb2 | 48 import search_engine_specifics_pb2 |
49 import session_specifics_pb2 | 49 import session_specifics_pb2 |
50 import sync_pb2 | 50 import sync_pb2 |
51 import sync_enums_pb2 | 51 import sync_enums_pb2 |
52 import synced_notification_app_info_specifics_pb2 | 52 import synced_notification_app_info_specifics_pb2 |
53 import synced_notification_data_pb2 | 53 import synced_notification_data_pb2 |
54 import synced_notification_render_pb2 | 54 import synced_notification_render_pb2 |
55 import synced_notification_specifics_pb2 | 55 import synced_notification_specifics_pb2 |
56 import theme_specifics_pb2 | 56 import theme_specifics_pb2 |
57 import typed_url_specifics_pb2 | 57 import typed_url_specifics_pb2 |
| 58 import wifi_credential_specifics_pb2 |
58 | 59 |
59 # An enumeration of the various kinds of data that can be synced. | 60 # An enumeration of the various kinds of data that can be synced. |
60 # Over the wire, this enumeration is not used: a sync object's type is | 61 # Over the wire, this enumeration is not used: a sync object's type is |
61 # inferred by which EntitySpecifics field it has. But in the context | 62 # inferred by which EntitySpecifics field it has. But in the context |
62 # of a program, it is useful to have an enumeration. | 63 # of a program, it is useful to have an enumeration. |
63 ALL_TYPES = ( | 64 ALL_TYPES = ( |
64 TOP_LEVEL, # The type of the 'Google Chrome' folder. | 65 TOP_LEVEL, # The type of the 'Google Chrome' folder. |
65 APPS, | 66 APPS, |
66 APP_LIST, | 67 APP_LIST, |
67 APP_NOTIFICATION, | 68 APP_NOTIFICATION, |
(...skipping 15 matching lines...) Expand all Loading... |
83 PREFERENCE, | 84 PREFERENCE, |
84 PRIORITY_PREFERENCE, | 85 PRIORITY_PREFERENCE, |
85 SEARCH_ENGINE, | 86 SEARCH_ENGINE, |
86 SESSION, | 87 SESSION, |
87 SYNCED_NOTIFICATION, | 88 SYNCED_NOTIFICATION, |
88 SYNCED_NOTIFICATION_APP_INFO, | 89 SYNCED_NOTIFICATION_APP_INFO, |
89 THEME, | 90 THEME, |
90 TYPED_URL, | 91 TYPED_URL, |
91 EXTENSION_SETTINGS, | 92 EXTENSION_SETTINGS, |
92 FAVICON_IMAGES, | 93 FAVICON_IMAGES, |
93 FAVICON_TRACKING) = range(30) | 94 FAVICON_TRACKING, |
| 95 WIFI_CREDENTIAL) = range(31) |
94 | 96 |
95 # An enumeration on the frequency at which the server should send errors | 97 # An enumeration on the frequency at which the server should send errors |
96 # to the client. This would be specified by the url that triggers the error. | 98 # to the client. This would be specified by the url that triggers the error. |
97 # Note: This enum should be kept in the same order as the enum in sync_test.h. | 99 # Note: This enum should be kept in the same order as the enum in sync_test.h. |
98 SYNC_ERROR_FREQUENCY = ( | 100 SYNC_ERROR_FREQUENCY = ( |
99 ERROR_FREQUENCY_NONE, | 101 ERROR_FREQUENCY_NONE, |
100 ERROR_FREQUENCY_ALWAYS, | 102 ERROR_FREQUENCY_ALWAYS, |
101 ERROR_FREQUENCY_TWO_THIRDS) = range(3) | 103 ERROR_FREQUENCY_TWO_THIRDS) = range(3) |
102 | 104 |
103 # Well-known server tag of the top level 'Google Chrome' folder. | 105 # Well-known server tag of the top level 'Google Chrome' folder. |
(...skipping 27 matching lines...) Expand all Loading... |
131 PASSWORD: SYNC_TYPE_FIELDS['password'], | 133 PASSWORD: SYNC_TYPE_FIELDS['password'], |
132 PREFERENCE: SYNC_TYPE_FIELDS['preference'], | 134 PREFERENCE: SYNC_TYPE_FIELDS['preference'], |
133 PRIORITY_PREFERENCE: SYNC_TYPE_FIELDS['priority_preference'], | 135 PRIORITY_PREFERENCE: SYNC_TYPE_FIELDS['priority_preference'], |
134 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], | 136 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], |
135 SESSION: SYNC_TYPE_FIELDS['session'], | 137 SESSION: SYNC_TYPE_FIELDS['session'], |
136 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], | 138 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], |
137 SYNCED_NOTIFICATION_APP_INFO: | 139 SYNCED_NOTIFICATION_APP_INFO: |
138 SYNC_TYPE_FIELDS["synced_notification_app_info"], | 140 SYNC_TYPE_FIELDS["synced_notification_app_info"], |
139 THEME: SYNC_TYPE_FIELDS['theme'], | 141 THEME: SYNC_TYPE_FIELDS['theme'], |
140 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], | 142 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], |
| 143 WIFI_CREDENTIAL: SYNC_TYPE_FIELDS["wifi_credential"], |
141 } | 144 } |
142 | 145 |
143 # The parent ID used to indicate a top-level node. | 146 # The parent ID used to indicate a top-level node. |
144 ROOT_ID = '0' | 147 ROOT_ID = '0' |
145 | 148 |
146 # Unix time epoch +1 day in struct_time format. The tuple corresponds to | 149 # Unix time epoch +1 day in struct_time format. The tuple corresponds to |
147 # UTC Thursday Jan 2 1970, 00:00:00, non-dst. | 150 # UTC Thursday Jan 2 1970, 00:00:00, non-dst. |
148 # We have to add one day after start of epoch, since in timezones with positive | 151 # We have to add one day after start of epoch, since in timezones with positive |
149 # UTC offset time.mktime throws an OverflowError, | 152 # UTC offset time.mktime throws an OverflowError, |
150 # rather then returning negative number. | 153 # rather then returning negative number. |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 name='Synced Notification App Info', | 556 name='Synced Notification App Info', |
554 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION_APP_INFO), | 557 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION_APP_INFO), |
555 PermanentItem('google_chrome_search_engines', name='Search Engines', | 558 PermanentItem('google_chrome_search_engines', name='Search Engines', |
556 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), | 559 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), |
557 PermanentItem('google_chrome_sessions', name='Sessions', | 560 PermanentItem('google_chrome_sessions', name='Sessions', |
558 parent_tag=ROOT_ID, sync_type=SESSION), | 561 parent_tag=ROOT_ID, sync_type=SESSION), |
559 PermanentItem('google_chrome_themes', name='Themes', | 562 PermanentItem('google_chrome_themes', name='Themes', |
560 parent_tag=ROOT_ID, sync_type=THEME), | 563 parent_tag=ROOT_ID, sync_type=THEME), |
561 PermanentItem('google_chrome_typed_urls', name='Typed URLs', | 564 PermanentItem('google_chrome_typed_urls', name='Typed URLs', |
562 parent_tag=ROOT_ID, sync_type=TYPED_URL), | 565 parent_tag=ROOT_ID, sync_type=TYPED_URL), |
| 566 PermanentItem('google_chrome_wifi_credentials', name='WiFi Credentials', |
| 567 parent_tag=ROOT_ID, sync_type=WIFI_CREDENTIAL), |
563 PermanentItem('google_chrome_dictionary', name='Dictionary', | 568 PermanentItem('google_chrome_dictionary', name='Dictionary', |
564 parent_tag=ROOT_ID, sync_type=DICTIONARY), | 569 parent_tag=ROOT_ID, sync_type=DICTIONARY), |
565 PermanentItem('google_chrome_articles', name='Articles', | 570 PermanentItem('google_chrome_articles', name='Articles', |
566 parent_tag=ROOT_ID, sync_type=ARTICLE), | 571 parent_tag=ROOT_ID, sync_type=ARTICLE), |
567 ] | 572 ] |
568 | 573 |
569 def __init__(self): | 574 def __init__(self): |
570 # Monotonically increasing version number. The next object change will | 575 # Monotonically increasing version number. The next object change will |
571 # take on this value + 1. | 576 # take on this value + 1. |
572 self._version = 0 | 577 self._version = 0 |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 | 1746 |
1742 Args: | 1747 Args: |
1743 sessions_commit_delay_seconds: The desired sync delay time for sessions. | 1748 sessions_commit_delay_seconds: The desired sync delay time for sessions. |
1744 """ | 1749 """ |
1745 if not self._client_command: | 1750 if not self._client_command: |
1746 self._client_command = client_commands_pb2.ClientCommand() | 1751 self._client_command = client_commands_pb2.ClientCommand() |
1747 | 1752 |
1748 self._client_command.sessions_commit_delay_seconds = \ | 1753 self._client_command.sessions_commit_delay_seconds = \ |
1749 sessions_commit_delay_seconds | 1754 sessions_commit_delay_seconds |
1750 return self._client_command | 1755 return self._client_command |
OLD | NEW |