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 #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/cleanup_disabled_types_command.h" | |
16 #include "sync/engine/commit.h" | 15 #include "sync/engine/commit.h" |
17 #include "sync/engine/conflict_resolver.h" | 16 #include "sync/engine/conflict_resolver.h" |
18 #include "sync/engine/download_updates_command.h" | 17 #include "sync/engine/download_updates_command.h" |
19 #include "sync/engine/net/server_connection_manager.h" | 18 #include "sync/engine/net/server_connection_manager.h" |
20 #include "sync/engine/process_commit_response_command.h" | 19 #include "sync/engine/process_commit_response_command.h" |
21 #include "sync/engine/process_updates_command.h" | 20 #include "sync/engine/process_updates_command.h" |
22 #include "sync/engine/resolve_conflicts_command.h" | 21 #include "sync/engine/resolve_conflicts_command.h" |
23 #include "sync/engine/store_timestamps_command.h" | 22 #include "sync/engine/store_timestamps_command.h" |
24 #include "sync/engine/syncer_types.h" | 23 #include "sync/engine/syncer_types.h" |
25 #include "sync/engine/throttled_data_type_tracker.h" | 24 #include "sync/engine/throttled_data_type_tracker.h" |
(...skipping 20 matching lines...) Expand all Loading... |
46 using syncable::SERVER_PARENT_ID; | 45 using syncable::SERVER_PARENT_ID; |
47 using syncable::SERVER_POSITION_IN_PARENT; | 46 using syncable::SERVER_POSITION_IN_PARENT; |
48 using syncable::SERVER_SPECIFICS; | 47 using syncable::SERVER_SPECIFICS; |
49 using syncable::SERVER_VERSION; | 48 using syncable::SERVER_VERSION; |
50 | 49 |
51 #define ENUM_CASE(x) case x: return #x | 50 #define ENUM_CASE(x) case x: return #x |
52 const char* SyncerStepToString(const SyncerStep step) | 51 const char* SyncerStepToString(const SyncerStep step) |
53 { | 52 { |
54 switch (step) { | 53 switch (step) { |
55 ENUM_CASE(SYNCER_BEGIN); | 54 ENUM_CASE(SYNCER_BEGIN); |
56 ENUM_CASE(CLEANUP_DISABLED_TYPES); | |
57 ENUM_CASE(DOWNLOAD_UPDATES); | 55 ENUM_CASE(DOWNLOAD_UPDATES); |
58 ENUM_CASE(PROCESS_CLIENT_COMMAND); | 56 ENUM_CASE(PROCESS_CLIENT_COMMAND); |
59 ENUM_CASE(VERIFY_UPDATES); | 57 ENUM_CASE(VERIFY_UPDATES); |
60 ENUM_CASE(PROCESS_UPDATES); | 58 ENUM_CASE(PROCESS_UPDATES); |
61 ENUM_CASE(STORE_TIMESTAMPS); | 59 ENUM_CASE(STORE_TIMESTAMPS); |
62 ENUM_CASE(APPLY_UPDATES); | 60 ENUM_CASE(APPLY_UPDATES); |
63 ENUM_CASE(COMMIT); | 61 ENUM_CASE(COMMIT); |
64 ENUM_CASE(RESOLVE_CONFLICTS); | 62 ENUM_CASE(RESOLVE_CONFLICTS); |
65 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS); | 63 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS); |
66 ENUM_CASE(SYNCER_END); | 64 ENUM_CASE(SYNCER_END); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 TRACE_EVENT1("sync", "SyncerStateMachine", | 97 TRACE_EVENT1("sync", "SyncerStateMachine", |
100 "state", SyncerStepToString(current_step)); | 98 "state", SyncerStepToString(current_step)); |
101 DVLOG(1) << "Syncer step:" << SyncerStepToString(current_step); | 99 DVLOG(1) << "Syncer step:" << SyncerStepToString(current_step); |
102 | 100 |
103 switch (current_step) { | 101 switch (current_step) { |
104 case SYNCER_BEGIN: | 102 case SYNCER_BEGIN: |
105 session->context()->throttled_data_type_tracker()-> | 103 session->context()->throttled_data_type_tracker()-> |
106 PruneUnthrottledTypes(base::TimeTicks::Now()); | 104 PruneUnthrottledTypes(base::TimeTicks::Now()); |
107 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN); | 105 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN); |
108 | 106 |
109 next_step = CLEANUP_DISABLED_TYPES; | |
110 break; | |
111 case CLEANUP_DISABLED_TYPES: { | |
112 CleanupDisabledTypesCommand cleanup; | |
113 cleanup.Execute(session); | |
114 next_step = DOWNLOAD_UPDATES; | 107 next_step = DOWNLOAD_UPDATES; |
115 break; | 108 break; |
116 } | |
117 case DOWNLOAD_UPDATES: { | 109 case DOWNLOAD_UPDATES: { |
118 // TODO(akalin): We may want to propagate this switch up | 110 // TODO(akalin): We may want to propagate this switch up |
119 // eventually. | 111 // eventually. |
120 #if defined(OS_ANDROID) | 112 #if defined(OS_ANDROID) |
121 const bool kCreateMobileBookmarksFolder = true; | 113 const bool kCreateMobileBookmarksFolder = true; |
122 #else | 114 #else |
123 const bool kCreateMobileBookmarksFolder = false; | 115 const bool kCreateMobileBookmarksFolder = false; |
124 #endif | 116 #endif |
125 DownloadUpdatesCommand download_updates(kCreateMobileBookmarksFolder); | 117 DownloadUpdatesCommand download_updates(kCreateMobileBookmarksFolder); |
126 session->mutable_status_controller()->set_last_download_updates_result( | 118 session->mutable_status_controller()->set_last_download_updates_result( |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 entry->Put(SERVER_CTIME, Time()); | 281 entry->Put(SERVER_CTIME, Time()); |
290 entry->Put(SERVER_VERSION, 0); | 282 entry->Put(SERVER_VERSION, 0); |
291 entry->Put(SERVER_IS_DIR, false); | 283 entry->Put(SERVER_IS_DIR, false); |
292 entry->Put(SERVER_IS_DEL, false); | 284 entry->Put(SERVER_IS_DEL, false); |
293 entry->Put(IS_UNAPPLIED_UPDATE, false); | 285 entry->Put(IS_UNAPPLIED_UPDATE, false); |
294 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); | 286 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); |
295 entry->Put(SERVER_POSITION_IN_PARENT, 0); | 287 entry->Put(SERVER_POSITION_IN_PARENT, 0); |
296 } | 288 } |
297 | 289 |
298 } // namespace syncer | 290 } // namespace syncer |
OLD | NEW |