diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 05:26:29 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 05:26:29 +0000 |
commit | cec4d7abe9b7671e0ad170b458dccd86a59f7a29 (patch) | |
tree | 40311be04869a1fba87184a0694789bea0b78d3a | |
parent | 715ffe498a150b6ad85d19337e34eb4bbbf842cd (diff) | |
download | chromium_src-cec4d7abe9b7671e0ad170b458dccd86a59f7a29.zip chromium_src-cec4d7abe9b7671e0ad170b458dccd86a59f7a29.tar.gz chromium_src-cec4d7abe9b7671e0ad170b458dccd86a59f7a29.tar.bz2 |
Add file thread in MessageHostContext.
Review URL: https://chromiumcodereview.appspot.com/9956148
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132544 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/host/chromoting_host_context.cc | 23 | ||||
-rw-r--r-- | remoting/host/chromoting_host_context.h | 15 | ||||
-rw-r--r-- | remoting/host/chromoting_host_context_unittest.cc | 2 | ||||
-rw-r--r-- | remoting/host/desktop_environment.cc | 2 | ||||
-rw-r--r-- | remoting/host/host_mock_objects.cc | 2 | ||||
-rw-r--r-- | remoting/host/plugin/host_script_object.cc | 3 | ||||
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 22 | ||||
-rw-r--r-- | remoting/host/simple_host_process.cc | 5 |
8 files changed, 34 insertions, 40 deletions
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc index 783834f..74d214c 100644 --- a/remoting/host/chromoting_host_context.cc +++ b/remoting/host/chromoting_host_context.cc @@ -13,12 +13,11 @@ namespace remoting { ChromotingHostContext::ChromotingHostContext( - base::MessageLoopProxy* io_message_loop, base::MessageLoopProxy* ui_message_loop) : main_thread_("ChromotingMainThread"), encode_thread_("ChromotingEncodeThread"), desktop_thread_("ChromotingDesktopThread"), - io_message_loop_(io_message_loop), + file_thread_("ChromotingFileIOThread"), ui_message_loop_(ui_message_loop) { } @@ -28,21 +27,15 @@ ChromotingHostContext::~ChromotingHostContext() { bool ChromotingHostContext::Start() { // Start all the threads. return main_thread_.Start() && encode_thread_.Start() && - jingle_thread_.Start() && desktop_thread_.Start(); + jingle_thread_.Start() && desktop_thread_.Start() && + file_thread_.StartWithOptions( + base::Thread::Options(MessageLoop::TYPE_IO, 0)); } JingleThread* ChromotingHostContext::jingle_thread() { return &jingle_thread_; } -base::MessageLoopProxy* ChromotingHostContext::io_message_loop() { - return io_message_loop_; -} - -base::MessageLoopProxy* ChromotingHostContext::ui_message_loop() { - return ui_message_loop_; -} - MessageLoop* ChromotingHostContext::main_message_loop() { return main_thread_.message_loop(); } @@ -59,4 +52,12 @@ MessageLoop* ChromotingHostContext::desktop_message_loop() { return desktop_thread_.message_loop(); } +base::MessageLoopProxy* ChromotingHostContext::ui_message_loop() { + return ui_message_loop_; +} + +MessageLoop* ChromotingHostContext::file_message_loop() { + return file_thread_.message_loop(); +} + } // namespace remoting diff --git a/remoting/host/chromoting_host_context.h b/remoting/host/chromoting_host_context.h index d1b87ed..60b261e 100644 --- a/remoting/host/chromoting_host_context.h +++ b/remoting/host/chromoting_host_context.h @@ -19,8 +19,7 @@ namespace remoting { class ChromotingHostContext { public: // Create a context. - ChromotingHostContext(base::MessageLoopProxy* io_message_loop, - base::MessageLoopProxy* ui_message_loop); + ChromotingHostContext(base::MessageLoopProxy* ui_message_loop); virtual ~ChromotingHostContext(); // TODO(ajwong): Move the Start method out of this class. Then @@ -32,12 +31,13 @@ class ChromotingHostContext { virtual JingleThread* jingle_thread(); - virtual base::MessageLoopProxy* io_message_loop(); - virtual base::MessageLoopProxy* ui_message_loop(); + virtual MessageLoop* main_message_loop(); virtual MessageLoop* encode_message_loop(); virtual base::MessageLoopProxy* network_message_loop(); virtual MessageLoop* desktop_message_loop(); + virtual base::MessageLoopProxy* ui_message_loop(); + virtual MessageLoop* file_message_loop(); private: FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); @@ -45,7 +45,8 @@ class ChromotingHostContext { // A thread that hosts all network operations. JingleThread jingle_thread_; - // A thread that hosts ChromotingHost and performs rate control. + // TODO(sergeyu): The "main" thread is used just by the + // capturer. Consider renaming it. base::Thread main_thread_; // A thread that hosts all encode operations. @@ -55,7 +56,9 @@ class ChromotingHostContext { // This is NOT a Chrome-style UI thread. base::Thread desktop_thread_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_; + // Thread for blocking IO operations. + base::Thread file_thread_; + scoped_refptr<base::MessageLoopProxy> ui_message_loop_; DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); diff --git a/remoting/host/chromoting_host_context_unittest.cc b/remoting/host/chromoting_host_context_unittest.cc index 2ada2ed..179673c 100644 --- a/remoting/host/chromoting_host_context_unittest.cc +++ b/remoting/host/chromoting_host_context_unittest.cc @@ -13,7 +13,7 @@ namespace remoting { // operates properly and all threads and message loops are valid. TEST(ChromotingHostContextTest, StartAndStop) { MessageLoop message_loop; - ChromotingHostContext context(NULL, base::MessageLoopProxy::current()); + ChromotingHostContext context(base::MessageLoopProxy::current()); context.Start(); EXPECT_TRUE(context.jingle_thread()); diff --git a/remoting/host/desktop_environment.cc b/remoting/host/desktop_environment.cc index e3268af..f5d45f8 100644 --- a/remoting/host/desktop_environment.cc +++ b/remoting/host/desktop_environment.cc @@ -52,7 +52,7 @@ scoped_ptr<DesktopEnvironment> DesktopEnvironment::CreateForService( #if defined(OS_WIN) event_executor.reset(new SessionEventExecutorWin( context->desktop_message_loop(), - context->io_message_loop(), + context->file_message_loop()->message_loop_proxy(), event_executor.Pass())); #endif diff --git a/remoting/host/host_mock_objects.cc b/remoting/host/host_mock_objects.cc index 1c43ecf..bbc1631 100644 --- a/remoting/host/host_mock_objects.cc +++ b/remoting/host/host_mock_objects.cc @@ -52,7 +52,7 @@ scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create() { } MockChromotingHostContext::MockChromotingHostContext() - : ChromotingHostContext(NULL, base::MessageLoopProxy::current()) { + : ChromotingHostContext(base::MessageLoopProxy::current()) { } MockChromotingHostContext::~MockChromotingHostContext() {} diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc index 7370f93..67362a2 100644 --- a/remoting/host/plugin/host_script_object.cc +++ b/remoting/host/plugin/host_script_object.cc @@ -134,8 +134,7 @@ bool HostNPScriptObject::Init() { DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); VLOG(2) << "Init"; - host_context_.reset(new ChromotingHostContext(NULL, - plugin_message_loop_proxy_)); + host_context_.reset(new ChromotingHostContext(plugin_message_loop_proxy_)); if (!host_context_->Start()) { host_context_.reset(); return false; diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index f380056..cb81bf8 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -77,15 +77,10 @@ class HostProcess : public OAuthClient::Delegate { public: HostProcess() : message_loop_(MessageLoop::TYPE_UI), - file_io_thread_("FileIO"), allow_nat_traversal_(true), restarting_(false) { - file_io_thread_.StartWithOptions( - base::Thread::Options(MessageLoop::TYPE_IO, 0)); - - context_.reset(new ChromotingHostContext( - file_io_thread_.message_loop_proxy(), - message_loop_.message_loop_proxy())); + context_.reset( + new ChromotingHostContext(message_loop_.message_loop_proxy())); context_->Start(); network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); } @@ -113,7 +108,7 @@ class HostProcess : public OAuthClient::Delegate { // The auth tokens can't be updated once the host is running, so we don't // need to check the pending state, but it's a required parameter. bool tokens_pending; - if (LoadConfig(file_io_thread_.message_loop_proxy(), &tokens_pending)) { + if (LoadConfig(&tokens_pending)) { context_->network_message_loop()->PostTask( FROM_HERE, base::Bind(&HostProcess::CreateAuthenticatorFactory, @@ -140,7 +135,7 @@ class HostProcess : public OAuthClient::Delegate { int Run() { bool tokens_pending = false; - if (!LoadConfig(file_io_thread_.message_loop_proxy(), &tokens_pending)) { + if (!LoadConfig(&tokens_pending)) { return kInvalidHostConfigurationExitCode; } if (tokens_pending) { @@ -157,7 +152,7 @@ class HostProcess : public OAuthClient::Delegate { } #if defined(OS_MACOSX) - file_io_thread_.message_loop_proxy()->PostTask( + context_->file_message_loop()->PostTask( FROM_HERE, base::Bind(&HostProcess::ListenForConfigChanges, base::Unretained(this))); @@ -192,14 +187,14 @@ class HostProcess : public OAuthClient::Delegate { private: void StartWatchingNatPolicy() { nat_policy_.reset( - policy_hack::NatPolicy::Create(file_io_thread_.message_loop_proxy())); + policy_hack::NatPolicy::Create( + context_->file_message_loop()->message_loop_proxy())); nat_policy_->StartWatching( base::Bind(&HostProcess::OnNatPolicyUpdate, base::Unretained(this))); } // Read Host config from disk, returning true if successful. - bool LoadConfig(base::MessageLoopProxy* io_message_loop, - bool* tokens_pending) { + bool LoadConfig(bool* tokens_pending) { JsonHostConfig host_config(host_config_path_); JsonHostConfig auth_config(auth_config_path_); @@ -343,7 +338,6 @@ class HostProcess : public OAuthClient::Delegate { } MessageLoop message_loop_; - base::Thread file_io_thread_; scoped_ptr<ChromotingHostContext> context_; scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index f37d7a9..d9fba33 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -93,12 +93,10 @@ class SimpleHost { public: SimpleHost() : message_loop_(MessageLoop::TYPE_UI), - file_io_thread_("FileIO"), - context_(NULL, message_loop_.message_loop_proxy()), + context_(message_loop_.message_loop_proxy()), fake_(false), is_it2me_(false) { context_.Start(); - file_io_thread_.Start(); network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); } @@ -263,7 +261,6 @@ class SimpleHost { } MessageLoop message_loop_; - base::Thread file_io_thread_; ChromotingHostContext context_; scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |