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/service_process/service_process_control.h" | 5 #include "chrome/browser/service_process/service_process_control.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/metrics/histogram_base.h" | 12 #include "base/metrics/histogram_base.h" |
13 #include "base/metrics/histogram_delta_serialization.h" | 13 #include "base/metrics/histogram_delta_serialization.h" |
14 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
23 #include "chrome/browser/upgrade_detector.h" | 23 #include "chrome/browser/upgrade_detector.h" |
24 #include "chrome/common/service_messages.h" | 24 #include "chrome/common/service_messages.h" |
25 #include "chrome/common/service_process_util.h" | 25 #include "chrome/common/service_process_util.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/common/child_process_host.h" |
28 | 29 |
29 using content::BrowserThread; | 30 using content::BrowserThread; |
30 | 31 |
31 // ServiceProcessControl implementation. | 32 // ServiceProcessControl implementation. |
32 ServiceProcessControl::ServiceProcessControl() { | 33 ServiceProcessControl::ServiceProcessControl() { |
33 } | 34 } |
34 | 35 |
35 ServiceProcessControl::~ServiceProcessControl() { | 36 ServiceProcessControl::~ServiceProcessControl() { |
36 } | 37 } |
37 | 38 |
38 void ServiceProcessControl::ConnectInternal() { | 39 void ServiceProcessControl::ConnectInternal() { |
39 // If the channel has already been established then we run the task | 40 // If the channel has already been established then we run the task |
40 // and return. | 41 // and return. |
41 if (channel_.get()) { | 42 if (channel_.get()) { |
42 RunConnectDoneTasks(); | 43 RunConnectDoneTasks(); |
43 return; | 44 return; |
44 } | 45 } |
45 | 46 |
46 // Actually going to connect. | 47 // Actually going to connect. |
47 DVLOG(1) << "Connecting to Service Process IPC Server"; | 48 DVLOG(1) << "Connecting to Service Process IPC Server"; |
48 | 49 |
49 // TODO(hclam): Handle error connecting to channel. | 50 // TODO(hclam): Handle error connecting to channel. |
50 const IPC::ChannelHandle channel_id = GetServiceProcessChannel(); | 51 const IPC::ChannelHandle channel_id = GetServiceProcessChannel(); |
51 SetChannel(IPC::ChannelProxy::Create( | 52 SetChannel(IPC::ChannelProxy::Create( |
52 channel_id, | 53 channel_id, IPC::Channel::MODE_NAMED_CLIENT, this, |
53 IPC::Channel::MODE_NAMED_CLIENT, | 54 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get(), |
54 this, | 55 content::ChildProcessHost::GetAttachmentBroker())); |
55 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); | |
56 } | 56 } |
57 | 57 |
58 void ServiceProcessControl::SetChannel(scoped_ptr<IPC::ChannelProxy> channel) { | 58 void ServiceProcessControl::SetChannel(scoped_ptr<IPC::ChannelProxy> channel) { |
59 channel_ = channel.Pass(); | 59 channel_ = channel.Pass(); |
60 } | 60 } |
61 | 61 |
62 void ServiceProcessControl::RunConnectDoneTasks() { | 62 void ServiceProcessControl::RunConnectDoneTasks() { |
63 // The tasks executed here may add more tasks to the vector. So copy | 63 // The tasks executed here may add more tasks to the vector. So copy |
64 // them to the stack before executing them. This way recursion is | 64 // them to the stack before executing them. This way recursion is |
65 // avoided. | 65 // avoided. |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (process_.IsValid()) { | 382 if (process_.IsValid()) { |
383 BrowserThread::PostTask( | 383 BrowserThread::PostTask( |
384 BrowserThread::IO, FROM_HERE, | 384 BrowserThread::IO, FROM_HERE, |
385 base::Bind(&Launcher::DoDetectLaunched, this)); | 385 base::Bind(&Launcher::DoDetectLaunched, this)); |
386 } else { | 386 } else { |
387 BrowserThread::PostTask( | 387 BrowserThread::PostTask( |
388 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 388 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
389 } | 389 } |
390 } | 390 } |
391 #endif // !OS_MACOSX | 391 #endif // !OS_MACOSX |
OLD | NEW |