summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-17 05:24:30 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-17 05:24:30 +0000
commitc3ba9b31f45a887b80d6a4ff412ac922ecd30298 (patch)
tree0c652c68b9613d0b26ab430463329d692b37ce96
parent8de78b013c1754d83a67312b086a53bd6d593ab9 (diff)
downloadchromium_src-c3ba9b31f45a887b80d6a4ff412ac922ecd30298.zip
chromium_src-c3ba9b31f45a887b80d6a4ff412ac922ecd30298.tar.gz
chromium_src-c3ba9b31f45a887b80d6a4ff412ac922ecd30298.tar.bz2
Move creation of capturer, input stub into ChromotingHost
BUG=None TEST=None Review URL: http://codereview.chromium.org/5065001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66390 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/service/service_process.cc37
-rw-r--r--remoting/host/chromoting_host.cc50
-rw-r--r--remoting/host/chromoting_host.h3
-rw-r--r--remoting/host/simple_host_process.cc53
4 files changed, 58 insertions, 85 deletions
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index fccd186..ee5bdf93 100644
--- a/chrome/service/service_process.cc
+++ b/chrome/service/service_process.cc
@@ -28,17 +28,6 @@
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/json_host_config.h"
-
-#if defined(OS_WIN)
-#include "remoting/host/capturer_gdi.h"
-#include "remoting/host/event_executor_win.h"
-#elif defined(OS_LINUX)
-#include "remoting/host/capturer_linux.h"
-#include "remoting/host/event_executor_linux.h"
-#elif defined(OS_MACOSX)
-#include "remoting/host/capturer_mac.h"
-#include "remoting/host/event_executor_mac.h"
-#endif
#endif // defined(ENABLED_REMOTING)
ServiceProcess* g_service_process = NULL;
@@ -283,33 +272,9 @@ bool ServiceProcess::StartChromotingHost() {
chromoting_context_.reset(new remoting::ChromotingHostContext());
chromoting_context_->Start();
- // Create capturer and executor. The ownership will be transfered
- // to the chromoting host.
- scoped_ptr<remoting::Capturer> capturer;
- scoped_ptr<remoting::protocol::InputStub> input_stub;
-
-#if defined(OS_WIN)
- capturer.reset(new remoting::CapturerGdi(
- chromoting_context_->capture_message_loop()));
- input_stub.reset(new remoting::EventExecutorWin(
- chromoting_context_->capture_message_loop(), capturer.get()));
-#elif defined(OS_LINUX)
- capturer.reset(new remoting::CapturerLinux(
- chromoting_context_->capture_message_loop()));
- input_stub.reset(new remoting::EventExecutorLinux(
- chromoting_context_->capture_message_loop(), capturer.get()));
-#elif defined(OS_MACOSX)
- capturer.reset(new remoting::CapturerMac(
- chromoting_context_->capture_message_loop()));
- input_stub.reset(new remoting::EventExecutorMac(
- chromoting_context_->capture_message_loop(), capturer.get()));
-#endif
-
// Create a chromoting host object.
chromoting_host_ = new remoting::ChromotingHost(chromoting_context_.get(),
- chromoting_config_,
- capturer.release(),
- input_stub.release());
+ chromoting_config_);
// Then start the chromoting host.
// When ChromotingHost is shutdown because of failure or a request that
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index c7fc7f5..e8b2ccc 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -8,12 +8,21 @@
#include "base/task.h"
#include "build/build_config.h"
#include "remoting/base/constants.h"
+#if defined(OS_WIN)
+#include "remoting/host/capturer_gdi.h"
+#include "remoting/host/event_executor_win.h"
+#elif defined(OS_LINUX)
+#include "remoting/host/capturer_linux.h"
+#include "remoting/host/event_executor_linux.h"
+#elif defined(OS_MACOSX)
+#include "remoting/host/capturer_mac.h"
+#include "remoting/host/event_executor_mac.h"
+#endif
#include "remoting/base/encoder.h"
#include "remoting/base/encoder_verbatim.h"
#include "remoting/base/encoder_vp8.h"
#include "remoting/base/encoder_zlib.h"
#include "remoting/host/chromoting_host_context.h"
-#include "remoting/host/capturer.h"
#include "remoting/host/host_config.h"
#include "remoting/host/host_stub_fake.h"
#include "remoting/host/session_manager.h"
@@ -28,13 +37,44 @@ using remoting::protocol::ConnectionToClient;
namespace remoting {
ChromotingHost::ChromotingHost(ChromotingHostContext* context,
- MutableHostConfig* config,
- Capturer* capturer,
- protocol::InputStub* input_stub)
+ MutableHostConfig* config)
+ : context_(context),
+ config_(config),
+#if defined(OS_WIN)
+ capturer_(new remoting::CapturerGdi(
+ context->capture_message_loop())),
+ input_stub_(new remoting::EventExecutorWin(
+ context->capture_message_loop(), capturer_.get())),
+#elif defined(OS_LINUX)
+ capturer_(new remoting::CapturerLinux(
+ context->capture_message_loop())),
+ input_stub_(new remoting::EventExecutorLinux(
+ context->capture_message_loop(), capturer_.get())),
+#elif defined(OS_MACOSX)
+ capturer_(new remoting::CapturerMac(
+ context->capture_message_loop())),
+ input_stub_(new remoting::EventExecutorMac(
+ context->capture_message_loop(), capturer_.get())),
+#endif
+ host_stub_(new HostStubFake()),
+ state_(kInitial) {
+}
+
+ChromotingHost::ChromotingHost(ChromotingHostContext* context,
+ MutableHostConfig* config, Capturer* capturer)
: context_(context),
config_(config),
capturer_(capturer),
- input_stub_(input_stub),
+#if defined(OS_WIN)
+ input_stub_(new remoting::EventExecutorWin(
+ context->capture_message_loop(), capturer)),
+#elif defined(OS_LINUX)
+ input_stub_(new remoting::EventExecutorLinux(
+ context->capture_message_loop(), capturer)),
+#elif defined(OS_MACOSX)
+ input_stub_(new remoting::EventExecutorMac(
+ context->capture_message_loop(), capturer)),
+#endif
host_stub_(new HostStubFake()),
state_(kInitial) {
}
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index f3b908f..2294fdd 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -63,8 +63,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
public protocol::ConnectionToClient::EventHandler,
public JingleClient::Callback {
public:
+ ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config);
ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config,
- Capturer* capturer, protocol::InputStub* input_stub);
+ Capturer* capturer);
virtual ~ChromotingHost();
// Asynchronously start the host process.
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 0a6ff42..5decb81 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -36,17 +36,6 @@
#include "remoting/proto/video.pb.h"
#if defined(OS_WIN)
-#include "remoting/host/capturer_gdi.h"
-#include "remoting/host/event_executor_win.h"
-#elif defined(OS_LINUX)
-#include "remoting/host/capturer_linux.h"
-#include "remoting/host/event_executor_linux.h"
-#elif defined(OS_MACOSX)
-#include "remoting/host/capturer_mac.h"
-#include "remoting/host/event_executor_mac.h"
-#endif
-
-#if defined(OS_WIN)
const std::wstring kDefaultConfigPath = L".ChromotingConfig.json";
const wchar_t kHomeDrive[] = L"HOMEDRIVE";
const wchar_t kHomePath[] = L"HOMEPATH";
@@ -77,27 +66,6 @@ int main(int argc, char** argv) {
remoting::ChromotingHostContext context;
context.Start();
- scoped_ptr<remoting::Capturer> capturer;
- scoped_ptr<remoting::protocol::InputStub> input_stub;
-#if defined(OS_WIN)
- capturer.reset(new remoting::CapturerGdi(
- context.capture_message_loop()));
- input_stub.reset(new remoting::EventExecutorWin(
- context.capture_message_loop(), capturer.get()));
-#elif defined(OS_LINUX)
- capturer.reset(new remoting::CapturerLinux(
- context.capture_message_loop()));
- input_stub.reset(new remoting::EventExecutorLinux(
- context.capture_message_loop(), capturer.get()));
-#elif defined(OS_MACOSX)
- capturer.reset(new remoting::CapturerMac(
- context.capture_message_loop()));
- input_stub.reset(new remoting::EventExecutorMac(
- context.capture_message_loop(), capturer.get()));
-#endif
-
- // Check the argument to see if we should use a fake capturer.
- bool fake = cmd_line->HasSwitch(kFakeSwitchName);
#if defined(OS_WIN)
std::wstring home_path = GetEnvironmentVar(kHomeDrive);
@@ -111,12 +79,6 @@ int main(int argc, char** argv) {
config_path = cmd_line->GetSwitchValuePath(kConfigSwitchName);
}
- if (fake) {
- // Inject a fake capturer.
- LOG(INFO) << "Using a fake capturer.";
- capturer.reset(new remoting::CapturerFake(context.capture_message_loop()));
- }
-
base::Thread file_io_thread("FileIO");
file_io_thread.Start();
@@ -136,11 +98,16 @@ int main(int argc, char** argv) {
<< "Cannot load media library";
// Construct a chromoting host.
- scoped_refptr<remoting::ChromotingHost> host(
- new remoting::ChromotingHost(&context,
- config,
- capturer.release(),
- input_stub.release()));
+ scoped_refptr<remoting::ChromotingHost> host;
+
+ bool fake = cmd_line->HasSwitch(kFakeSwitchName);
+ if (fake) {
+ host = new remoting::ChromotingHost(
+ &context, config,
+ new remoting::CapturerFake(context.capture_message_loop()));
+ } else {
+ host = new remoting::ChromotingHost(&context, config);
+ }
// Let the chromoting host run until the shutdown task is executed.
MessageLoop message_loop(MessageLoop::TYPE_UI);