Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: sync/tools/testserver/chromiumsync.py

Issue 143973006: New Sync datatype for Synced Notifications App Info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AppInfo: Rename fields in protobuf to match code better. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 import managed_user_specifics_pb2 42 import managed_user_specifics_pb2
43 import managed_user_shared_setting_specifics_pb2 43 import managed_user_shared_setting_specifics_pb2
44 import nigori_specifics_pb2 44 import nigori_specifics_pb2
45 import password_specifics_pb2 45 import password_specifics_pb2
46 import preference_specifics_pb2 46 import preference_specifics_pb2
47 import priority_preference_specifics_pb2 47 import priority_preference_specifics_pb2
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_data_pb2 53 import synced_notification_data_pb2
53 import synced_notification_render_pb2 54 import synced_notification_render_pb2
54 import synced_notification_specifics_pb2 55 import synced_notification_specifics_pb2
55 import theme_specifics_pb2 56 import theme_specifics_pb2
56 import typed_url_specifics_pb2 57 import typed_url_specifics_pb2
57 58
58 # An enumeration of the various kinds of data that can be synced. 59 # An enumeration of the various kinds of data that can be synced.
59 # Over the wire, this enumeration is not used: a sync object's type is 60 # Over the wire, this enumeration is not used: a sync object's type is
60 # inferred by which EntitySpecifics field it has. But in the context 61 # inferred by which EntitySpecifics field it has. But in the context
61 # of a program, it is useful to have an enumeration. 62 # of a program, it is useful to have an enumeration.
(...skipping 15 matching lines...) Expand all
77 MANAGED_USER_SETTING, 78 MANAGED_USER_SETTING,
78 MANAGED_USER_SHARED_SETTING, 79 MANAGED_USER_SHARED_SETTING,
79 MANAGED_USER, 80 MANAGED_USER,
80 NIGORI, 81 NIGORI,
81 PASSWORD, 82 PASSWORD,
82 PREFERENCE, 83 PREFERENCE,
83 PRIORITY_PREFERENCE, 84 PRIORITY_PREFERENCE,
84 SEARCH_ENGINE, 85 SEARCH_ENGINE,
85 SESSION, 86 SESSION,
86 SYNCED_NOTIFICATION, 87 SYNCED_NOTIFICATION,
88 SYNCED_NOTIFICATION_APP_INFO,
87 THEME, 89 THEME,
88 TYPED_URL, 90 TYPED_URL,
89 EXTENSION_SETTINGS, 91 EXTENSION_SETTINGS,
90 FAVICON_IMAGES, 92 FAVICON_IMAGES,
91 FAVICON_TRACKING) = range(29) 93 FAVICON_TRACKING) = range(30)
92 94
93 # An enumeration on the frequency at which the server should send errors 95 # An enumeration on the frequency at which the server should send errors
94 # to the client. This would be specified by the url that triggers the error. 96 # to the client. This would be specified by the url that triggers the error.
95 # Note: This enum should be kept in the same order as the enum in sync_test.h. 97 # Note: This enum should be kept in the same order as the enum in sync_test.h.
96 SYNC_ERROR_FREQUENCY = ( 98 SYNC_ERROR_FREQUENCY = (
97 ERROR_FREQUENCY_NONE, 99 ERROR_FREQUENCY_NONE,
98 ERROR_FREQUENCY_ALWAYS, 100 ERROR_FREQUENCY_ALWAYS,
99 ERROR_FREQUENCY_TWO_THIRDS) = range(3) 101 ERROR_FREQUENCY_TWO_THIRDS) = range(3)
100 102
101 # Well-known server tag of the top level 'Google Chrome' folder. 103 # Well-known server tag of the top level 'Google Chrome' folder.
(...skipping 23 matching lines...) Expand all
125 SYNC_TYPE_FIELDS['managed_user_shared_setting'], 127 SYNC_TYPE_FIELDS['managed_user_shared_setting'],
126 MANAGED_USER_SETTING: SYNC_TYPE_FIELDS['managed_user_setting'], 128 MANAGED_USER_SETTING: SYNC_TYPE_FIELDS['managed_user_setting'],
127 MANAGED_USER: SYNC_TYPE_FIELDS['managed_user'], 129 MANAGED_USER: SYNC_TYPE_FIELDS['managed_user'],
128 NIGORI: SYNC_TYPE_FIELDS['nigori'], 130 NIGORI: SYNC_TYPE_FIELDS['nigori'],
129 PASSWORD: SYNC_TYPE_FIELDS['password'], 131 PASSWORD: SYNC_TYPE_FIELDS['password'],
130 PREFERENCE: SYNC_TYPE_FIELDS['preference'], 132 PREFERENCE: SYNC_TYPE_FIELDS['preference'],
131 PRIORITY_PREFERENCE: SYNC_TYPE_FIELDS['priority_preference'], 133 PRIORITY_PREFERENCE: SYNC_TYPE_FIELDS['priority_preference'],
132 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], 134 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'],
133 SESSION: SYNC_TYPE_FIELDS['session'], 135 SESSION: SYNC_TYPE_FIELDS['session'],
134 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], 136 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"],
137 SYNCED_NOTIFICATION_APP_INFO:
138 SYNC_TYPE_FIELDS["synced_notification_app_info"],
135 THEME: SYNC_TYPE_FIELDS['theme'], 139 THEME: SYNC_TYPE_FIELDS['theme'],
136 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], 140 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'],
137 } 141 }
138 142
139 # The parent ID used to indicate a top-level node. 143 # The parent ID used to indicate a top-level node.
140 ROOT_ID = '0' 144 ROOT_ID = '0'
141 145
142 # Unix time epoch +1 day in struct_time format. The tuple corresponds to 146 # Unix time epoch +1 day in struct_time format. The tuple corresponds to
143 # UTC Thursday Jan 2 1970, 00:00:00, non-dst. 147 # UTC Thursday Jan 2 1970, 00:00:00, non-dst.
144 # We have to add one day after start of epoch, since in timezones with positive 148 # We have to add one day after start of epoch, since in timezones with positive
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 PermanentItem('google_chrome_passwords', name='Passwords', 542 PermanentItem('google_chrome_passwords', name='Passwords',
539 parent_tag=ROOT_ID, sync_type=PASSWORD), 543 parent_tag=ROOT_ID, sync_type=PASSWORD),
540 PermanentItem('google_chrome_preferences', name='Preferences', 544 PermanentItem('google_chrome_preferences', name='Preferences',
541 parent_tag=ROOT_ID, sync_type=PREFERENCE), 545 parent_tag=ROOT_ID, sync_type=PREFERENCE),
542 PermanentItem('google_chrome_priority_preferences', 546 PermanentItem('google_chrome_priority_preferences',
543 name='Priority Preferences', 547 name='Priority Preferences',
544 parent_tag=ROOT_ID, sync_type=PRIORITY_PREFERENCE), 548 parent_tag=ROOT_ID, sync_type=PRIORITY_PREFERENCE),
545 PermanentItem('google_chrome_synced_notifications', 549 PermanentItem('google_chrome_synced_notifications',
546 name='Synced Notifications', 550 name='Synced Notifications',
547 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION), 551 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION),
552 PermanentItem('google_chrome_synced_notification_app_info',
553 name='Synced Notification App Info',
554 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION_APP_INFO),
548 PermanentItem('google_chrome_search_engines', name='Search Engines', 555 PermanentItem('google_chrome_search_engines', name='Search Engines',
549 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), 556 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE),
550 PermanentItem('google_chrome_sessions', name='Sessions', 557 PermanentItem('google_chrome_sessions', name='Sessions',
551 parent_tag=ROOT_ID, sync_type=SESSION), 558 parent_tag=ROOT_ID, sync_type=SESSION),
552 PermanentItem('google_chrome_themes', name='Themes', 559 PermanentItem('google_chrome_themes', name='Themes',
553 parent_tag=ROOT_ID, sync_type=THEME), 560 parent_tag=ROOT_ID, sync_type=THEME),
554 PermanentItem('google_chrome_typed_urls', name='Typed URLs', 561 PermanentItem('google_chrome_typed_urls', name='Typed URLs',
555 parent_tag=ROOT_ID, sync_type=TYPED_URL), 562 parent_tag=ROOT_ID, sync_type=TYPED_URL),
556 PermanentItem('google_chrome_dictionary', name='Dictionary', 563 PermanentItem('google_chrome_dictionary', name='Dictionary',
557 parent_tag=ROOT_ID, sync_type=DICTIONARY), 564 parent_tag=ROOT_ID, sync_type=DICTIONARY),
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 coalesced.key = unique_id 1224 coalesced.key = unique_id
1218 1225
1219 specifics = sync_pb2.EntitySpecifics() 1226 specifics = sync_pb2.EntitySpecifics()
1220 notification_specifics = \ 1227 notification_specifics = \
1221 synced_notification_specifics_pb2.SyncedNotificationSpecifics() 1228 synced_notification_specifics_pb2.SyncedNotificationSpecifics()
1222 notification_specifics.coalesced_notification.CopyFrom(coalesced) 1229 notification_specifics.coalesced_notification.CopyFrom(coalesced)
1223 specifics.synced_notification.CopyFrom(notification_specifics) 1230 specifics.synced_notification.CopyFrom(notification_specifics)
1224 1231
1225 return specifics 1232 return specifics
1226 1233
1227
1228 def _CreateSyncedNotificationClientTag(self, key): 1234 def _CreateSyncedNotificationClientTag(self, key):
1229 """Create the client_defined_unique_tag value for a SyncedNotification. 1235 """Create the client_defined_unique_tag value for a SyncedNotification.
1230 1236
1231 Args: 1237 Args:
1232 key: The entity used to create the client tag. 1238 key: The entity used to create the client tag.
1233 1239
1234 Returns: 1240 Returns:
1235 The string value of the to be used as the client_defined_unique_tag. 1241 The string value of the to be used as the client_defined_unique_tag.
1236 """ 1242 """
1237 serialized_type = sync_pb2.EntitySpecifics() 1243 serialized_type = sync_pb2.EntitySpecifics()
1238 specifics = synced_notification_specifics_pb2.SyncedNotificationSpecifics() 1244 specifics = synced_notification_specifics_pb2.SyncedNotificationSpecifics()
1239 serialized_type.synced_notification.CopyFrom(specifics) 1245 serialized_type.synced_notification.CopyFrom(specifics)
1240 hash_input = serialized_type.SerializeToString() + key 1246 hash_input = serialized_type.SerializeToString() + key
1241 return base64.b64encode(hashlib.sha1(hash_input).digest()) 1247 return base64.b64encode(hashlib.sha1(hash_input).digest())
1242 1248
1243
1244 class TestServer(object): 1249 class TestServer(object):
1245 """An object to handle requests for one (and only one) Chrome Sync account. 1250 """An object to handle requests for one (and only one) Chrome Sync account.
1246 1251
1247 TestServer consumes the sync command messages that are the outermost 1252 TestServer consumes the sync command messages that are the outermost
1248 layers of the protocol, performs the corresponding actions on its 1253 layers of the protocol, performs the corresponding actions on its
1249 SyncDataModel, and constructs an appropriate response message. 1254 SyncDataModel, and constructs an appropriate response message.
1250 """ 1255 """
1251 1256
1252 def __init__(self): 1257 def __init__(self):
1253 # The implementation supports exactly one account; its state is here. 1258 # The implementation supports exactly one account; its state is here.
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 1646
1642 Args: 1647 Args:
1643 sessions_commit_delay_seconds: The desired sync delay time for sessions. 1648 sessions_commit_delay_seconds: The desired sync delay time for sessions.
1644 """ 1649 """
1645 if not self._client_command: 1650 if not self._client_command:
1646 self._client_command = client_commands_pb2.ClientCommand() 1651 self._client_command = client_commands_pb2.ClientCommand()
1647 1652
1648 self._client_command.sessions_commit_delay_seconds = \ 1653 self._client_command.sessions_commit_delay_seconds = \
1649 sessions_commit_delay_seconds 1654 sessions_commit_delay_seconds
1650 return self._client_command 1655 return self._client_command
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698