| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/json_pref_store.h" | 19 #include "chrome/common/json_pref_store.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 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/base/encoder_zlib.h" | |
| 29 #include "remoting/host/chromoting_host.h" | 28 #include "remoting/host/chromoting_host.h" |
| 30 #include "remoting/host/chromoting_host_context.h" | 29 #include "remoting/host/chromoting_host_context.h" |
| 31 #include "remoting/host/json_host_config.h" | 30 #include "remoting/host/json_host_config.h" |
| 32 | 31 |
| 33 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 34 #include "remoting/host/capturer_gdi.h" | 33 #include "remoting/host/capturer_gdi.h" |
| 35 #include "remoting/host/event_executor_win.h" | 34 #include "remoting/host/event_executor_win.h" |
| 36 #elif defined(OS_LINUX) | 35 #elif defined(OS_LINUX) |
| 37 #include "remoting/host/capturer_linux.h" | 36 #include "remoting/host/capturer_linux.h" |
| 38 #include "remoting/host/event_executor_linux.h" | 37 #include "remoting/host/event_executor_linux.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (chromoting_context_.get()) | 274 if (chromoting_context_.get()) |
| 276 return true; | 275 return true; |
| 277 | 276 |
| 278 // Load chromoting config from the disk. | 277 // Load chromoting config from the disk. |
| 279 LoadChromotingConfig(); | 278 LoadChromotingConfig(); |
| 280 | 279 |
| 281 // Start the chromoting context first. | 280 // Start the chromoting context first. |
| 282 chromoting_context_.reset(new remoting::ChromotingHostContext()); | 281 chromoting_context_.reset(new remoting::ChromotingHostContext()); |
| 283 chromoting_context_->Start(); | 282 chromoting_context_->Start(); |
| 284 | 283 |
| 285 // Create capturer, encoder and executor. The ownership will be transfered | 284 // Create capturer and executor. The ownership will be transfered |
| 286 // to the chromoting host. | 285 // to the chromoting host. |
| 287 scoped_ptr<remoting::Capturer> capturer; | 286 scoped_ptr<remoting::Capturer> capturer; |
| 288 scoped_ptr<remoting::Encoder> encoder; | |
| 289 scoped_ptr<remoting::EventExecutor> executor; | 287 scoped_ptr<remoting::EventExecutor> executor; |
| 290 | 288 |
| 291 #if defined(OS_WIN) | 289 #if defined(OS_WIN) |
| 292 capturer.reset(new remoting::CapturerGdi()); | 290 capturer.reset(new remoting::CapturerGdi()); |
| 293 executor.reset(new remoting::EventExecutorWin(capturer.get())); | 291 executor.reset(new remoting::EventExecutorWin(capturer.get())); |
| 294 #elif defined(OS_LINUX) | 292 #elif defined(OS_LINUX) |
| 295 capturer.reset(new remoting::CapturerLinux()); | 293 capturer.reset(new remoting::CapturerLinux()); |
| 296 executor.reset(new remoting::EventExecutorLinux(capturer.get())); | 294 executor.reset(new remoting::EventExecutorLinux(capturer.get())); |
| 297 #elif defined(OS_MACOSX) | 295 #elif defined(OS_MACOSX) |
| 298 capturer.reset(new remoting::CapturerMac()); | 296 capturer.reset(new remoting::CapturerMac()); |
| 299 executor.reset(new remoting::EventExecutorMac(capturer.get())); | 297 executor.reset(new remoting::EventExecutorMac(capturer.get())); |
| 300 #endif | 298 #endif |
| 301 encoder.reset(new remoting::EncoderZlib()); | |
| 302 | 299 |
| 303 // Create a chromoting host object. | 300 // Create a chromoting host object. |
| 304 chromoting_host_ = new remoting::ChromotingHost(chromoting_context_.get(), | 301 chromoting_host_ = new remoting::ChromotingHost(chromoting_context_.get(), |
| 305 chromoting_config_, | 302 chromoting_config_, |
| 306 capturer.release(), | 303 capturer.release(), |
| 307 encoder.release(), | |
| 308 executor.release()); | 304 executor.release()); |
| 309 | 305 |
| 310 // Then start the chromoting host. | 306 // Then start the chromoting host. |
| 311 // When ChromotingHost is shutdown because of failure or a request that | 307 // When ChromotingHost is shutdown because of failure or a request that |
| 312 // we made OnChromotingShutdown() is calls. | 308 // we made OnChromotingShutdown() is calls. |
| 313 chromoting_host_->Start( | 309 chromoting_host_->Start( |
| 314 NewRunnableMethod(this, &ServiceProcess::OnChromotingHostShutdown)); | 310 NewRunnableMethod(this, &ServiceProcess::OnChromotingHostShutdown)); |
| 315 OnServiceEnabled(); | 311 OnServiceEnabled(); |
| 316 return true; | 312 return true; |
| 317 } | 313 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 #endif | 415 #endif |
| 420 | 416 |
| 421 ServiceProcess::~ServiceProcess() { | 417 ServiceProcess::~ServiceProcess() { |
| 422 Teardown(); | 418 Teardown(); |
| 423 g_service_process = NULL; | 419 g_service_process = NULL; |
| 424 } | 420 } |
| 425 | 421 |
| 426 // Disable refcounting for runnable method because it is really not needed | 422 // Disable refcounting for runnable method because it is really not needed |
| 427 // when we post tasks on the main message loop. | 423 // when we post tasks on the main message loop. |
| 428 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 424 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
| OLD | NEW |