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/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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 channel_id, IPC::Channel::MODE_NAMED_CLIENT, this, | 49 channel_id, IPC::Channel::MODE_NAMED_CLIENT, this, |
50 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 50 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
51 } | 51 } |
52 | 52 |
53 void ServiceProcessControl::RunConnectDoneTasks() { | 53 void ServiceProcessControl::RunConnectDoneTasks() { |
54 // The tasks executed here may add more tasks to the vector. So copy | 54 // The tasks executed here may add more tasks to the vector. So copy |
55 // them to the stack before executing them. This way recursion is | 55 // them to the stack before executing them. This way recursion is |
56 // avoided. | 56 // avoided. |
57 TaskList tasks; | 57 TaskList tasks; |
58 | 58 |
59 if (is_connected()) { | 59 if (IsConnected()) { |
60 tasks.swap(connect_success_tasks_); | 60 tasks.swap(connect_success_tasks_); |
61 RunAllTasksHelper(&tasks); | 61 RunAllTasksHelper(&tasks); |
62 DCHECK(tasks.empty()); | 62 DCHECK(tasks.empty()); |
63 connect_failure_tasks_.clear(); | 63 connect_failure_tasks_.clear(); |
64 } else { | 64 } else { |
65 tasks.swap(connect_failure_tasks_); | 65 tasks.swap(connect_failure_tasks_); |
66 RunAllTasksHelper(&tasks); | 66 RunAllTasksHelper(&tasks); |
67 DCHECK(tasks.empty()); | 67 DCHECK(tasks.empty()); |
68 connect_success_tasks_.clear(); | 68 connect_success_tasks_.clear(); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 // static | 72 // static |
73 void ServiceProcessControl::RunAllTasksHelper(TaskList* task_list) { | 73 void ServiceProcessControl::RunAllTasksHelper(TaskList* task_list) { |
74 TaskList::iterator index = task_list->begin(); | 74 TaskList::iterator index = task_list->begin(); |
75 while (index != task_list->end()) { | 75 while (index != task_list->end()) { |
76 (*index).Run(); | 76 (*index).Run(); |
77 index = task_list->erase(index); | 77 index = task_list->erase(index); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 bool ServiceProcessControl::is_connected() const { | 81 bool ServiceProcessControl::IsConnected() const { |
82 return channel_.get() != NULL; | 82 return channel_ != NULL; |
83 } | 83 } |
84 | 84 |
85 void ServiceProcessControl::Launch(const base::Closure& success_task, | 85 void ServiceProcessControl::Launch(const base::Closure& success_task, |
86 const base::Closure& failure_task) { | 86 const base::Closure& failure_task) { |
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
88 | 88 |
89 base::Closure failure = failure_task; | 89 base::Closure failure = failure_task; |
90 if (!success_task.is_null()) | 90 if (!success_task.is_null()) |
91 connect_success_tasks_.push_back(success_task); | 91 connect_success_tasks_.push_back(success_task); |
92 | 92 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (base::LaunchProcess(*cmd_line_, options, NULL)) { | 313 if (base::LaunchProcess(*cmd_line_, options, NULL)) { |
314 BrowserThread::PostTask( | 314 BrowserThread::PostTask( |
315 BrowserThread::IO, FROM_HERE, | 315 BrowserThread::IO, FROM_HERE, |
316 base::Bind(&Launcher::DoDetectLaunched, this)); | 316 base::Bind(&Launcher::DoDetectLaunched, this)); |
317 } else { | 317 } else { |
318 BrowserThread::PostTask( | 318 BrowserThread::PostTask( |
319 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 319 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
320 } | 320 } |
321 } | 321 } |
322 #endif // !OS_MACOSX | 322 #endif // !OS_MACOSX |
OLD | NEW |