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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 6375007: [Sync] Refactored ProfileSyncService and remove its backend() function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compile failure Created 9 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 using browser_sync::DataTypeController; 44 using browser_sync::DataTypeController;
45 typedef TokenService::TokenAvailableDetails TokenAvailableDetails; 45 typedef TokenService::TokenAvailableDetails TokenAvailableDetails;
46 46
47 typedef GoogleServiceAuthError AuthError; 47 typedef GoogleServiceAuthError AuthError;
48 48
49 namespace browser_sync { 49 namespace browser_sync {
50 50
51 using sessions::SyncSessionSnapshot; 51 using sessions::SyncSessionSnapshot;
52 using sync_api::SyncCredentials; 52 using sync_api::SyncCredentials;
53 53
54 SyncBackendHost::SyncBackendHost(SyncFrontend* frontend, Profile* profile) 54 SyncBackendHost::SyncBackendHost(Profile* profile)
55 : core_(new Core(ALLOW_THIS_IN_INITIALIZER_LIST(this))), 55 : core_(new Core(ALLOW_THIS_IN_INITIALIZER_LIST(this))),
56 core_thread_("Chrome_SyncCoreThread"), 56 core_thread_("Chrome_SyncCoreThread"),
57 frontend_loop_(MessageLoop::current()), 57 frontend_loop_(MessageLoop::current()),
58 profile_(profile), 58 profile_(profile),
59 frontend_(frontend), 59 frontend_(NULL),
60 sync_data_folder_path_( 60 sync_data_folder_path_(
61 profile_->GetPath().Append(kSyncDataFolderName)), 61 profile_->GetPath().Append(kSyncDataFolderName)),
62 last_auth_error_(AuthError::None()), 62 last_auth_error_(AuthError::None()),
63 syncapi_initialized_(false) { 63 syncapi_initialized_(false) {
64 } 64 }
65 65
66 SyncBackendHost::SyncBackendHost() 66 SyncBackendHost::SyncBackendHost()
67 : core_thread_("Chrome_SyncCoreThread"), 67 : core_thread_("Chrome_SyncCoreThread"),
68 frontend_loop_(MessageLoop::current()), 68 frontend_loop_(MessageLoop::current()),
69 profile_(NULL), 69 profile_(NULL),
70 frontend_(NULL), 70 frontend_(NULL),
71 last_auth_error_(AuthError::None()), 71 last_auth_error_(AuthError::None()),
72 syncapi_initialized_(false) { 72 syncapi_initialized_(false) {
73 } 73 }
74 74
75 SyncBackendHost::~SyncBackendHost() { 75 SyncBackendHost::~SyncBackendHost() {
76 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; 76 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor.";
77 DCHECK(registrar_.workers.empty()); 77 DCHECK(registrar_.workers.empty());
78 } 78 }
79 79
80 void SyncBackendHost::Initialize( 80 void SyncBackendHost::Initialize(
81 SyncFrontend* frontend,
81 const GURL& sync_service_url, 82 const GURL& sync_service_url,
82 const syncable::ModelTypeSet& types, 83 const syncable::ModelTypeSet& types,
83 URLRequestContextGetter* baseline_context_getter, 84 URLRequestContextGetter* baseline_context_getter,
84 const SyncCredentials& credentials, 85 const SyncCredentials& credentials,
85 bool delete_sync_data_folder, 86 bool delete_sync_data_folder,
86 const notifier::NotifierOptions& notifier_options) { 87 const notifier::NotifierOptions& notifier_options) {
87 if (!core_thread_.Start()) 88 if (!core_thread_.Start())
88 return; 89 return;
89 90
91 frontend_ = frontend;
92 DCHECK(frontend);
93
90 // Create a worker for the UI thread and route bookmark changes to it. 94 // Create a worker for the UI thread and route bookmark changes to it.
91 // TODO(tim): Pull this into a method to reuse. For now we don't even 95 // TODO(tim): Pull this into a method to reuse. For now we don't even
92 // need to lock because we init before the syncapi exists and we tear down 96 // need to lock because we init before the syncapi exists and we tear down
93 // after the syncapi is destroyed. Make sure to NULL-check workers_ indices 97 // after the syncapi is destroyed. Make sure to NULL-check workers_ indices
94 // when a new type is synced as the worker may already exist and you just 98 // when a new type is synced as the worker may already exist and you just
95 // need to update routing_info_. 99 // need to update routing_info_.
96 registrar_.workers[GROUP_DB] = new DatabaseModelWorker(); 100 registrar_.workers[GROUP_DB] = new DatabaseModelWorker();
97 registrar_.workers[GROUP_UI] = new UIModelWorker(frontend_loop_); 101 registrar_.workers[GROUP_UI] = new UIModelWorker(frontend_loop_);
98 registrar_.workers[GROUP_PASSIVE] = new ModelSafeWorker(); 102 registrar_.workers[GROUP_PASSIVE] = new ModelSafeWorker();
99 103
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 } 897 }
894 898
895 void SyncBackendHost::Core::DeleteSyncDataFolder() { 899 void SyncBackendHost::Core::DeleteSyncDataFolder() {
896 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { 900 if (file_util::DirectoryExists(host_->sync_data_folder_path())) {
897 if (!file_util::Delete(host_->sync_data_folder_path(), true)) 901 if (!file_util::Delete(host_->sync_data_folder_path(), true))
898 LOG(DFATAL) << "Could not delete the Sync Data folder."; 902 LOG(DFATAL) << "Could not delete the Sync Data folder.";
899 } 903 }
900 } 904 }
901 905
902 } // namespace browser_sync 906 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698