| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/service_process_control.h" | 5 #include "chrome/browser/service/service_process_control.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/io_thread.h" | |
| 15 #include "chrome/browser/upgrade_detector.h" | 14 #include "chrome/browser/upgrade_detector.h" |
| 16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/service_messages.h" | 16 #include "chrome/common/service_messages.h" |
| 18 #include "chrome/common/service_process_util.h" | 17 #include "chrome/common/service_process_util.h" |
| 19 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 20 #include "content/common/child_process_host.h" | 19 #include "content/common/child_process_host.h" |
| 21 #include "content/common/notification_service.h" | 20 #include "content/common/notification_service.h" |
| 22 #include "ui/base/ui_base_switches.h" | 21 #include "ui/base/ui_base_switches.h" |
| 23 | 22 |
| 24 | 23 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 void ServiceProcessControl::ConnectInternal() { | 35 void ServiceProcessControl::ConnectInternal() { |
| 37 // If the channel has already been established then we run the task | 36 // If the channel has already been established then we run the task |
| 38 // and return. | 37 // and return. |
| 39 if (channel_.get()) { | 38 if (channel_.get()) { |
| 40 RunConnectDoneTasks(); | 39 RunConnectDoneTasks(); |
| 41 return; | 40 return; |
| 42 } | 41 } |
| 43 | 42 |
| 44 // Actually going to connect. | 43 // Actually going to connect. |
| 45 VLOG(1) << "Connecting to Service Process IPC Server"; | 44 VLOG(1) << "Connecting to Service Process IPC Server"; |
| 46 // Run the IPC channel on the shared IO thread. | |
| 47 base::Thread* io_thread = g_browser_process->io_thread(); | |
| 48 | 45 |
| 49 // TODO(hclam): Handle error connecting to channel. | 46 // TODO(hclam): Handle error connecting to channel. |
| 50 const IPC::ChannelHandle channel_id = GetServiceProcessChannel(); | 47 const IPC::ChannelHandle channel_id = GetServiceProcessChannel(); |
| 51 channel_.reset( | 48 channel_.reset(new IPC::SyncChannel( |
| 52 new IPC::SyncChannel(channel_id, IPC::Channel::MODE_NAMED_CLIENT, this, | 49 channel_id, IPC::Channel::MODE_NAMED_CLIENT, this, |
| 53 io_thread->message_loop(), true, | 50 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), true, |
| 54 g_browser_process->shutdown_event())); | 51 g_browser_process->shutdown_event())); |
| 55 } | 52 } |
| 56 | 53 |
| 57 void ServiceProcessControl::RunConnectDoneTasks() { | 54 void ServiceProcessControl::RunConnectDoneTasks() { |
| 58 // The tasks executed here may add more tasks to the vector. So copy | 55 // The tasks executed here may add more tasks to the vector. So copy |
| 59 // them to the stack before executing them. This way recursion is | 56 // them to the stack before executing them. This way recursion is |
| 60 // avoided. | 57 // avoided. |
| 61 TaskList tasks; | 58 TaskList tasks; |
| 62 tasks.swap(connect_done_tasks_); | 59 tasks.swap(connect_done_tasks_); |
| 63 RunAllTasksHelper(&tasks); | 60 RunAllTasksHelper(&tasks); |
| 64 DCHECK(tasks.empty()); | 61 DCHECK(tasks.empty()); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 if (base::LaunchApp(*cmd_line_, false, true, NULL)) { | 356 if (base::LaunchApp(*cmd_line_, false, true, NULL)) { |
| 360 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 357 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 361 NewRunnableMethod(this, | 358 NewRunnableMethod(this, |
| 362 &Launcher::DoDetectLaunched)); | 359 &Launcher::DoDetectLaunched)); |
| 363 } else { | 360 } else { |
| 364 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 361 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 365 NewRunnableMethod(this, &Launcher::Notify)); | 362 NewRunnableMethod(this, &Launcher::Notify)); |
| 366 } | 363 } |
| 367 } | 364 } |
| 368 #endif // !OS_MACOSX | 365 #endif // !OS_MACOSX |
| OLD | NEW |