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

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 browser tests for dictionary change notifications in settings Created 7 years, 12 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 theme_specifics_pb2 39 import theme_specifics_pb2
39 import typed_url_specifics_pb2 40 import typed_url_specifics_pb2
40 41
41 # An enumeration of the various kinds of data that can be synced. 42 # An enumeration of the various kinds of data that can be synced.
42 # Over the wire, this enumeration is not used: a sync object's type is 43 # Over the wire, this enumeration is not used: a sync object's type is
43 # inferred by which EntitySpecifics field it has. But in the context 44 # inferred by which EntitySpecifics field it has. But in the context
44 # of a program, it is useful to have an enumeration. 45 # of a program, it is useful to have an enumeration.
45 ALL_TYPES = ( 46 ALL_TYPES = (
46 TOP_LEVEL, # The type of the 'Google Chrome' folder. 47 TOP_LEVEL, # The type of the 'Google Chrome' folder.
47 APPS, 48 APPS,
48 APP_NOTIFICATION, 49 APP_NOTIFICATION,
49 APP_SETTINGS, 50 APP_SETTINGS,
50 AUTOFILL, 51 AUTOFILL,
51 AUTOFILL_PROFILE, 52 AUTOFILL_PROFILE,
52 BOOKMARK, 53 BOOKMARK,
53 DEVICE_INFO, 54 DEVICE_INFO,
55 DICTIONARY,
54 EXPERIMENTS, 56 EXPERIMENTS,
55 EXTENSIONS, 57 EXTENSIONS,
56 HISTORY_DELETE_DIRECTIVE, 58 HISTORY_DELETE_DIRECTIVE,
57 NIGORI, 59 NIGORI,
58 PASSWORD, 60 PASSWORD,
59 PREFERENCE, 61 PREFERENCE,
60 SEARCH_ENGINE, 62 SEARCH_ENGINE,
61 SESSION, 63 SESSION,
62 THEME, 64 THEME,
63 TYPED_URL, 65 TYPED_URL,
64 EXTENSION_SETTINGS) = range(19) 66 EXTENSION_SETTINGS) = range(20)
65 67
66 # An eumeration on the frequency at which the server should send errors 68 # An eumeration on the frequency at which the server should send errors
67 # to the client. This would be specified by the url that triggers the error. 69 # to the client. This would be specified by the url that triggers the error.
68 # Note: This enum should be kept in the same order as the enum in sync_test.h. 70 # Note: This enum should be kept in the same order as the enum in sync_test.h.
69 SYNC_ERROR_FREQUENCY = ( 71 SYNC_ERROR_FREQUENCY = (
70 ERROR_FREQUENCY_NONE, 72 ERROR_FREQUENCY_NONE,
71 ERROR_FREQUENCY_ALWAYS, 73 ERROR_FREQUENCY_ALWAYS,
72 ERROR_FREQUENCY_TWO_THIRDS) = range(3) 74 ERROR_FREQUENCY_TWO_THIRDS) = range(3)
73 75
74 # Well-known server tag of the top level 'Google Chrome' folder. 76 # Well-known server tag of the top level 'Google Chrome' folder.
75 TOP_LEVEL_FOLDER_TAG = 'google_chrome' 77 TOP_LEVEL_FOLDER_TAG = 'google_chrome'
76 78
77 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding 79 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding
78 # to that datatype. Note that TOP_LEVEL has no such token. 80 # to that datatype. Note that TOP_LEVEL has no such token.
79 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name 81 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name
80 SYNC_TYPE_TO_DESCRIPTOR = { 82 SYNC_TYPE_TO_DESCRIPTOR = {
81 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], 83 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'],
82 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], 84 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'],
83 APPS: SYNC_TYPE_FIELDS['app'], 85 APPS: SYNC_TYPE_FIELDS['app'],
84 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], 86 AUTOFILL: SYNC_TYPE_FIELDS['autofill'],
85 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], 87 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'],
86 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], 88 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'],
87 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], 89 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'],
90 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'],
88 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], 91 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'],
89 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], 92 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'],
90 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], 93 EXTENSIONS: SYNC_TYPE_FIELDS['extension'],
91 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], 94 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'],
92 NIGORI: SYNC_TYPE_FIELDS['nigori'], 95 NIGORI: SYNC_TYPE_FIELDS['nigori'],
93 PASSWORD: SYNC_TYPE_FIELDS['password'], 96 PASSWORD: SYNC_TYPE_FIELDS['password'],
94 PREFERENCE: SYNC_TYPE_FIELDS['preference'], 97 PREFERENCE: SYNC_TYPE_FIELDS['preference'],
95 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], 98 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'],
96 SESSION: SYNC_TYPE_FIELDS['session'], 99 SESSION: SYNC_TYPE_FIELDS['session'],
97 THEME: SYNC_TYPE_FIELDS['theme'], 100 THEME: SYNC_TYPE_FIELDS['theme'],
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 PermanentItem('google_chrome_preferences', name='Preferences', 473 PermanentItem('google_chrome_preferences', name='Preferences',
471 parent_tag=ROOT_ID, sync_type=PREFERENCE), 474 parent_tag=ROOT_ID, sync_type=PREFERENCE),
472 PermanentItem('google_chrome_search_engines', name='Search Engines', 475 PermanentItem('google_chrome_search_engines', name='Search Engines',
473 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), 476 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE),
474 PermanentItem('google_chrome_sessions', name='Sessions', 477 PermanentItem('google_chrome_sessions', name='Sessions',
475 parent_tag=ROOT_ID, sync_type=SESSION), 478 parent_tag=ROOT_ID, sync_type=SESSION),
476 PermanentItem('google_chrome_themes', name='Themes', 479 PermanentItem('google_chrome_themes', name='Themes',
477 parent_tag=ROOT_ID, sync_type=THEME), 480 parent_tag=ROOT_ID, sync_type=THEME),
478 PermanentItem('google_chrome_typed_urls', name='Typed URLs', 481 PermanentItem('google_chrome_typed_urls', name='Typed URLs',
479 parent_tag=ROOT_ID, sync_type=TYPED_URL), 482 parent_tag=ROOT_ID, sync_type=TYPED_URL),
483 PermanentItem('google_chrome_dictionary', name='Dictionary',
484 parent_tag=ROOT_ID, sync_type=DICTIONARY),
480 ] 485 ]
481 486
482 def __init__(self): 487 def __init__(self):
483 # Monotonically increasing version number. The next object change will 488 # Monotonically increasing version number. The next object change will
484 # take on this value + 1. 489 # take on this value + 1.
485 self._version = 0 490 self._version = 0
486 491
487 # The definitive copy of this client's items: a map from ID string to a 492 # The definitive copy of this client's items: a map from ID string to a
488 # SyncEntity protocol buffer. 493 # SyncEntity protocol buffer.
489 self._entries = {} 494 self._entries = {}
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 sending_nigori_node = False 1362 sending_nigori_node = False
1358 for entry in entries: 1363 for entry in entries:
1359 if entry.name == 'Nigori': 1364 if entry.name == 'Nigori':
1360 sending_nigori_node = True 1365 sending_nigori_node = True
1361 reply = update_response.entries.add() 1366 reply = update_response.entries.add()
1362 reply.CopyFrom(entry) 1367 reply.CopyFrom(entry)
1363 update_sieve.SaveProgress(new_timestamp, update_response) 1368 update_sieve.SaveProgress(new_timestamp, update_response)
1364 1369
1365 if update_request.need_encryption_key or sending_nigori_node: 1370 if update_request.need_encryption_key or sending_nigori_node:
1366 update_response.encryption_keys.extend(self.account.GetKeystoreKeys()) 1371 update_response.encryption_keys.extend(self.account.GetKeystoreKeys())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698