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

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: Created 8 years 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 PermanentItem('google_chrome_preferences', name='Preferences', 467 PermanentItem('google_chrome_preferences', name='Preferences',
465 parent_tag=ROOT_ID, sync_type=PREFERENCE), 468 parent_tag=ROOT_ID, sync_type=PREFERENCE),
466 PermanentItem('google_chrome_search_engines', name='Search Engines', 469 PermanentItem('google_chrome_search_engines', name='Search Engines',
467 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), 470 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE),
468 PermanentItem('google_chrome_sessions', name='Sessions', 471 PermanentItem('google_chrome_sessions', name='Sessions',
469 parent_tag=ROOT_ID, sync_type=SESSION), 472 parent_tag=ROOT_ID, sync_type=SESSION),
470 PermanentItem('google_chrome_themes', name='Themes', 473 PermanentItem('google_chrome_themes', name='Themes',
471 parent_tag=ROOT_ID, sync_type=THEME), 474 parent_tag=ROOT_ID, sync_type=THEME),
472 PermanentItem('google_chrome_typed_urls', name='Typed URLs', 475 PermanentItem('google_chrome_typed_urls', name='Typed URLs',
473 parent_tag=ROOT_ID, sync_type=TYPED_URL), 476 parent_tag=ROOT_ID, sync_type=TYPED_URL),
477 PermanentItem('google_chrome_dictionary', name='Dictionary',
478 parent_tag=ROOT_ID, sync_type=DICTIONARY),
474 ] 479 ]
475 480
476 def __init__(self): 481 def __init__(self):
477 # Monotonically increasing version number. The next object change will 482 # Monotonically increasing version number. The next object change will
478 # take on this value + 1. 483 # take on this value + 1.
479 self._version = 0 484 self._version = 0
480 485
481 # The definitive copy of this client's items: a map from ID string to a 486 # The definitive copy of this client's items: a map from ID string to a
482 # SyncEntity protocol buffer. 487 # SyncEntity protocol buffer.
483 self._entries = {} 488 self._entries = {}
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) 1329 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve)
1325 1330
1326 update_response.changes_remaining = remaining 1331 update_response.changes_remaining = remaining
1327 for entry in entries: 1332 for entry in entries:
1328 reply = update_response.entries.add() 1333 reply = update_response.entries.add()
1329 reply.CopyFrom(entry) 1334 reply.CopyFrom(entry)
1330 update_sieve.SaveProgress(new_timestamp, update_response) 1335 update_sieve.SaveProgress(new_timestamp, update_response)
1331 1336
1332 if update_request.need_encryption_key: 1337 if update_request.need_encryption_key:
1333 update_response.encryption_key = self.account.GetKey() 1338 update_response.encryption_key = self.account.GetKey()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698