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 "components/browser_sync/browser/profile_sync_service.h" | 5 #include "components/browser_sync/browser/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "components/sync_driver/change_processor.h" | 42 #include "components/sync_driver/change_processor.h" |
43 #include "components/sync_driver/data_type_controller.h" | 43 #include "components/sync_driver/data_type_controller.h" |
44 #include "components/sync_driver/device_info.h" | 44 #include "components/sync_driver/device_info.h" |
45 #include "components/sync_driver/glue/chrome_report_unrecoverable_error.h" | 45 #include "components/sync_driver/glue/chrome_report_unrecoverable_error.h" |
46 #include "components/sync_driver/glue/sync_backend_host.h" | 46 #include "components/sync_driver/glue/sync_backend_host.h" |
47 #include "components/sync_driver/glue/sync_backend_host_impl.h" | 47 #include "components/sync_driver/glue/sync_backend_host_impl.h" |
48 #include "components/sync_driver/pref_names.h" | 48 #include "components/sync_driver/pref_names.h" |
49 #include "components/sync_driver/signin_manager_wrapper.h" | 49 #include "components/sync_driver/signin_manager_wrapper.h" |
50 #include "components/sync_driver/sync_api_component_factory.h" | 50 #include "components/sync_driver/sync_api_component_factory.h" |
51 #include "components/sync_driver/sync_client.h" | 51 #include "components/sync_driver/sync_client.h" |
52 #include "components/sync_driver/sync_driver_features.h" | |
53 #include "components/sync_driver/sync_driver_switches.h" | 52 #include "components/sync_driver/sync_driver_switches.h" |
54 #include "components/sync_driver/sync_error_controller.h" | 53 #include "components/sync_driver/sync_error_controller.h" |
55 #include "components/sync_driver/sync_stopped_reporter.h" | 54 #include "components/sync_driver/sync_stopped_reporter.h" |
56 #include "components/sync_driver/sync_type_preference_provider.h" | 55 #include "components/sync_driver/sync_type_preference_provider.h" |
57 #include "components/sync_driver/sync_util.h" | 56 #include "components/sync_driver/sync_util.h" |
58 #include "components/sync_driver/system_encryptor.h" | 57 #include "components/sync_driver/system_encryptor.h" |
59 #include "components/sync_driver/user_selectable_sync_type.h" | 58 #include "components/sync_driver/user_selectable_sync_type.h" |
60 #include "components/sync_sessions/favicon_cache.h" | 59 #include "components/sync_sessions/favicon_cache.h" |
61 #include "components/sync_sessions/session_data_type_controller.h" | 60 #include "components/sync_sessions/session_data_type_controller.h" |
62 #include "components/sync_sessions/sessions_sync_manager.h" | 61 #include "components/sync_sessions/sessions_sync_manager.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // Backup is needed if user's not signed in or signed in but previous | 331 // Backup is needed if user's not signed in or signed in but previous |
333 // backup didn't finish, i.e. backend didn't switch from backup to sync. | 332 // backup didn't finish, i.e. backend didn't switch from backup to sync. |
334 need_backup_ = !IsSignedIn() || sync_prefs_.GetFirstSyncTime().is_null(); | 333 need_backup_ = !IsSignedIn() || sync_prefs_.GetFirstSyncTime().is_null(); |
335 | 334 |
336 // Try to resume rollback if it didn't finish in last session. | 335 // Try to resume rollback if it didn't finish in last session. |
337 running_rollback = backup_rollback_controller_->StartRollback(); | 336 running_rollback = backup_rollback_controller_->StartRollback(); |
338 } else { | 337 } else { |
339 need_backup_ = false; | 338 need_backup_ = false; |
340 } | 339 } |
341 | 340 |
342 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 341 #if defined(ENABLE_PRE_SYNC_BACKUP) |
343 if (!running_rollback && !IsSignedIn()) { | 342 if (!running_rollback && !IsSignedIn()) { |
344 CleanUpBackup(); | 343 CleanUpBackup(); |
345 } | 344 } |
346 #else | 345 #else |
347 DCHECK(!running_rollback); | 346 DCHECK(!running_rollback); |
348 #endif | 347 #endif |
349 | 348 |
350 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind( | 349 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind( |
351 &ProfileSyncService::OnMemoryPressure, weak_factory_.GetWeakPtr()))); | 350 &ProfileSyncService::OnMemoryPressure, weak_factory_.GetWeakPtr()))); |
352 startup_controller_->Reset(GetRegisteredDataTypes()); | 351 startup_controller_->Reset(GetRegisteredDataTypes()); |
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 if (first_sync_time.is_null()) | 2559 if (first_sync_time.is_null()) |
2561 return; | 2560 return; |
2562 | 2561 |
2563 sync_client_->GetClearBrowsingDataCallback().Run(first_sync_time, | 2562 sync_client_->GetClearBrowsingDataCallback().Run(first_sync_time, |
2564 base::Time::Now()); | 2563 base::Time::Now()); |
2565 } | 2564 } |
2566 | 2565 |
2567 void ProfileSyncService::CheckSyncBackupIfNeeded() { | 2566 void ProfileSyncService::CheckSyncBackupIfNeeded() { |
2568 DCHECK_EQ(backend_mode_, SYNC); | 2567 DCHECK_EQ(backend_mode_, SYNC); |
2569 | 2568 |
2570 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 2569 #if defined(ENABLE_PRE_SYNC_BACKUP) |
2571 const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime(); | 2570 const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime(); |
2572 // Check backup once a day. | 2571 // Check backup once a day. |
2573 if (!last_backup_time_ && | 2572 if (!last_backup_time_ && |
2574 (last_synced_time.is_null() || | 2573 (last_synced_time.is_null() || |
2575 base::Time::Now() - last_synced_time >= | 2574 base::Time::Now() - last_synced_time >= |
2576 base::TimeDelta::FromDays(1))) { | 2575 base::TimeDelta::FromDays(1))) { |
2577 // If sync thread is set, need to serialize check on sync thread after | 2576 // If sync thread is set, need to serialize check on sync thread after |
2578 // closing backup DB. | 2577 // closing backup DB. |
2579 if (sync_thread_) { | 2578 if (sync_thread_) { |
2580 sync_thread_->task_runner()->PostTask( | 2579 sync_thread_->task_runner()->PostTask( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 } | 2703 } |
2705 | 2704 |
2706 std::string ProfileSyncService::unrecoverable_error_message() const { | 2705 std::string ProfileSyncService::unrecoverable_error_message() const { |
2707 return unrecoverable_error_message_; | 2706 return unrecoverable_error_message_; |
2708 } | 2707 } |
2709 | 2708 |
2710 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() | 2709 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() |
2711 const { | 2710 const { |
2712 return unrecoverable_error_location_; | 2711 return unrecoverable_error_location_; |
2713 } | 2712 } |
OLD | NEW |