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/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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/service_process_util.h" | 21 #include "chrome/common/service_process_util.h" |
22 #include "chrome/service/cloud_print/cloud_print_proxy.h" | 22 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
23 #include "chrome/service/service_ipc_server.h" | 23 #include "chrome/service/service_ipc_server.h" |
24 #include "net/base/network_change_notifier.h" | 24 #include "net/base/network_change_notifier.h" |
25 | 25 |
26 #if defined(ENABLE_REMOTING) | 26 #if defined(ENABLE_REMOTING) |
27 #include "remoting/base/constants.h" | 27 #include "remoting/base/constants.h" |
28 #include "remoting/host/chromoting_host.h" | 28 #include "remoting/host/chromoting_host.h" |
29 #include "remoting/host/chromoting_host_context.h" | 29 #include "remoting/host/chromoting_host_context.h" |
30 #include "remoting/host/json_host_config.h" | 30 #include "remoting/host/json_host_config.h" |
31 | |
32 #if defined(OS_WIN) | |
33 #include "remoting/host/capturer_gdi.h" | |
34 #include "remoting/host/event_executor_win.h" | |
35 #elif defined(OS_LINUX) | |
36 #include "remoting/host/capturer_linux.h" | |
37 #include "remoting/host/event_executor_linux.h" | |
38 #elif defined(OS_MACOSX) | |
39 #include "remoting/host/capturer_mac.h" | |
40 #include "remoting/host/event_executor_mac.h" | |
41 #endif | |
42 #endif // defined(ENABLED_REMOTING) | 31 #endif // defined(ENABLED_REMOTING) |
43 | 32 |
44 ServiceProcess* g_service_process = NULL; | 33 ServiceProcess* g_service_process = NULL; |
45 | 34 |
46 namespace { | 35 namespace { |
47 | 36 |
48 // Delay in millseconds after the last service is disabled before we attempt | 37 // Delay in millseconds after the last service is disabled before we attempt |
49 // a shutdown. | 38 // a shutdown. |
50 const int64 kShutdownDelay = 60000; | 39 const int64 kShutdownDelay = 60000; |
51 | 40 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 if (chromoting_context_.get()) | 265 if (chromoting_context_.get()) |
277 return true; | 266 return true; |
278 | 267 |
279 // Load chromoting config from the disk. | 268 // Load chromoting config from the disk. |
280 LoadChromotingConfig(); | 269 LoadChromotingConfig(); |
281 | 270 |
282 // Start the chromoting context first. | 271 // Start the chromoting context first. |
283 chromoting_context_.reset(new remoting::ChromotingHostContext()); | 272 chromoting_context_.reset(new remoting::ChromotingHostContext()); |
284 chromoting_context_->Start(); | 273 chromoting_context_->Start(); |
285 | 274 |
286 // Create capturer and executor. The ownership will be transfered | |
287 // to the chromoting host. | |
288 scoped_ptr<remoting::Capturer> capturer; | |
289 scoped_ptr<remoting::protocol::InputStub> input_stub; | |
290 | |
291 #if defined(OS_WIN) | |
292 capturer.reset(new remoting::CapturerGdi( | |
293 chromoting_context_->capture_message_loop())); | |
294 input_stub.reset(new remoting::EventExecutorWin( | |
295 chromoting_context_->capture_message_loop(), capturer.get())); | |
296 #elif defined(OS_LINUX) | |
297 capturer.reset(new remoting::CapturerLinux( | |
298 chromoting_context_->capture_message_loop())); | |
299 input_stub.reset(new remoting::EventExecutorLinux( | |
300 chromoting_context_->capture_message_loop(), capturer.get())); | |
301 #elif defined(OS_MACOSX) | |
302 capturer.reset(new remoting::CapturerMac( | |
303 chromoting_context_->capture_message_loop())); | |
304 input_stub.reset(new remoting::EventExecutorMac( | |
305 chromoting_context_->capture_message_loop(), capturer.get())); | |
306 #endif | |
307 | |
308 // Create a chromoting host object. | 275 // Create a chromoting host object. |
309 chromoting_host_ = new remoting::ChromotingHost(chromoting_context_.get(), | 276 chromoting_host_ = new remoting::ChromotingHost(chromoting_context_.get(), |
310 chromoting_config_, | 277 chromoting_config_); |
311 capturer.release(), | |
312 input_stub.release()); | |
313 | 278 |
314 // Then start the chromoting host. | 279 // Then start the chromoting host. |
315 // When ChromotingHost is shutdown because of failure or a request that | 280 // When ChromotingHost is shutdown because of failure or a request that |
316 // we made OnChromotingShutdown() is calls. | 281 // we made OnChromotingShutdown() is calls. |
317 chromoting_host_->Start( | 282 chromoting_host_->Start( |
318 NewRunnableMethod(this, &ServiceProcess::OnChromotingHostShutdown)); | 283 NewRunnableMethod(this, &ServiceProcess::OnChromotingHostShutdown)); |
319 OnServiceEnabled(); | 284 OnServiceEnabled(); |
320 return true; | 285 return true; |
321 } | 286 } |
322 | 287 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 #endif | 388 #endif |
424 | 389 |
425 ServiceProcess::~ServiceProcess() { | 390 ServiceProcess::~ServiceProcess() { |
426 Teardown(); | 391 Teardown(); |
427 g_service_process = NULL; | 392 g_service_process = NULL; |
428 } | 393 } |
429 | 394 |
430 // Disable refcounting for runnable method because it is really not needed | 395 // Disable refcounting for runnable method because it is really not needed |
431 // when we post tasks on the main message loop. | 396 // when we post tasks on the main message loop. |
432 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 397 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
OLD | NEW |