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

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

Issue 11445002: Sync user's custom spellcheck dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add server-side size limit tests Created 7 years, 11 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
OLDNEW
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
11 import cgi 11 import cgi
12 import copy 12 import copy
13 import operator 13 import operator
14 import pickle 14 import pickle
15 import random 15 import random
16 import string 16 import string
17 import sys 17 import sys
18 import threading 18 import threading
19 import time 19 import time
20 import urlparse 20 import urlparse
21 21
22 import app_notification_specifics_pb2 22 import app_notification_specifics_pb2
23 import app_setting_specifics_pb2 23 import app_setting_specifics_pb2
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 dictionary_specifics_pb2
27 import get_updates_caller_info_pb2 28 import get_updates_caller_info_pb2
28 import extension_setting_specifics_pb2 29 import extension_setting_specifics_pb2
29 import extension_specifics_pb2 30 import extension_specifics_pb2
30 import history_delete_directive_specifics_pb2 31 import history_delete_directive_specifics_pb2
31 import nigori_specifics_pb2 32 import nigori_specifics_pb2
32 import password_specifics_pb2 33 import password_specifics_pb2
33 import preference_specifics_pb2 34 import preference_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 synced_notification_specifics_pb2 39 import synced_notification_specifics_pb2
39 import theme_specifics_pb2 40 import theme_specifics_pb2
40 import typed_url_specifics_pb2 41 import typed_url_specifics_pb2
41 42
42 # An enumeration of the various kinds of data that can be synced. 43 # An enumeration of the various kinds of data that can be synced.
43 # Over the wire, this enumeration is not used: a sync object's type is 44 # Over the wire, this enumeration is not used: a sync object's type is
44 # inferred by which EntitySpecifics field it has. But in the context 45 # inferred by which EntitySpecifics field it has. But in the context
45 # of a program, it is useful to have an enumeration. 46 # of a program, it is useful to have an enumeration.
46 ALL_TYPES = ( 47 ALL_TYPES = (
47 TOP_LEVEL, # The type of the 'Google Chrome' folder. 48 TOP_LEVEL, # The type of the 'Google Chrome' folder.
48 APPS, 49 APPS,
49 APP_NOTIFICATION, 50 APP_NOTIFICATION,
50 APP_SETTINGS, 51 APP_SETTINGS,
51 AUTOFILL, 52 AUTOFILL,
52 AUTOFILL_PROFILE, 53 AUTOFILL_PROFILE,
53 BOOKMARK, 54 BOOKMARK,
54 DEVICE_INFO, 55 DEVICE_INFO,
56 DICTIONARY,
55 EXPERIMENTS, 57 EXPERIMENTS,
56 EXTENSIONS, 58 EXTENSIONS,
57 HISTORY_DELETE_DIRECTIVE, 59 HISTORY_DELETE_DIRECTIVE,
58 NIGORI, 60 NIGORI,
59 PASSWORD, 61 PASSWORD,
60 PREFERENCE, 62 PREFERENCE,
61 SEARCH_ENGINE, 63 SEARCH_ENGINE,
62 SESSION, 64 SESSION,
63 SYNCED_NOTIFICATION, 65 SYNCED_NOTIFICATION,
64 THEME, 66 THEME,
65 TYPED_URL, 67 TYPED_URL,
66 EXTENSION_SETTINGS) = range(20) 68 EXTENSION_SETTINGS) = range(21)
67 69
68 # An eumeration on the frequency at which the server should send errors 70 # An enumeration on the frequency at which the server should send errors
69 # to the client. This would be specified by the url that triggers the error. 71 # to the client. This would be specified by the url that triggers the error.
70 # Note: This enum should be kept in the same order as the enum in sync_test.h. 72 # Note: This enum should be kept in the same order as the enum in sync_test.h.
71 SYNC_ERROR_FREQUENCY = ( 73 SYNC_ERROR_FREQUENCY = (
72 ERROR_FREQUENCY_NONE, 74 ERROR_FREQUENCY_NONE,
73 ERROR_FREQUENCY_ALWAYS, 75 ERROR_FREQUENCY_ALWAYS,
74 ERROR_FREQUENCY_TWO_THIRDS) = range(3) 76 ERROR_FREQUENCY_TWO_THIRDS) = range(3)
75 77
76 # Well-known server tag of the top level 'Google Chrome' folder. 78 # Well-known server tag of the top level 'Google Chrome' folder.
77 TOP_LEVEL_FOLDER_TAG = 'google_chrome' 79 TOP_LEVEL_FOLDER_TAG = 'google_chrome'
78 80
79 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding 81 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding
80 # to that datatype. Note that TOP_LEVEL has no such token. 82 # to that datatype. Note that TOP_LEVEL has no such token.
81 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name 83 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name
82 SYNC_TYPE_TO_DESCRIPTOR = { 84 SYNC_TYPE_TO_DESCRIPTOR = {
83 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], 85 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'],
84 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], 86 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'],
85 APPS: SYNC_TYPE_FIELDS['app'], 87 APPS: SYNC_TYPE_FIELDS['app'],
86 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], 88 AUTOFILL: SYNC_TYPE_FIELDS['autofill'],
87 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], 89 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'],
88 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], 90 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'],
89 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], 91 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'],
92 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'],
90 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], 93 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'],
91 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], 94 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'],
92 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], 95 EXTENSIONS: SYNC_TYPE_FIELDS['extension'],
93 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], 96 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'],
94 NIGORI: SYNC_TYPE_FIELDS['nigori'], 97 NIGORI: SYNC_TYPE_FIELDS['nigori'],
95 PASSWORD: SYNC_TYPE_FIELDS['password'], 98 PASSWORD: SYNC_TYPE_FIELDS['password'],
96 PREFERENCE: SYNC_TYPE_FIELDS['preference'], 99 PREFERENCE: SYNC_TYPE_FIELDS['preference'],
97 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], 100 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'],
98 SESSION: SYNC_TYPE_FIELDS['session'], 101 SESSION: SYNC_TYPE_FIELDS['session'],
99 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], 102 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"],
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 PermanentItem('google_chrome_preferences', name='Synced Notifications', 478 PermanentItem('google_chrome_preferences', name='Synced Notifications',
476 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION), 479 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION),
477 PermanentItem('google_chrome_search_engines', name='Search Engines', 480 PermanentItem('google_chrome_search_engines', name='Search Engines',
478 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), 481 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE),
479 PermanentItem('google_chrome_sessions', name='Sessions', 482 PermanentItem('google_chrome_sessions', name='Sessions',
480 parent_tag=ROOT_ID, sync_type=SESSION), 483 parent_tag=ROOT_ID, sync_type=SESSION),
481 PermanentItem('google_chrome_themes', name='Themes', 484 PermanentItem('google_chrome_themes', name='Themes',
482 parent_tag=ROOT_ID, sync_type=THEME), 485 parent_tag=ROOT_ID, sync_type=THEME),
483 PermanentItem('google_chrome_typed_urls', name='Typed URLs', 486 PermanentItem('google_chrome_typed_urls', name='Typed URLs',
484 parent_tag=ROOT_ID, sync_type=TYPED_URL), 487 parent_tag=ROOT_ID, sync_type=TYPED_URL),
488 PermanentItem('google_chrome_dictionary', name='Dictionary',
489 parent_tag=ROOT_ID, sync_type=DICTIONARY),
485 ] 490 ]
486 491
487 def __init__(self): 492 def __init__(self):
488 # Monotonically increasing version number. The next object change will 493 # Monotonically increasing version number. The next object change will
489 # take on this value + 1. 494 # take on this value + 1.
490 self._version = 0 495 self._version = 0
491 496
492 # The definitive copy of this client's items: a map from ID string to a 497 # The definitive copy of this client's items: a map from ID string to a
493 # SyncEntity protocol buffer. 498 # SyncEntity protocol buffer.
494 self._entries = {} 499 self._entries = {}
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 sending_nigori_node = False 1367 sending_nigori_node = False
1363 for entry in entries: 1368 for entry in entries:
1364 if entry.name == 'Nigori': 1369 if entry.name == 'Nigori':
1365 sending_nigori_node = True 1370 sending_nigori_node = True
1366 reply = update_response.entries.add() 1371 reply = update_response.entries.add()
1367 reply.CopyFrom(entry) 1372 reply.CopyFrom(entry)
1368 update_sieve.SaveProgress(new_timestamp, update_response) 1373 update_sieve.SaveProgress(new_timestamp, update_response)
1369 1374
1370 if update_request.need_encryption_key or sending_nigori_node: 1375 if update_request.need_encryption_key or sending_nigori_node:
1371 update_response.encryption_keys.extend(self.account.GetKeystoreKeys()) 1376 update_response.encryption_keys.extend(self.account.GetKeystoreKeys())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698