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

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

Issue 11091009: sync: Merge {Verify,Process}UpdatesCommand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fixes Created 8 years, 2 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_control_data_updates.h" 13 #include "sync/engine/apply_control_data_updates.h"
14 #include "sync/engine/apply_updates_command.h" 14 #include "sync/engine/apply_updates_command.h"
15 #include "sync/engine/build_commit_command.h" 15 #include "sync/engine/build_commit_command.h"
16 #include "sync/engine/commit.h" 16 #include "sync/engine/commit.h"
17 #include "sync/engine/conflict_resolver.h" 17 #include "sync/engine/conflict_resolver.h"
18 #include "sync/engine/download_updates_command.h" 18 #include "sync/engine/download_updates_command.h"
19 #include "sync/engine/net/server_connection_manager.h" 19 #include "sync/engine/net/server_connection_manager.h"
20 #include "sync/engine/process_commit_response_command.h" 20 #include "sync/engine/process_commit_response_command.h"
21 #include "sync/engine/process_updates_command.h" 21 #include "sync/engine/process_updates_command.h"
22 #include "sync/engine/resolve_conflicts_command.h" 22 #include "sync/engine/resolve_conflicts_command.h"
23 #include "sync/engine/store_timestamps_command.h" 23 #include "sync/engine/store_timestamps_command.h"
24 #include "sync/engine/syncer_types.h" 24 #include "sync/engine/syncer_types.h"
25 #include "sync/engine/throttled_data_type_tracker.h" 25 #include "sync/engine/throttled_data_type_tracker.h"
26 #include "sync/engine/verify_updates_command.h"
27 #include "sync/syncable/mutable_entry.h" 26 #include "sync/syncable/mutable_entry.h"
28 #include "sync/syncable/syncable-inl.h" 27 #include "sync/syncable/syncable-inl.h"
29 28
30 using base::Time; 29 using base::Time;
31 using base::TimeDelta; 30 using base::TimeDelta;
32 using sync_pb::ClientCommand; 31 using sync_pb::ClientCommand;
33 32
34 namespace syncer { 33 namespace syncer {
35 34
36 using sessions::ScopedSessionContextConflictResolver; 35 using sessions::ScopedSessionContextConflictResolver;
37 using sessions::StatusController; 36 using sessions::StatusController;
38 using sessions::SyncSession; 37 using sessions::SyncSession;
39 using syncable::IS_UNAPPLIED_UPDATE; 38 using syncable::IS_UNAPPLIED_UPDATE;
40 using syncable::SERVER_CTIME; 39 using syncable::SERVER_CTIME;
41 using syncable::SERVER_IS_DEL; 40 using syncable::SERVER_IS_DEL;
42 using syncable::SERVER_IS_DIR; 41 using syncable::SERVER_IS_DIR;
43 using syncable::SERVER_MTIME; 42 using syncable::SERVER_MTIME;
44 using syncable::SERVER_NON_UNIQUE_NAME; 43 using syncable::SERVER_NON_UNIQUE_NAME;
45 using syncable::SERVER_PARENT_ID; 44 using syncable::SERVER_PARENT_ID;
46 using syncable::SERVER_POSITION_IN_PARENT; 45 using syncable::SERVER_POSITION_IN_PARENT;
47 using syncable::SERVER_SPECIFICS; 46 using syncable::SERVER_SPECIFICS;
48 using syncable::SERVER_VERSION; 47 using syncable::SERVER_VERSION;
49 48
50 #define ENUM_CASE(x) case x: return #x 49 #define ENUM_CASE(x) case x: return #x
51 const char* SyncerStepToString(const SyncerStep step) 50 const char* SyncerStepToString(const SyncerStep step)
52 { 51 {
53 switch (step) { 52 switch (step) {
54 ENUM_CASE(SYNCER_BEGIN); 53 ENUM_CASE(SYNCER_BEGIN);
55 ENUM_CASE(DOWNLOAD_UPDATES); 54 ENUM_CASE(DOWNLOAD_UPDATES);
56 ENUM_CASE(VERIFY_UPDATES);
57 ENUM_CASE(PROCESS_UPDATES); 55 ENUM_CASE(PROCESS_UPDATES);
58 ENUM_CASE(STORE_TIMESTAMPS); 56 ENUM_CASE(STORE_TIMESTAMPS);
59 ENUM_CASE(APPLY_UPDATES); 57 ENUM_CASE(APPLY_UPDATES);
60 ENUM_CASE(COMMIT); 58 ENUM_CASE(COMMIT);
61 ENUM_CASE(RESOLVE_CONFLICTS); 59 ENUM_CASE(RESOLVE_CONFLICTS);
62 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS); 60 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS);
63 ENUM_CASE(SYNCER_END); 61 ENUM_CASE(SYNCER_END);
64 } 62 }
65 NOTREACHED(); 63 NOTREACHED();
66 return ""; 64 return "";
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // TODO(akalin): We may want to propagate this switch up 107 // TODO(akalin): We may want to propagate this switch up
110 // eventually. 108 // eventually.
111 #if defined(OS_ANDROID) || defined(OS_IOS) 109 #if defined(OS_ANDROID) || defined(OS_IOS)
112 const bool kCreateMobileBookmarksFolder = true; 110 const bool kCreateMobileBookmarksFolder = true;
113 #else 111 #else
114 const bool kCreateMobileBookmarksFolder = false; 112 const bool kCreateMobileBookmarksFolder = false;
115 #endif 113 #endif
116 DownloadUpdatesCommand download_updates(kCreateMobileBookmarksFolder); 114 DownloadUpdatesCommand download_updates(kCreateMobileBookmarksFolder);
117 session->mutable_status_controller()->set_last_download_updates_result( 115 session->mutable_status_controller()->set_last_download_updates_result(
118 download_updates.Execute(session)); 116 download_updates.Execute(session));
119 next_step = VERIFY_UPDATES;
120 break;
121 }
122 case VERIFY_UPDATES: {
123 VerifyUpdatesCommand verify_updates;
124 verify_updates.Execute(session);
125 next_step = PROCESS_UPDATES; 117 next_step = PROCESS_UPDATES;
126 break; 118 break;
127 } 119 }
128 case PROCESS_UPDATES: { 120 case PROCESS_UPDATES: {
129 ProcessUpdatesCommand process_updates; 121 ProcessUpdatesCommand process_updates;
130 process_updates.Execute(session); 122 process_updates.Execute(session);
131 next_step = STORE_TIMESTAMPS; 123 next_step = STORE_TIMESTAMPS;
132 break; 124 break;
133 } 125 }
134 case STORE_TIMESTAMPS: { 126 case STORE_TIMESTAMPS: {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 entry->Put(SERVER_CTIME, Time()); 243 entry->Put(SERVER_CTIME, Time());
252 entry->Put(SERVER_VERSION, 0); 244 entry->Put(SERVER_VERSION, 0);
253 entry->Put(SERVER_IS_DIR, false); 245 entry->Put(SERVER_IS_DIR, false);
254 entry->Put(SERVER_IS_DEL, false); 246 entry->Put(SERVER_IS_DEL, false);
255 entry->Put(IS_UNAPPLIED_UPDATE, false); 247 entry->Put(IS_UNAPPLIED_UPDATE, false);
256 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); 248 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance());
257 entry->Put(SERVER_POSITION_IN_PARENT, 0); 249 entry->Put(SERVER_POSITION_IN_PARENT, 0);
258 } 250 }
259 251
260 } // namespace syncer 252 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698