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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 base::TimeDelta delta = on_backend_initialized_time - | 998 base::TimeDelta delta = on_backend_initialized_time - |
999 startup_controller_.start_backend_time(); | 999 startup_controller_.start_backend_time(); |
1000 if (is_first_time_sync_configure_) { | 1000 if (is_first_time_sync_configure_) { |
1001 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeFirstTime", delta); | 1001 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeFirstTime", delta); |
1002 } else { | 1002 } else { |
1003 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeRestoreTime", delta); | 1003 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeRestoreTime", delta); |
1004 } | 1004 } |
1005 } | 1005 } |
1006 | 1006 |
1007 void ProfileSyncService::PostBackendInitialization() { | 1007 void ProfileSyncService::PostBackendInitialization() { |
1008 if (backend_mode_ == BACKUP || backend_mode_ == ROLLBACK) { | 1008 // Never get here for backup / restore. |
1009 ConfigureDataTypeManager(); | 1009 DCHECK_EQ(backend_mode_, SYNC); |
1010 return; | |
1011 } | |
1012 | 1010 |
1013 if (protocol_event_observers_.might_have_observers()) { | 1011 if (protocol_event_observers_.might_have_observers()) { |
1014 backend_->RequestBufferedProtocolEventsAndEnableForwarding(); | 1012 backend_->RequestBufferedProtocolEventsAndEnableForwarding(); |
1015 } | 1013 } |
1016 | 1014 |
1017 non_blocking_data_type_manager_.ConnectSyncBackend( | 1015 non_blocking_data_type_manager_.ConnectSyncBackend( |
1018 backend_->GetSyncCoreProxy()); | 1016 backend_->GetSyncCoreProxy()); |
1019 | 1017 |
1020 if (type_debug_info_observers_.might_have_observers()) { | 1018 if (type_debug_info_observers_.might_have_observers()) { |
1021 backend_->EnableDirectoryTypeDebugInfoForwarding(); | 1019 backend_->EnableDirectoryTypeDebugInfoForwarding(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 false, | 1075 false, |
1078 ERROR_REASON_BACKEND_INIT_FAILURE); | 1076 ERROR_REASON_BACKEND_INIT_FAILURE); |
1079 return; | 1077 return; |
1080 } | 1078 } |
1081 | 1079 |
1082 backend_initialized_ = true; | 1080 backend_initialized_ = true; |
1083 | 1081 |
1084 sync_js_controller_.AttachJsBackend(js_backend); | 1082 sync_js_controller_.AttachJsBackend(js_backend); |
1085 debug_info_listener_ = debug_info_listener; | 1083 debug_info_listener_ = debug_info_listener; |
1086 | 1084 |
1087 PostBackendInitialization(); | 1085 // Give the DataTypeControllers a handle to the now initialized backend |
| 1086 // as a UserShare. |
| 1087 for (DataTypeController::TypeMap::iterator it = |
| 1088 directory_data_type_controllers_.begin(); |
| 1089 it != directory_data_type_controllers_.end(); ++it) { |
| 1090 it->second->OnUserShareReady(GetUserShare()); |
| 1091 } |
| 1092 |
| 1093 if (backend_mode_ == BACKUP || backend_mode_ == ROLLBACK) |
| 1094 ConfigureDataTypeManager(); |
| 1095 else |
| 1096 PostBackendInitialization(); |
1088 } | 1097 } |
1089 | 1098 |
1090 void ProfileSyncService::OnSyncCycleCompleted() { | 1099 void ProfileSyncService::OnSyncCycleCompleted() { |
1091 UpdateLastSyncedTime(); | 1100 UpdateLastSyncedTime(); |
1092 if (IsSessionsDataTypeControllerRunning()) { | 1101 if (IsSessionsDataTypeControllerRunning()) { |
1093 // Trigger garbage collection of old sessions now that we've downloaded | 1102 // Trigger garbage collection of old sessions now that we've downloaded |
1094 // any new session data. | 1103 // any new session data. |
1095 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 1104 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
1096 &browser_sync::SessionsSyncManager::DoGarbageCollection, | 1105 &browser_sync::SessionsSyncManager::DoGarbageCollection, |
1097 base::AsWeakPtr(sessions_sync_manager_.get()))); | 1106 base::AsWeakPtr(sessions_sync_manager_.get()))); |
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 if (first_sync_time.is_null()) | 2528 if (first_sync_time.is_null()) |
2520 return; | 2529 return; |
2521 | 2530 |
2522 clear_browsing_data_.Run(profile_, first_sync_time, base::Time::Now()); | 2531 clear_browsing_data_.Run(profile_, first_sync_time, base::Time::Now()); |
2523 } | 2532 } |
2524 | 2533 |
2525 void ProfileSyncService::SetClearingBrowseringDataForTesting( | 2534 void ProfileSyncService::SetClearingBrowseringDataForTesting( |
2526 base::Callback<void(Profile*, base::Time, base::Time)> c) { | 2535 base::Callback<void(Profile*, base::Time, base::Time)> c) { |
2527 clear_browsing_data_ = c; | 2536 clear_browsing_data_ = c; |
2528 } | 2537 } |
OLD | NEW |