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

Side by Side Diff: sync/engine/syncer.cc

Issue 10455012: [Sync] Add support for performing a GetKey on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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
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 #include "sync/engine/syncer.h" 5 #include "sync/engine/syncer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "sync/engine/apply_updates_command.h" 13 #include "sync/engine/apply_updates_command.h"
14 #include "sync/engine/build_commit_command.h" 14 #include "sync/engine/build_commit_command.h"
15 #include "sync/engine/commit.h" 15 #include "sync/engine/commit.h"
16 #include "sync/engine/conflict_resolver.h" 16 #include "sync/engine/conflict_resolver.h"
17 #include "sync/engine/download_updates_command.h" 17 #include "sync/engine/download_updates_command.h"
18 #include "sync/engine/get_key_command.h"
18 #include "sync/engine/net/server_connection_manager.h" 19 #include "sync/engine/net/server_connection_manager.h"
19 #include "sync/engine/process_commit_response_command.h" 20 #include "sync/engine/process_commit_response_command.h"
20 #include "sync/engine/process_updates_command.h" 21 #include "sync/engine/process_updates_command.h"
21 #include "sync/engine/resolve_conflicts_command.h" 22 #include "sync/engine/resolve_conflicts_command.h"
22 #include "sync/engine/store_timestamps_command.h" 23 #include "sync/engine/store_timestamps_command.h"
23 #include "sync/engine/syncer_types.h" 24 #include "sync/engine/syncer_types.h"
24 #include "sync/engine/throttled_data_type_tracker.h" 25 #include "sync/engine/throttled_data_type_tracker.h"
25 #include "sync/engine/verify_updates_command.h" 26 #include "sync/engine/verify_updates_command.h"
26 #include "sync/syncable/mutable_entry.h" 27 #include "sync/syncable/mutable_entry.h"
27 #include "sync/syncable/syncable-inl.h" 28 #include "sync/syncable/syncable-inl.h"
(...skipping 17 matching lines...) Expand all
45 using syncable::SERVER_PARENT_ID; 46 using syncable::SERVER_PARENT_ID;
46 using syncable::SERVER_POSITION_IN_PARENT; 47 using syncable::SERVER_POSITION_IN_PARENT;
47 using syncable::SERVER_SPECIFICS; 48 using syncable::SERVER_SPECIFICS;
48 using syncable::SERVER_VERSION; 49 using syncable::SERVER_VERSION;
49 50
50 #define ENUM_CASE(x) case x: return #x 51 #define ENUM_CASE(x) case x: return #x
51 const char* SyncerStepToString(const SyncerStep step) 52 const char* SyncerStepToString(const SyncerStep step)
52 { 53 {
53 switch (step) { 54 switch (step) {
54 ENUM_CASE(SYNCER_BEGIN); 55 ENUM_CASE(SYNCER_BEGIN);
56 ENUM_CASE(GET_ENCRYPTION_KEY);
55 ENUM_CASE(DOWNLOAD_UPDATES); 57 ENUM_CASE(DOWNLOAD_UPDATES);
56 ENUM_CASE(PROCESS_CLIENT_COMMAND); 58 ENUM_CASE(PROCESS_CLIENT_COMMAND);
57 ENUM_CASE(VERIFY_UPDATES); 59 ENUM_CASE(VERIFY_UPDATES);
58 ENUM_CASE(PROCESS_UPDATES); 60 ENUM_CASE(PROCESS_UPDATES);
59 ENUM_CASE(STORE_TIMESTAMPS); 61 ENUM_CASE(STORE_TIMESTAMPS);
60 ENUM_CASE(APPLY_UPDATES); 62 ENUM_CASE(APPLY_UPDATES);
61 ENUM_CASE(COMMIT); 63 ENUM_CASE(COMMIT);
62 ENUM_CASE(RESOLVE_CONFLICTS); 64 ENUM_CASE(RESOLVE_CONFLICTS);
63 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS); 65 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS);
64 ENUM_CASE(SYNCER_END); 66 ENUM_CASE(SYNCER_END);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 DVLOG(1) << "Syncer step:" << SyncerStepToString(current_step); 101 DVLOG(1) << "Syncer step:" << SyncerStepToString(current_step);
100 102
101 switch (current_step) { 103 switch (current_step) {
102 case SYNCER_BEGIN: 104 case SYNCER_BEGIN:
103 session->context()->throttled_data_type_tracker()-> 105 session->context()->throttled_data_type_tracker()->
104 PruneUnthrottledTypes(base::TimeTicks::Now()); 106 PruneUnthrottledTypes(base::TimeTicks::Now());
105 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN); 107 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN);
106 108
107 next_step = DOWNLOAD_UPDATES; 109 next_step = DOWNLOAD_UPDATES;
108 break; 110 break;
111 case GET_ENCRYPTION_KEY: {
112 GetKeyCommand get_key;
113 SyncerError result = get_key.Execute(session);
114 session->mutable_status_controller()->set_last_get_key_result(result);
115 if (result == SYNCER_OK && last_step != GET_ENCRYPTION_KEY) {
116 next_step = DOWNLOAD_UPDATES;
117 } else {
118 LOG_IF(ERROR, result != SYNCER_OK)
119 << "Aborting sync cycle due to get key failure.";
120 last_step = SYNCER_END; // Necessary for CONFIGURATION mode.
121 next_step = SYNCER_END;
122 }
123 break;
124 }
109 case DOWNLOAD_UPDATES: { 125 case DOWNLOAD_UPDATES: {
110 // TODO(akalin): We may want to propagate this switch up 126 // TODO(akalin): We may want to propagate this switch up
111 // eventually. 127 // eventually.
112 #if defined(OS_ANDROID) 128 #if defined(OS_ANDROID)
113 const bool kCreateMobileBookmarksFolder = true; 129 const bool kCreateMobileBookmarksFolder = true;
114 #else 130 #else
115 const bool kCreateMobileBookmarksFolder = false; 131 const bool kCreateMobileBookmarksFolder = false;
116 #endif 132 #endif
117 DownloadUpdatesCommand download_updates(kCreateMobileBookmarksFolder); 133 DownloadUpdatesCommand download_updates(kCreateMobileBookmarksFolder);
118 session->mutable_status_controller()->set_last_download_updates_result( 134 session->mutable_status_controller()->set_last_download_updates_result(
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 entry->Put(SERVER_CTIME, Time()); 297 entry->Put(SERVER_CTIME, Time());
282 entry->Put(SERVER_VERSION, 0); 298 entry->Put(SERVER_VERSION, 0);
283 entry->Put(SERVER_IS_DIR, false); 299 entry->Put(SERVER_IS_DIR, false);
284 entry->Put(SERVER_IS_DEL, false); 300 entry->Put(SERVER_IS_DEL, false);
285 entry->Put(IS_UNAPPLIED_UPDATE, false); 301 entry->Put(IS_UNAPPLIED_UPDATE, false);
286 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); 302 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance());
287 entry->Put(SERVER_POSITION_IN_PARENT, 0); 303 entry->Put(SERVER_POSITION_IN_PARENT, 0);
288 } 304 }
289 305
290 } // namespace syncer 306 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698