OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/file_version_info.h" | 7 #include "base/file_version_info.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_version_info.h" | 10 #include "chrome/app/chrome_version_info.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
13 #include "chrome/browser/sync/glue/change_processor.h" | 13 #include "chrome/browser/sync/glue/change_processor.h" |
14 #include "chrome/browser/sync/glue/database_model_worker.h" | 14 #include "chrome/browser/sync/glue/database_model_worker.h" |
15 #include "chrome/browser/sync/glue/history_model_worker.h" | 15 #include "chrome/browser/sync/glue/history_model_worker.h" |
16 #include "chrome/browser/sync/glue/sync_backend_host.h" | 16 #include "chrome/browser/sync/glue/sync_backend_host.h" |
17 #include "chrome/browser/sync/glue/http_bridge.h" | 17 #include "chrome/browser/sync/glue/http_bridge.h" |
| 18 #include "chrome/browser/sync/glue/password_model_worker.h" |
18 #include "chrome/browser/sync/sessions/session_state.h" | 19 #include "chrome/browser/sync/sessions/session_state.h" |
19 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
20 #include "chrome/common/notification_type.h" | 21 #include "chrome/common/notification_type.h" |
21 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
22 | 23 |
23 static const int kSaveChangesIntervalSeconds = 10; | 24 static const int kSaveChangesIntervalSeconds = 10; |
24 static const char kGaiaServiceId[] = "chromiumsync"; | 25 static const char kGaiaServiceId[] = "chromiumsync"; |
25 static const char kGaiaSourceForChrome[] = "ChromiumBrowser"; | 26 static const char kGaiaSourceForChrome[] = "ChromiumBrowser"; |
26 static const FilePath::CharType kSyncDataFolderName[] = | 27 static const FilePath::CharType kSyncDataFolderName[] = |
27 FILE_PATH_LITERAL("Sync Data"); | 28 FILE_PATH_LITERAL("Sync Data"); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return; | 78 return; |
78 | 79 |
79 // Create a worker for the UI thread and route bookmark changes to it. | 80 // Create a worker for the UI thread and route bookmark changes to it. |
80 // TODO(tim): Pull this into a method to reuse. For now we don't even | 81 // TODO(tim): Pull this into a method to reuse. For now we don't even |
81 // need to lock because we init before the syncapi exists and we tear down | 82 // need to lock because we init before the syncapi exists and we tear down |
82 // after the syncapi is destroyed. Make sure to NULL-check workers_ indices | 83 // after the syncapi is destroyed. Make sure to NULL-check workers_ indices |
83 // when a new type is synced as the worker may already exist and you just | 84 // when a new type is synced as the worker may already exist and you just |
84 // need to update routing_info_. | 85 // need to update routing_info_. |
85 registrar_.workers[GROUP_DB] = new DatabaseModelWorker(); | 86 registrar_.workers[GROUP_DB] = new DatabaseModelWorker(); |
86 registrar_.workers[GROUP_HISTORY] = | 87 registrar_.workers[GROUP_HISTORY] = |
87 new HistoryModelWorker( | 88 new HistoryModelWorker( |
88 profile_->GetHistoryService(Profile::IMPLICIT_ACCESS)); | 89 profile_->GetHistoryService(Profile::IMPLICIT_ACCESS)); |
89 registrar_.workers[GROUP_UI] = new UIModelWorker(frontend_loop_); | 90 registrar_.workers[GROUP_UI] = new UIModelWorker(frontend_loop_); |
90 registrar_.workers[GROUP_PASSIVE] = new ModelSafeWorker(); | 91 registrar_.workers[GROUP_PASSIVE] = new ModelSafeWorker(); |
| 92 registrar_.workers[GROUP_PASSWORD] = |
| 93 new PasswordModelWorker( |
| 94 profile_->GetPasswordStore(Profile::IMPLICIT_ACCESS)); |
91 | 95 |
92 // Any datatypes that we want the syncer to pull down must | 96 // Any datatypes that we want the syncer to pull down must |
93 // be in the routing_info map. We set them to group passive, meaning that | 97 // be in the routing_info map. We set them to group passive, meaning that |
94 // updates will be applied, but not dispatched to the UI thread yet. | 98 // updates will be applied, but not dispatched to the UI thread yet. |
95 for (syncable::ModelTypeSet::const_iterator it = types.begin(); | 99 for (syncable::ModelTypeSet::const_iterator it = types.begin(); |
96 it != types.end(); ++it) { | 100 it != types.end(); ++it) { |
97 registrar_.routing_info[(*it)] = GROUP_PASSIVE; | 101 registrar_.routing_info[(*it)] = GROUP_PASSIVE; |
98 } | 102 } |
99 | 103 |
100 core_thread_.message_loop()->PostTask(FROM_HERE, | 104 core_thread_.message_loop()->PostTask(FROM_HERE, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // initialized. For now this only ever happens at sync-enabled-Chrome exit, | 150 // initialized. For now this only ever happens at sync-enabled-Chrome exit, |
147 // meaning bug 1482548 applies to prolonged "waiting" that may occur in | 151 // meaning bug 1482548 applies to prolonged "waiting" that may occur in |
148 // DoShutdown. | 152 // DoShutdown. |
149 core_thread_.Stop(); | 153 core_thread_.Stop(); |
150 | 154 |
151 registrar_.routing_info.clear(); | 155 registrar_.routing_info.clear(); |
152 registrar_.workers[GROUP_DB] = NULL; | 156 registrar_.workers[GROUP_DB] = NULL; |
153 registrar_.workers[GROUP_HISTORY] = NULL; | 157 registrar_.workers[GROUP_HISTORY] = NULL; |
154 registrar_.workers[GROUP_UI] = NULL; | 158 registrar_.workers[GROUP_UI] = NULL; |
155 registrar_.workers[GROUP_PASSIVE] = NULL; | 159 registrar_.workers[GROUP_PASSIVE] = NULL; |
| 160 registrar_.workers[GROUP_PASSWORD] = NULL; |
156 registrar_.workers.erase(GROUP_DB); | 161 registrar_.workers.erase(GROUP_DB); |
157 registrar_.workers.erase(GROUP_HISTORY); | 162 registrar_.workers.erase(GROUP_HISTORY); |
158 registrar_.workers.erase(GROUP_UI); | 163 registrar_.workers.erase(GROUP_UI); |
159 registrar_.workers.erase(GROUP_PASSIVE); | 164 registrar_.workers.erase(GROUP_PASSIVE); |
| 165 registrar_.workers.erase(GROUP_PASSWORD); |
160 frontend_ = NULL; | 166 frontend_ = NULL; |
161 core_ = NULL; // Releases reference to core_. | 167 core_ = NULL; // Releases reference to core_. |
162 } | 168 } |
163 | 169 |
164 void SyncBackendHost::ConfigureDataTypes(const syncable::ModelTypeSet& types, | 170 void SyncBackendHost::ConfigureDataTypes(const syncable::ModelTypeSet& types, |
165 CancelableTask* ready_task) { | 171 CancelableTask* ready_task) { |
166 // Only one configure is allowed at a time. | 172 // Only one configure is allowed at a time. |
167 DCHECK(!configure_ready_task_.get()); | 173 DCHECK(!configure_ready_task_.get()); |
168 AutoLock lock(registrar_lock_); | 174 AutoLock lock(registrar_lock_); |
169 bool has_new = false; | 175 bool has_new = false; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 } | 562 } |
557 | 563 |
558 void SyncBackendHost::Core::DeleteSyncDataFolder() { | 564 void SyncBackendHost::Core::DeleteSyncDataFolder() { |
559 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { | 565 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { |
560 if (!file_util::Delete(host_->sync_data_folder_path(), true)) | 566 if (!file_util::Delete(host_->sync_data_folder_path(), true)) |
561 LOG(DFATAL) << "Could not delete the Sync Data folder."; | 567 LOG(DFATAL) << "Could not delete the Sync Data folder."; |
562 } | 568 } |
563 } | 569 } |
564 | 570 |
565 } // namespace browser_sync | 571 } // namespace browser_sync |
OLD | NEW |