| 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 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/environment.h" | 12 #include "base/environment.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 19 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
| 22 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 23 #include "base/threading/sequenced_worker_pool.h" | 24 #include "base/threading/sequenced_worker_pool.h" |
| 24 #include "base/values.h" | 25 #include "base/values.h" |
| 25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 void ServiceIOThread::CleanUp() { | 78 void ServiceIOThread::CleanUp() { |
| 78 net::URLFetcher::CancelAll(); | 79 net::URLFetcher::CancelAll(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 // Prepares the localized strings that are going to be displayed to | 82 // Prepares the localized strings that are going to be displayed to |
| 82 // the user if the service process dies. These strings are stored in the | 83 // the user if the service process dies. These strings are stored in the |
| 83 // environment block so they are accessible in the early stages of the | 84 // environment block so they are accessible in the early stages of the |
| 84 // chrome executable's lifetime. | 85 // chrome executable's lifetime. |
| 85 void PrepareRestartOnCrashEnviroment( | 86 void PrepareRestartOnCrashEnviroment( |
| 86 const base::CommandLine& parsed_command_line) { | 87 const base::CommandLine& parsed_command_line) { |
| 87 scoped_ptr<base::Environment> env(base::Environment::Create()); | 88 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 88 // Clear this var so child processes don't show the dialog by default. | 89 // Clear this var so child processes don't show the dialog by default. |
| 89 env->UnSetVar(env_vars::kShowRestart); | 90 env->UnSetVar(env_vars::kShowRestart); |
| 90 | 91 |
| 91 // For non-interactive tests we don't restart on crash. | 92 // For non-interactive tests we don't restart on crash. |
| 92 if (env->HasVar(env_vars::kHeadless)) | 93 if (env->HasVar(env_vars::kHeadless)) |
| 93 return; | 94 return; |
| 94 | 95 |
| 95 // If the known command-line test options are used we don't create the | 96 // If the known command-line test options are used we don't create the |
| 96 // environment block which means we don't get the restart dialog. | 97 // environment block which means we don't get the restart dialog. |
| 97 if (parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) | 98 if (parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled, false)) { | 194 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled, false)) { |
| 194 GetCloudPrintProxy()->EnableForUser(); | 195 GetCloudPrintProxy()->EnableForUser(); |
| 195 } | 196 } |
| 196 | 197 |
| 197 VLOG(1) << "Starting Service Process IPC Server"; | 198 VLOG(1) << "Starting Service Process IPC Server"; |
| 198 ipc_server_.reset(new ServiceIPCServer( | 199 ipc_server_.reset(new ServiceIPCServer( |
| 199 this /* client */, | 200 this /* client */, |
| 200 io_task_runner(), | 201 io_task_runner(), |
| 201 service_process_state_->GetServiceProcessChannel(), | 202 service_process_state_->GetServiceProcessChannel(), |
| 202 &shutdown_event_)); | 203 &shutdown_event_)); |
| 203 ipc_server_->AddMessageHandler(make_scoped_ptr( | 204 ipc_server_->AddMessageHandler(base::WrapUnique( |
| 204 new cloud_print::CloudPrintMessageHandler(ipc_server_.get(), this))); | 205 new cloud_print::CloudPrintMessageHandler(ipc_server_.get(), this))); |
| 205 ipc_server_->Init(); | 206 ipc_server_->Init(); |
| 206 | 207 |
| 207 // After the IPC server has started we signal that the service process is | 208 // After the IPC server has started we signal that the service process is |
| 208 // ready. | 209 // ready. |
| 209 if (!service_process_state_->SignalReady( | 210 if (!service_process_state_->SignalReady( |
| 210 io_task_runner().get(), | 211 io_task_runner().get(), |
| 211 base::Bind(&ServiceProcess::Terminate, base::Unretained(this)))) { | 212 base::Bind(&ServiceProcess::Terminate, base::Unretained(this)))) { |
| 212 return false; | 213 return false; |
| 213 } | 214 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } else { | 366 } else { |
| 366 Shutdown(); | 367 Shutdown(); |
| 367 } | 368 } |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 | 371 |
| 371 ServiceProcess::~ServiceProcess() { | 372 ServiceProcess::~ServiceProcess() { |
| 372 Teardown(); | 373 Teardown(); |
| 373 g_service_process = NULL; | 374 g_service_process = NULL; |
| 374 } | 375 } |
| OLD | NEW |