| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/common/service_process_util.h" | 32 #include "chrome/common/service_process_util.h" |
| 33 #include "chrome/grit/chromium_strings.h" | 33 #include "chrome/grit/chromium_strings.h" |
| 34 #include "chrome/grit/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
| 35 #include "chrome/service/cloud_print/cloud_print_message_handler.h" | 35 #include "chrome/service/cloud_print/cloud_print_message_handler.h" |
| 36 #include "chrome/service/cloud_print/cloud_print_proxy.h" | 36 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
| 37 #include "chrome/service/net/service_url_request_context_getter.h" | 37 #include "chrome/service/net/service_url_request_context_getter.h" |
| 38 #include "chrome/service/service_process_prefs.h" | 38 #include "chrome/service/service_process_prefs.h" |
| 39 #include "components/network_session_configurator/switches.h" | 39 #include "components/network_session_configurator/switches.h" |
| 40 #include "components/prefs/json_pref_store.h" | 40 #include "components/prefs/json_pref_store.h" |
| 41 #include "mojo/edk/embedder/embedder.h" |
| 42 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 41 #include "net/base/network_change_notifier.h" | 43 #include "net/base/network_change_notifier.h" |
| 42 #include "net/url_request/url_fetcher.h" | 44 #include "net/url_request/url_fetcher.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "ui/base/material_design/material_design_controller.h" | 46 #include "ui/base/material_design/material_design_controller.h" |
| 45 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| 46 #include "ui/base/ui_base_switches.h" | 48 #include "ui/base/ui_base_switches.h" |
| 47 | 49 |
| 48 #if defined(USE_GLIB) | 50 #if defined(USE_GLIB) |
| 49 #include <glib-object.h> | 51 #include <glib-object.h> |
| 50 #endif | 52 #endif |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 io_thread_.reset(new ServiceIOThread("ServiceProcess_IO")); | 149 io_thread_.reset(new ServiceIOThread("ServiceProcess_IO")); |
| 148 file_thread_.reset(new base::Thread("ServiceProcess_File")); | 150 file_thread_.reset(new base::Thread("ServiceProcess_File")); |
| 149 if (!io_thread_->StartWithOptions(options) || | 151 if (!io_thread_->StartWithOptions(options) || |
| 150 !file_thread_->StartWithOptions(options)) { | 152 !file_thread_->StartWithOptions(options)) { |
| 151 NOTREACHED(); | 153 NOTREACHED(); |
| 152 Teardown(); | 154 Teardown(); |
| 153 return false; | 155 return false; |
| 154 } | 156 } |
| 155 blocking_pool_ = new base::SequencedWorkerPool(3, "ServiceBlocking"); | 157 blocking_pool_ = new base::SequencedWorkerPool(3, "ServiceBlocking"); |
| 156 | 158 |
| 159 // Initialize Mojo early so things can use it. |
| 160 mojo::edk::Init(); |
| 161 mojo_ipc_support_.reset( |
| 162 new mojo::edk::ScopedIPCSupport(io_thread_->task_runner())); |
| 163 |
| 157 request_context_getter_ = new ServiceURLRequestContextGetter(); | 164 request_context_getter_ = new ServiceURLRequestContextGetter(); |
| 158 | 165 |
| 159 base::FilePath user_data_dir; | 166 base::FilePath user_data_dir; |
| 160 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 167 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 161 base::FilePath pref_path = | 168 base::FilePath pref_path = |
| 162 user_data_dir.Append(chrome::kServiceStateFileName); | 169 user_data_dir.Append(chrome::kServiceStateFileName); |
| 163 service_prefs_.reset(new ServiceProcessPrefs( | 170 service_prefs_.reset(new ServiceProcessPrefs( |
| 164 pref_path, | 171 pref_path, |
| 165 JsonPrefStore::GetTaskRunnerForFile(pref_path, blocking_pool_.get()) | 172 JsonPrefStore::GetTaskRunnerForFile(pref_path, blocking_pool_.get()) |
| 166 .get())); | 173 .get())); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // See if we need to stay running. | 225 // See if we need to stay running. |
| 219 ScheduleShutdownCheck(); | 226 ScheduleShutdownCheck(); |
| 220 | 227 |
| 221 return true; | 228 return true; |
| 222 } | 229 } |
| 223 | 230 |
| 224 bool ServiceProcess::Teardown() { | 231 bool ServiceProcess::Teardown() { |
| 225 service_prefs_.reset(); | 232 service_prefs_.reset(); |
| 226 cloud_print_proxy_.reset(); | 233 cloud_print_proxy_.reset(); |
| 227 | 234 |
| 235 mojo_ipc_support_.reset(); |
| 228 ipc_server_.reset(); | 236 ipc_server_.reset(); |
| 229 // Signal this event before shutting down the service process. That way all | 237 // Signal this event before shutting down the service process. That way all |
| 230 // background threads can cleanup. | 238 // background threads can cleanup. |
| 231 shutdown_event_.Signal(); | 239 shutdown_event_.Signal(); |
| 232 io_thread_.reset(); | 240 io_thread_.reset(); |
| 233 file_thread_.reset(); | 241 file_thread_.reset(); |
| 234 | 242 |
| 235 if (blocking_pool_.get()) { | 243 if (blocking_pool_.get()) { |
| 236 // The goal is to make it impossible for chrome to 'infinite loop' during | 244 // The goal is to make it impossible for chrome to 'infinite loop' during |
| 237 // shutdown, but to reasonably expect that all BLOCKING_SHUTDOWN tasks | 245 // shutdown, but to reasonably expect that all BLOCKING_SHUTDOWN tasks |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } else { | 376 } else { |
| 369 Shutdown(); | 377 Shutdown(); |
| 370 } | 378 } |
| 371 } | 379 } |
| 372 } | 380 } |
| 373 | 381 |
| 374 ServiceProcess::~ServiceProcess() { | 382 ServiceProcess::~ServiceProcess() { |
| 375 Teardown(); | 383 Teardown(); |
| 376 g_service_process = NULL; | 384 g_service_process = NULL; |
| 377 } | 385 } |
| OLD | NEW |