| 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/service/service_process.h" | 5 #include "chrome/service/service_process.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/environment.h" | 14 #include "base/environment.h" |
| 14 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 15 #include "base/location.h" | 16 #include "base/location.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 18 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
| 19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 21 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
| 25 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
| 24 #include "base/task_scheduler/task_scheduler.h" | 26 #include "base/task_scheduler/task_scheduler.h" |
| 25 #include "base/threading/sequenced_worker_pool.h" | 27 #include "base/threading/sequenced_worker_pool.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 28 #include "base/values.h" | 30 #include "base/values.h" |
| 29 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 30 #include "chrome/common/chrome_constants.h" | 32 #include "chrome/common/chrome_constants.h" |
| 31 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/env_vars.h" | 35 #include "chrome/common/env_vars.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 file_thread_.reset(new base::Thread("ServiceProcess_File")); | 157 file_thread_.reset(new base::Thread("ServiceProcess_File")); |
| 156 if (!io_thread_->StartWithOptions(options) || | 158 if (!io_thread_->StartWithOptions(options) || |
| 157 !file_thread_->StartWithOptions(options)) { | 159 !file_thread_->StartWithOptions(options)) { |
| 158 NOTREACHED(); | 160 NOTREACHED(); |
| 159 Teardown(); | 161 Teardown(); |
| 160 return false; | 162 return false; |
| 161 } | 163 } |
| 162 | 164 |
| 163 // Initialize TaskScheduler and redirect SequencedWorkerPool tasks to it. | 165 // Initialize TaskScheduler and redirect SequencedWorkerPool tasks to it. |
| 164 constexpr int kMaxTaskSchedulerThreads = 3; | 166 constexpr int kMaxTaskSchedulerThreads = 3; |
| 165 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( | 167 std::vector<base::SchedulerWorkerPoolParams> worker_pool_params_vector; |
| 166 kMaxTaskSchedulerThreads); | 168 worker_pool_params_vector.emplace_back( |
| 169 "CloudPrintServiceProcess", base::ThreadPriority::NORMAL, |
| 170 base::SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY, |
| 171 kMaxTaskSchedulerThreads, base::TimeDelta::FromSeconds(30), |
| 172 base::SchedulerBackwardCompatibility::INIT_COM_STA); |
| 173 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( |
| 174 worker_pool_params_vector, |
| 175 base::Bind([](const base::TaskTraits&) -> size_t { return 0; })); |
| 167 base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(); | 176 base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(); |
| 168 | 177 |
| 169 blocking_pool_ = new base::SequencedWorkerPool( | 178 blocking_pool_ = |
| 170 3, "ServiceBlocking", base::TaskPriority::USER_VISIBLE); | 179 new base::SequencedWorkerPool(kMaxTaskSchedulerThreads, "ServiceBlocking", |
| 180 base::TaskPriority::USER_VISIBLE); |
| 171 | 181 |
| 172 // Initialize Mojo early so things can use it. | 182 // Initialize Mojo early so things can use it. |
| 173 mojo::edk::Init(); | 183 mojo::edk::Init(); |
| 174 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( | 184 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( |
| 175 io_thread_->task_runner(), | 185 io_thread_->task_runner(), |
| 176 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST)); | 186 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST)); |
| 177 | 187 |
| 178 request_context_getter_ = new ServiceURLRequestContextGetter(); | 188 request_context_getter_ = new ServiceURLRequestContextGetter(); |
| 179 | 189 |
| 180 base::FilePath user_data_dir; | 190 base::FilePath user_data_dir; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } else { | 435 } else { |
| 426 Shutdown(); | 436 Shutdown(); |
| 427 } | 437 } |
| 428 } | 438 } |
| 429 } | 439 } |
| 430 | 440 |
| 431 ServiceProcess::~ServiceProcess() { | 441 ServiceProcess::~ServiceProcess() { |
| 432 Teardown(); | 442 Teardown(); |
| 433 g_service_process = NULL; | 443 g_service_process = NULL; |
| 434 } | 444 } |
| OLD | NEW |