| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/glue/sync_start_util.h" | 5 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
| 13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 13 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 void StartSyncOnUIThread(const base::FilePath& profile, | 18 void StartSyncOnUIThread(const base::FilePath& profile, |
| 19 syncer::ModelType type) { | 19 syncer::ModelType type) { |
| 20 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 20 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 21 if (!profile_manager) { |
| 22 // Can happen in tests. |
| 23 DVLOG(2) << "No ProfileManager, can't start sync."; |
| 24 return; |
| 25 } |
| 26 |
| 21 Profile* p = profile_manager->GetProfileByPath(profile); | 27 Profile* p = profile_manager->GetProfileByPath(profile); |
| 22 if (!p) { | 28 if (!p) { |
| 23 DVLOG(2) << "Profile not found, can't start sync."; | 29 DVLOG(2) << "Profile not found, can't start sync."; |
| 24 return; | 30 return; |
| 25 } | 31 } |
| 26 | 32 |
| 27 ProfileSyncService* service = ProfileSyncServiceFactory::GetForProfile(p); | 33 ProfileSyncService* service = ProfileSyncServiceFactory::GetForProfile(p); |
| 28 if (!service) { | 34 if (!service) { |
| 29 DVLOG(2) << "No ProfileSyncService for profile, can't start sync."; | 35 DVLOG(2) << "No ProfileSyncService for profile, can't start sync."; |
| 30 return; | 36 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 42 } // namespace | 48 } // namespace |
| 43 | 49 |
| 44 namespace sync_start_util { | 50 namespace sync_start_util { |
| 45 | 51 |
| 46 syncer::SyncableService::StartSyncFlare GetFlareForSyncableService( | 52 syncer::SyncableService::StartSyncFlare GetFlareForSyncableService( |
| 47 const base::FilePath& profile_path) { | 53 const base::FilePath& profile_path) { |
| 48 return base::Bind(&StartSyncProxy, profile_path); | 54 return base::Bind(&StartSyncProxy, profile_path); |
| 49 } | 55 } |
| 50 | 56 |
| 51 } // namespace sync_start_util | 57 } // namespace sync_start_util |
| OLD | NEW |