Chromium Code Reviews| Index: remoting/host/chromoting_host.cc |
| diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc |
| index 67798a960bdb242725c5b278c63bf8da7fe1e8ff..68f4846daad2d1318d07e1d7e3ec488c003f492d 100644 |
| --- a/remoting/host/chromoting_host.cc |
| +++ b/remoting/host/chromoting_host.cc |
| @@ -8,21 +8,13 @@ |
| #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/capturer.h" |
| #include "remoting/host/chromoting_host_context.h" |
| +#include "remoting/host/event_executor.h" |
| #include "remoting/host/host_config.h" |
| #include "remoting/host/host_stub_fake.h" |
| #include "remoting/host/session_manager.h" |
| @@ -36,28 +28,19 @@ using remoting::protocol::ConnectionToClient; |
| namespace remoting { |
| -ChromotingHost::ChromotingHost(ChromotingHostContext* context, |
| - MutableHostConfig* config) |
| - : context_(context), |
| - config_(config), |
| -#if defined(OS_WIN) |
| - capturer_(new remoting::CapturerGdi( |
| - context->main_message_loop())), |
| - input_stub_(new remoting::EventExecutorWin( |
| - context->main_message_loop(), capturer_.get())), |
| -#elif defined(OS_LINUX) |
| - capturer_(new remoting::CapturerLinux( |
| - context->main_message_loop())), |
| - input_stub_(new remoting::EventExecutorLinux( |
| - context->main_message_loop(), capturer_.get())), |
| -#elif defined(OS_MACOSX) |
| - capturer_(new remoting::CapturerMac( |
| - context->main_message_loop())), |
| - input_stub_(new remoting::EventExecutorMac( |
| - context->main_message_loop(), capturer_.get())), |
| -#endif |
| - host_stub_(new HostStubFake()), |
| - state_(kInitial) { |
| +// static |
| +ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context, |
| + MutableHostConfig* config) { |
| + return new ChromotingHost( |
| + context, config, |
|
dmac
2010/11/23 01:14:57
any reason not to have these up on line 34?
Sergey Ulanov
2010/11/23 01:59:18
Done.
|
| + Capturer::Create(context->main_message_loop())); |
| +} |
| + |
| +// static |
| +ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context, |
| + MutableHostConfig* config, |
| + Capturer* capturer) { |
| + return new ChromotingHost(context, config, capturer); |
| } |
| ChromotingHost::ChromotingHost(ChromotingHostContext* context, |
| @@ -65,20 +48,14 @@ ChromotingHost::ChromotingHost(ChromotingHostContext* context, |
| : context_(context), |
| config_(config), |
| capturer_(capturer), |
| -#if defined(OS_WIN) |
| - input_stub_(new remoting::EventExecutorWin( |
| - context->main_message_loop(), capturer)), |
| -#elif defined(OS_LINUX) |
| - input_stub_(new remoting::EventExecutorLinux( |
| + input_stub_(EventExecutor::Create( |
| context->main_message_loop(), capturer)), |
| -#elif defined(OS_MACOSX) |
| - input_stub_(new remoting::EventExecutorMac( |
| - context->main_message_loop(), capturer)), |
| -#endif |
| host_stub_(new HostStubFake()), |
| - state_(kInitial) { |
| + state_(kInitial), |
| + protocol_config_(protocol::CandidateSessionConfig::CreateDefault()) { |
| } |
| + |
| ChromotingHost::~ChromotingHost() { |
| } |
| @@ -293,12 +270,10 @@ void ChromotingHost::OnNewClientSession( |
| return; |
| } |
| - scoped_ptr<protocol::CandidateSessionConfig> |
| - local_config(protocol::CandidateSessionConfig::CreateDefault()); |
| - local_config->SetInitialResolution( |
| - protocol::ScreenResolution(capturer_->width(), capturer_->height())); |
| + *protocol_config_->mutable_initial_resolution() = |
| + protocol::ScreenResolution(capturer_->width(), capturer_->height()); |
| // TODO(sergeyu): Respect resolution requested by the client if supported. |
| - protocol::SessionConfig* config = local_config->Select( |
| + protocol::SessionConfig* config = protocol_config_->Select( |
| session->candidate_config(), true /* force_host_resolution */); |
| if (!config) { |
| @@ -322,6 +297,12 @@ void ChromotingHost::OnNewClientSession( |
| connection_->Init(session); |
| } |
| +void ChromotingHost::set_protocol_config( |
| + protocol::CandidateSessionConfig* config) { |
| + DCHECK_EQ(state_, kInitial); |
| + protocol_config_.reset(config); |
| +} |
| + |
| void ChromotingHost::OnServerClosed() { |
| // Don't need to do anything here. |
| } |