OLD | NEW |
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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "base/threading/thread_restrictions.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
14 #include "chrome/browser/net/gaia/token_service.h" | 15 #include "chrome/browser/net/gaia/token_service.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/sync/engine/syncapi.h" | 18 #include "chrome/browser/sync/engine/syncapi.h" |
18 #include "chrome/browser/sync/glue/autofill_model_associator.h" | 19 #include "chrome/browser/sync/glue/autofill_model_associator.h" |
19 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h" | 20 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h" |
20 #include "chrome/browser/sync/glue/change_processor.h" | 21 #include "chrome/browser/sync/glue/change_processor.h" |
21 #include "chrome/browser/sync/glue/database_model_worker.h" | 22 #include "chrome/browser/sync/glue/database_model_worker.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 if (ui_worker()) | 234 if (ui_worker()) |
234 ui_worker()->Stop(); | 235 ui_worker()->Stop(); |
235 | 236 |
236 // Stop will return once the thread exits, which will be after DoShutdown | 237 // Stop will return once the thread exits, which will be after DoShutdown |
237 // runs. DoShutdown needs to run from core_thread_ because the sync backend | 238 // runs. DoShutdown needs to run from core_thread_ because the sync backend |
238 // requires any thread that opened sqlite handles to relinquish them | 239 // requires any thread that opened sqlite handles to relinquish them |
239 // personally. We need to join threads, because otherwise the main Chrome | 240 // personally. We need to join threads, because otherwise the main Chrome |
240 // thread (ui loop) can exit before DoShutdown finishes, at which point | 241 // thread (ui loop) can exit before DoShutdown finishes, at which point |
241 // virtually anything the sync backend does (or the post-back to | 242 // virtually anything the sync backend does (or the post-back to |
242 // frontend_loop_ by our Core) will epically fail because the CRT won't be | 243 // frontend_loop_ by our Core) will epically fail because the CRT won't be |
243 // initialized. For now this only ever happens at sync-enabled-Chrome exit, | 244 // initialized. |
244 // meaning bug 1482548 applies to prolonged "waiting" that may occur in | 245 // Since we are blocking the UI thread here, we need to turn ourselves in |
245 // DoShutdown. | 246 // with the ThreadRestriction police. For sentencing and how we plan to fix |
246 core_thread_.Stop(); | 247 // this, see bug 19757. |
| 248 { |
| 249 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 250 core_thread_.Stop(); |
| 251 } |
247 | 252 |
248 registrar_.routing_info.clear(); | 253 registrar_.routing_info.clear(); |
249 registrar_.workers[GROUP_DB] = NULL; | 254 registrar_.workers[GROUP_DB] = NULL; |
250 registrar_.workers[GROUP_HISTORY] = NULL; | 255 registrar_.workers[GROUP_HISTORY] = NULL; |
251 registrar_.workers[GROUP_UI] = NULL; | 256 registrar_.workers[GROUP_UI] = NULL; |
252 registrar_.workers[GROUP_PASSIVE] = NULL; | 257 registrar_.workers[GROUP_PASSIVE] = NULL; |
253 registrar_.workers[GROUP_PASSWORD] = NULL; | 258 registrar_.workers[GROUP_PASSWORD] = NULL; |
254 registrar_.workers.erase(GROUP_DB); | 259 registrar_.workers.erase(GROUP_DB); |
255 registrar_.workers.erase(GROUP_HISTORY); | 260 registrar_.workers.erase(GROUP_HISTORY); |
256 registrar_.workers.erase(GROUP_UI); | 261 registrar_.workers.erase(GROUP_UI); |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 } | 893 } |
889 | 894 |
890 void SyncBackendHost::Core::DeleteSyncDataFolder() { | 895 void SyncBackendHost::Core::DeleteSyncDataFolder() { |
891 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { | 896 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { |
892 if (!file_util::Delete(host_->sync_data_folder_path(), true)) | 897 if (!file_util::Delete(host_->sync_data_folder_path(), true)) |
893 LOG(DFATAL) << "Could not delete the Sync Data folder."; | 898 LOG(DFATAL) << "Could not delete the Sync Data folder."; |
894 } | 899 } |
895 } | 900 } |
896 | 901 |
897 } // namespace browser_sync | 902 } // namespace browser_sync |
OLD | NEW |