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/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // See if we need to stay running. | 202 // See if we need to stay running. |
203 ScheduleShutdownCheck(); | 203 ScheduleShutdownCheck(); |
204 | 204 |
205 // Occasionally check to see if we need to launch the browser to get the | 205 // Occasionally check to see if we need to launch the browser to get the |
206 // policy state information. | 206 // policy state information. |
207 CloudPrintPolicyCheckIfNeeded(); | 207 CloudPrintPolicyCheckIfNeeded(); |
208 return true; | 208 return true; |
209 } | 209 } |
210 | 210 |
211 bool ServiceProcess::Teardown() { | 211 bool ServiceProcess::Teardown() { |
| 212 if (request_context_getter_.get()) |
| 213 request_context_getter_->StartTearDown(); |
212 service_prefs_.reset(); | 214 service_prefs_.reset(); |
213 cloud_print_proxy_.reset(); | 215 cloud_print_proxy_.reset(); |
214 | 216 |
215 ipc_server_.reset(); | 217 ipc_server_.reset(); |
216 // Signal this event before shutting down the service process. That way all | 218 // Signal this event before shutting down the service process. That way all |
217 // background threads can cleanup. | 219 // background threads can cleanup. |
218 shutdown_event_.Signal(); | 220 shutdown_event_.Signal(); |
219 io_thread_.reset(); | 221 io_thread_.reset(); |
220 file_thread_.reset(); | 222 file_thread_.reset(); |
| 223 // The ServiceURLRequestContextGetter must be destroyed after the other |
| 224 // threads so that its shutdown tasks have a chance to run. |
| 225 request_context_getter_ = NULL; |
221 // The NetworkChangeNotifier must be destroyed after all other threads that | 226 // The NetworkChangeNotifier must be destroyed after all other threads that |
222 // might use it have been shut down. | 227 // might use it have been shut down. |
223 network_change_notifier_.reset(); | 228 network_change_notifier_.reset(); |
224 | 229 |
225 service_process_state_->SignalStopped(); | 230 service_process_state_->SignalStopped(); |
226 return true; | 231 return true; |
227 } | 232 } |
228 | 233 |
229 // This method is called when a shutdown command is received from IPC channel | 234 // This method is called when a shutdown command is received from IPC channel |
230 // or there was an error in the IPC channel. | 235 // or there was an error in the IPC channel. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 if (enabled_services_ && !ipc_server_->is_client_connected()) { | 355 if (enabled_services_ && !ipc_server_->is_client_connected()) { |
351 GetCloudPrintProxy()->CheckCloudPrintProxyPolicy(); | 356 GetCloudPrintProxy()->CheckCloudPrintProxyPolicy(); |
352 } | 357 } |
353 ScheduleCloudPrintPolicyCheck(); | 358 ScheduleCloudPrintPolicyCheck(); |
354 } | 359 } |
355 | 360 |
356 ServiceProcess::~ServiceProcess() { | 361 ServiceProcess::~ServiceProcess() { |
357 Teardown(); | 362 Teardown(); |
358 g_service_process = NULL; | 363 g_service_process = NULL; |
359 } | 364 } |
OLD | NEW |