OLD | NEW |
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 |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 nigori_tag = "google_chrome_nigori" | 917 nigori_tag = "google_chrome_nigori" |
918 nigori_original = self._entries.get(self._ServerTagToId(nigori_tag)) | 918 nigori_original = self._entries.get(self._ServerTagToId(nigori_tag)) |
919 if (nigori_original.specifics.Extensions[nigori_specifics_pb2.nigori]. | 919 if (nigori_original.specifics.Extensions[nigori_specifics_pb2.nigori]. |
920 sync_tabs): | 920 sync_tabs): |
921 return | 921 return |
922 nigori_new = copy.deepcopy(nigori_original) | 922 nigori_new = copy.deepcopy(nigori_original) |
923 nigori_new.specifics.Extensions[nigori_specifics_pb2.nigori].sync_tabs = ( | 923 nigori_new.specifics.Extensions[nigori_specifics_pb2.nigori].sync_tabs = ( |
924 True) | 924 True) |
925 self._SaveEntry(nigori_new) | 925 self._SaveEntry(nigori_new) |
926 | 926 |
| 927 def TriggerCreateSyncedBookmarks(self): |
| 928 """Create the Synced Bookmarks folder under the Bookmarks permanent item. |
| 929 |
| 930 Clients will then received the Synced Bookmarks folder on future |
| 931 GetUpdates, and new bookmarks can be added within the Synced Bookmarks |
| 932 folder.""" |
| 933 |
| 934 synced_bookmarks_spec = ( |
| 935 PermanentItem('synced_bookmarks', name='Synced Bookmarks', |
| 936 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK)) |
| 937 self._PERMANENT_ITEM_SPECS.append(synced_bookmarks_spec) |
| 938 self._CreatePermanentItem(synced_bookmarks_spec) |
| 939 |
927 def SetInducedError(self, error, error_frequency, | 940 def SetInducedError(self, error, error_frequency, |
928 sync_count_before_errors): | 941 sync_count_before_errors): |
929 self.induced_error = error | 942 self.induced_error = error |
930 self.induced_error_frequency = error_frequency | 943 self.induced_error_frequency = error_frequency |
931 self.sync_count_before_errors = sync_count_before_errors | 944 self.sync_count_before_errors = sync_count_before_errors |
932 | 945 |
933 def GetInducedError(self): | 946 def GetInducedError(self): |
934 return self.induced_error | 947 return self.induced_error |
935 | 948 |
936 | 949 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 200, | 1079 200, |
1067 '<html><title>Transient error</title><H1>Transient error</H1></html>') | 1080 '<html><title>Transient error</title><H1>Transient error</H1></html>') |
1068 | 1081 |
1069 def HandleSetSyncTabs(self): | 1082 def HandleSetSyncTabs(self): |
1070 """Set the 'sync_tab' field of the nigori node for this account.""" | 1083 """Set the 'sync_tab' field of the nigori node for this account.""" |
1071 self.account.TriggerSyncTabs() | 1084 self.account.TriggerSyncTabs() |
1072 return ( | 1085 return ( |
1073 200, | 1086 200, |
1074 '<html><title>Sync Tabs</title><H1>Sync Tabs</H1></html>') | 1087 '<html><title>Sync Tabs</title><H1>Sync Tabs</H1></html>') |
1075 | 1088 |
| 1089 def HandleCreateSyncedBookmarks(self): |
| 1090 """Create the Synced Bookmarks folder under Bookmarks.""" |
| 1091 self.account.TriggerCreateSyncedBookmarks() |
| 1092 return ( |
| 1093 200, |
| 1094 '<html><title>Synced Bookmarks</title><H1>Synced Bookmarks</H1></html>') |
| 1095 |
1076 def HandleCommand(self, query, raw_request): | 1096 def HandleCommand(self, query, raw_request): |
1077 """Decode and handle a sync command from a raw input of bytes. | 1097 """Decode and handle a sync command from a raw input of bytes. |
1078 | 1098 |
1079 This is the main entry point for this class. It is safe to call this | 1099 This is the main entry point for this class. It is safe to call this |
1080 method from multiple threads. | 1100 method from multiple threads. |
1081 | 1101 |
1082 Args: | 1102 Args: |
1083 raw_request: An iterable byte sequence to be interpreted as a sync | 1103 raw_request: An iterable byte sequence to be interpreted as a sync |
1084 protocol command. | 1104 protocol command. |
1085 Returns: | 1105 Returns: |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 | 1245 |
1226 update_sieve.CheckMigrationState() | 1246 update_sieve.CheckMigrationState() |
1227 | 1247 |
1228 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) | 1248 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) |
1229 | 1249 |
1230 update_response.changes_remaining = remaining | 1250 update_response.changes_remaining = remaining |
1231 for entry in entries: | 1251 for entry in entries: |
1232 reply = update_response.entries.add() | 1252 reply = update_response.entries.add() |
1233 reply.CopyFrom(entry) | 1253 reply.CopyFrom(entry) |
1234 update_sieve.SaveProgress(new_timestamp, update_response) | 1254 update_sieve.SaveProgress(new_timestamp, update_response) |
OLD | NEW |