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 "chrome/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/atomic_ref_count.h" | 14 #include "base/atomic_ref_count.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/debug/crash_logging.h" | 18 #include "base/debug/crash_logging.h" |
19 #include "base/debug/leak_annotations.h" | 19 #include "base/debug/leak_annotations.h" |
20 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
21 #include "base/location.h" | 21 #include "base/location.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
24 #include "base/metrics/histogram_macros.h" | 24 #include "base/metrics/histogram_macros.h" |
25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
26 #include "base/run_loop.h" | 26 #include "base/run_loop.h" |
27 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
28 #include "base/synchronization/waitable_event.h" | 28 #include "base/synchronization/waitable_event.h" |
29 #include "base/threading/sequenced_worker_pool.h" | 29 #include "base/task_scheduler/post_task.h" |
30 #include "base/threading/thread.h" | 30 #include "base/threading/thread.h" |
31 #include "base/threading/thread_restrictions.h" | 31 #include "base/threading/thread_restrictions.h" |
32 #include "base/threading/thread_task_runner_handle.h" | 32 #include "base/threading/thread_task_runner_handle.h" |
33 #include "base/time/default_clock.h" | 33 #include "base/time/default_clock.h" |
34 #include "base/time/default_tick_clock.h" | 34 #include "base/time/default_tick_clock.h" |
35 #include "base/trace_event/trace_event.h" | 35 #include "base/trace_event/trace_event.h" |
36 #include "build/build_config.h" | 36 #include "build/build_config.h" |
37 #include "chrome/browser/chrome_browser_main.h" | 37 #include "chrome/browser/chrome_browser_main.h" |
38 #include "chrome/browser/chrome_child_process_watcher.h" | 38 #include "chrome/browser/chrome_child_process_watcher.h" |
39 #include "chrome/browser/chrome_content_browser_client.h" | 39 #include "chrome/browser/chrome_content_browser_client.h" |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 | 1217 |
1218 void BrowserProcessImpl::CreateSubresourceFilterRulesetService() { | 1218 void BrowserProcessImpl::CreateSubresourceFilterRulesetService() { |
1219 DCHECK(!subresource_filter_ruleset_service_); | 1219 DCHECK(!subresource_filter_ruleset_service_); |
1220 created_subresource_filter_ruleset_service_ = true; | 1220 created_subresource_filter_ruleset_service_ = true; |
1221 | 1221 |
1222 if (!base::FeatureList::IsEnabled( | 1222 if (!base::FeatureList::IsEnabled( |
1223 subresource_filter::kSafeBrowsingSubresourceFilter)) { | 1223 subresource_filter::kSafeBrowsingSubresourceFilter)) { |
1224 return; | 1224 return; |
1225 } | 1225 } |
1226 | 1226 |
1227 base::SequencedWorkerPool* blocking_pool = | |
1228 content::BrowserThread::GetBlockingPool(); | |
1229 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | 1227 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
1230 blocking_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 1228 base::CreateSequencedTaskRunnerWithTraits( |
1231 blocking_pool->GetSequenceToken(), | 1229 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
1232 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 1230 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); |
1233 | 1231 |
1234 base::FilePath user_data_dir; | 1232 base::FilePath user_data_dir; |
1235 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 1233 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
1236 base::FilePath indexed_ruleset_base_dir = | 1234 base::FilePath indexed_ruleset_base_dir = |
1237 user_data_dir.Append(subresource_filter::kTopLevelDirectoryName) | 1235 user_data_dir.Append(subresource_filter::kTopLevelDirectoryName) |
1238 .Append(subresource_filter::kIndexedRulesetBaseDirectoryName); | 1236 .Append(subresource_filter::kIndexedRulesetBaseDirectoryName); |
1239 subresource_filter_ruleset_service_ = | 1237 subresource_filter_ruleset_service_ = |
1240 base::MakeUnique<subresource_filter::ContentRulesetService>( | 1238 base::MakeUnique<subresource_filter::ContentRulesetService>( |
1241 blocking_task_runner); | 1239 blocking_task_runner); |
1242 subresource_filter_ruleset_service_->set_ruleset_service( | 1240 subresource_filter_ruleset_service_->set_ruleset_service( |
1243 base::MakeUnique<subresource_filter::RulesetService>( | 1241 base::MakeUnique<subresource_filter::RulesetService>( |
1244 local_state(), blocking_task_runner, | 1242 local_state(), blocking_task_runner, |
1245 subresource_filter_ruleset_service_.get(), indexed_ruleset_base_dir)); | 1243 subresource_filter_ruleset_service_.get(), indexed_ruleset_base_dir)); |
1246 } | 1244 } |
1247 | 1245 |
1248 void BrowserProcessImpl::CreateGCMDriver() { | 1246 void BrowserProcessImpl::CreateGCMDriver() { |
1249 DCHECK(!gcm_driver_); | 1247 DCHECK(!gcm_driver_); |
1250 | 1248 |
1251 #if defined(OS_ANDROID) | 1249 #if defined(OS_ANDROID) |
1252 // Android's GCMDriver currently makes the assumption that it's a singleton. | 1250 // Android's GCMDriver currently makes the assumption that it's a singleton. |
1253 // Until this gets fixed, instantiating multiple Java GCMDrivers will throw | 1251 // Until this gets fixed, instantiating multiple Java GCMDrivers will throw |
1254 // an exception, but because they're only initialized on demand these crashes | 1252 // an exception, but because they're only initialized on demand these crashes |
1255 // would be very difficult to triage. See http://crbug.com/437827. | 1253 // would be very difficult to triage. See http://crbug.com/437827. |
1256 NOTREACHED(); | 1254 NOTREACHED(); |
1257 #else | 1255 #else |
1258 base::FilePath store_path; | 1256 base::FilePath store_path; |
1259 CHECK(PathService::Get(chrome::DIR_GLOBAL_GCM_STORE, &store_path)); | 1257 CHECK(PathService::Get(chrome::DIR_GLOBAL_GCM_STORE, &store_path)); |
1260 base::SequencedWorkerPool* worker_pool = | |
1261 content::BrowserThread::GetBlockingPool(); | |
1262 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | 1258 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
1263 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 1259 base::CreateSequencedTaskRunnerWithTraits( |
1264 worker_pool->GetSequenceToken(), | 1260 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
1265 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 1261 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); |
1266 | 1262 |
1267 gcm_driver_ = gcm::CreateGCMDriverDesktop( | 1263 gcm_driver_ = gcm::CreateGCMDriverDesktop( |
1268 base::WrapUnique(new gcm::GCMClientFactory), local_state(), store_path, | 1264 base::WrapUnique(new gcm::GCMClientFactory), local_state(), store_path, |
1269 system_request_context(), chrome::GetChannel(), | 1265 system_request_context(), chrome::GetChannel(), |
1270 gcm::GetProductCategoryForSubtypes(local_state()), | 1266 gcm::GetProductCategoryForSubtypes(local_state()), |
1271 content::BrowserThread::GetTaskRunnerForThread( | 1267 content::BrowserThread::GetTaskRunnerForThread( |
1272 content::BrowserThread::UI), | 1268 content::BrowserThread::UI), |
1273 content::BrowserThread::GetTaskRunnerForThread( | 1269 content::BrowserThread::GetTaskRunnerForThread( |
1274 content::BrowserThread::IO), | 1270 content::BrowserThread::IO), |
1275 blocking_task_runner); | 1271 blocking_task_runner); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 } | 1423 } |
1428 | 1424 |
1429 void BrowserProcessImpl::OnAutoupdateTimer() { | 1425 void BrowserProcessImpl::OnAutoupdateTimer() { |
1430 if (CanAutorestartForUpdate()) { | 1426 if (CanAutorestartForUpdate()) { |
1431 DLOG(WARNING) << "Detected update. Restarting browser."; | 1427 DLOG(WARNING) << "Detected update. Restarting browser."; |
1432 RestartBackgroundInstance(); | 1428 RestartBackgroundInstance(); |
1433 } | 1429 } |
1434 } | 1430 } |
1435 | 1431 |
1436 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1432 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |