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

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

Issue 7669073: [Sync] Add support for enabling session sync remotely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DOUBLE R..ebase Created 9 years, 4 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
« no previous file with comments | « chrome/test/live_sync/migration_errors_test.cc ('k') | net/tools/testserver/testserver.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """An implementation of the server side of the Chromium sync protocol. 6 """An implementation of the server side of the Chromium sync protocol.
7 7
8 The details of the protocol are described mostly by comments in the protocol 8 The details of the protocol are described mostly by comments in the protocol
9 buffer definition at chrome/browser/sync/protocol/sync.proto. 9 buffer definition at chrome/browser/sync/protocol/sync.proto.
10 """ 10 """
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 all_entries = self._entries.values() 856 all_entries = self._entries.values()
857 self._entries.clear() 857 self._entries.clear()
858 for entry in all_entries: 858 for entry in all_entries:
859 new_id = self._RewriteVersionInId(entry.id_string) 859 new_id = self._RewriteVersionInId(entry.id_string)
860 entry.id_string = new_id 860 entry.id_string = new_id
861 if entry.HasField('parent_id_string'): 861 if entry.HasField('parent_id_string'):
862 entry.parent_id_string = self._RewriteVersionInId( 862 entry.parent_id_string = self._RewriteVersionInId(
863 entry.parent_id_string) 863 entry.parent_id_string)
864 self._entries[entry.id_string] = entry 864 self._entries[entry.id_string] = entry
865 865
866 def TriggerSyncTabs(self):
867 """Set the 'sync_tabs' field to this account's nigori node.
868
869 If the field is not currently set, will write a new nigori node entry
870 with the field set. Else does nothing.
871 """
872
873 nigori_tag = "google_chrome_nigori"
874 nigori_original = self._entries.get(self._ServerTagToId(nigori_tag))
875 if (nigori_original.specifics.Extensions[nigori_specifics_pb2.nigori].
876 sync_tabs):
877 return
878 nigori_new = copy.deepcopy(nigori_original)
879 nigori_new.specifics.Extensions[nigori_specifics_pb2.nigori].sync_tabs = (
880 True)
881 self._SaveEntry(nigori_new)
882
866 883
867 class TestServer(object): 884 class TestServer(object):
868 """An object to handle requests for one (and only one) Chrome Sync account. 885 """An object to handle requests for one (and only one) Chrome Sync account.
869 886
870 TestServer consumes the sync command messages that are the outermost 887 TestServer consumes the sync command messages that are the outermost
871 layers of the protocol, performs the corresponding actions on its 888 layers of the protocol, performs the corresponding actions on its
872 SyncDataModel, and constructs an appropropriate response message. 889 SyncDataModel, and constructs an appropropriate response message.
873 """ 890 """
874 891
875 def __init__(self): 892 def __init__(self):
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 return ( 949 return (
933 200, 950 200,
934 '<html><title>Birthday error</title><H1>Birthday error</H1></html>') 951 '<html><title>Birthday error</title><H1>Birthday error</H1></html>')
935 952
936 def HandleSetTransientError(self): 953 def HandleSetTransientError(self):
937 self.transient_error = True 954 self.transient_error = True
938 return ( 955 return (
939 200, 956 200,
940 '<html><title>Transient error</title><H1>Transient error</H1></html>') 957 '<html><title>Transient error</title><H1>Transient error</H1></html>')
941 958
959 def HandleSetSyncTabs(self):
960 """Set the 'sync_tab' field of the nigori node for this account."""
961 self.account.TriggerSyncTabs()
962 return (
963 200,
964 '<html><title>Sync Tabs</title><H1>Sync Tabs</H1></html>')
965
942 def HandleCommand(self, query, raw_request): 966 def HandleCommand(self, query, raw_request):
943 """Decode and handle a sync command from a raw input of bytes. 967 """Decode and handle a sync command from a raw input of bytes.
944 968
945 This is the main entry point for this class. It is safe to call this 969 This is the main entry point for this class. It is safe to call this
946 method from multiple threads. 970 method from multiple threads.
947 971
948 Args: 972 Args:
949 raw_request: An iterable byte sequence to be interpreted as a sync 973 raw_request: An iterable byte sequence to be interpreted as a sync
950 protocol command. 974 protocol command.
951 Returns: 975 Returns:
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1102
1079 update_sieve.CheckMigrationState() 1103 update_sieve.CheckMigrationState()
1080 1104
1081 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) 1105 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve)
1082 1106
1083 update_response.changes_remaining = remaining 1107 update_response.changes_remaining = remaining
1084 for entry in entries: 1108 for entry in entries:
1085 reply = update_response.entries.add() 1109 reply = update_response.entries.add()
1086 reply.CopyFrom(entry) 1110 reply.CopyFrom(entry)
1087 update_sieve.SaveProgress(new_timestamp, update_response) 1111 update_sieve.SaveProgress(new_timestamp, update_response)
OLDNEW
« no previous file with comments | « chrome/test/live_sync/migration_errors_test.cc ('k') | net/tools/testserver/testserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698