OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/thread.h" | 10 #include "base/thread.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // has failed. | 164 // has failed. |
165 task->Run(); | 165 task->Run(); |
166 delete task; | 166 delete task; |
167 } | 167 } |
168 | 168 |
169 // We don't need the launcher anymore. | 169 // We don't need the launcher anymore. |
170 launcher_ = NULL; | 170 launcher_ = NULL; |
171 } | 171 } |
172 | 172 |
173 void ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { | 173 void ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { |
174 if (!message_handler_) | 174 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) |
175 return; | 175 IPC_MESSAGE_HANDLER(ServiceHostMsg_GoodDay, OnGoodDay) |
176 | 176 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_IsEnabled, |
177 if (message.type() == ServiceHostMsg_GoodDay::ID) | 177 OnCloudPrintProxyIsEnabled) |
178 message_handler_->OnGoodDay(); | 178 IPC_END_MESSAGE_MAP() |
179 } | 179 } |
180 | 180 |
181 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { | 181 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { |
182 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 182 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
183 if (!connect_done_task_.get()) | 183 if (!connect_done_task_.get()) |
184 return; | 184 return; |
185 connect_done_task_->Run(); | 185 connect_done_task_->Run(); |
186 connect_done_task_.reset(); | 186 connect_done_task_.reset(); |
187 } | 187 } |
188 | 188 |
189 void ServiceProcessControl::OnChannelError() { | 189 void ServiceProcessControl::OnChannelError() { |
190 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 190 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
191 channel_.reset(); | 191 channel_.reset(); |
192 if (!connect_done_task_.get()) | 192 if (!connect_done_task_.get()) |
193 return; | 193 return; |
194 connect_done_task_->Run(); | 194 connect_done_task_->Run(); |
195 connect_done_task_.reset(); | 195 connect_done_task_.reset(); |
196 } | 196 } |
197 | 197 |
198 bool ServiceProcessControl::Send(IPC::Message* message) { | 198 bool ServiceProcessControl::Send(IPC::Message* message) { |
199 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 199 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
200 if (!channel_.get()) | 200 if (!channel_.get()) |
201 return false; | 201 return false; |
202 return channel_->Send(message); | 202 return channel_->Send(message); |
203 } | 203 } |
204 | 204 |
| 205 void ServiceProcessControl::OnGoodDay() { |
| 206 if (!message_handler_) |
| 207 return; |
| 208 |
| 209 message_handler_->OnGoodDay(); |
| 210 } |
| 211 |
| 212 void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled, |
| 213 std::string email) { |
| 214 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 215 if (cloud_print_status_callback_ != NULL) { |
| 216 cloud_print_status_callback_->Run(enabled, email); |
| 217 cloud_print_status_callback_.reset(); |
| 218 } |
| 219 } |
| 220 |
205 bool ServiceProcessControl::SendHello() { | 221 bool ServiceProcessControl::SendHello() { |
206 return Send(new ServiceMsg_Hello()); | 222 return Send(new ServiceMsg_Hello()); |
207 } | 223 } |
208 | 224 |
209 bool ServiceProcessControl::Shutdown() { | 225 bool ServiceProcessControl::Shutdown() { |
210 bool ret = Send(new ServiceMsg_Shutdown()); | 226 bool ret = Send(new ServiceMsg_Shutdown()); |
211 channel_.reset(); | 227 channel_.reset(); |
212 return ret; | 228 return ret; |
213 } | 229 } |
214 | 230 |
215 bool ServiceProcessControl::EnableRemotingWithTokens( | 231 bool ServiceProcessControl::EnableRemotingWithTokens( |
216 const std::string& user, | 232 const std::string& user, |
217 const std::string& remoting_token, | 233 const std::string& remoting_token, |
218 const std::string& talk_token) { | 234 const std::string& talk_token) { |
219 return Send( | 235 return Send( |
220 new ServiceMsg_EnableRemotingWithTokens(user, remoting_token, | 236 new ServiceMsg_EnableRemotingWithTokens(user, remoting_token, |
221 talk_token)); | 237 talk_token)); |
222 } | 238 } |
223 | 239 |
| 240 bool ServiceProcessControl::GetCloudPrintProxyStatus( |
| 241 Callback2<bool, std::string>::Type* cloud_print_status_callback) { |
| 242 DCHECK(cloud_print_status_callback); |
| 243 cloud_print_status_callback_.reset(cloud_print_status_callback); |
| 244 return Send(new ServiceMsg_IsCloudPrintProxyEnabled); |
| 245 } |
| 246 |
224 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); | 247 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); |
OLD | NEW |