diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-12 01:52:54 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-12 01:52:54 +0000 |
commit | 6be34a67b24aef48908eeaa99643a180359309dc (patch) | |
tree | c20c552cea0acb230a4ccc2a3a61256067db4a26 /remoting | |
parent | 693576920ab9d73c222a9d49ad70b89b1b1a19a7 (diff) | |
download | chromium_src-6be34a67b24aef48908eeaa99643a180359309dc.zip chromium_src-6be34a67b24aef48908eeaa99643a180359309dc.tar.gz chromium_src-6be34a67b24aef48908eeaa99643a180359309dc.tar.bz2 |
MessageLoopProxy cleanups in remoting client.
Replaced all usage of MessageLoopProxy with SingleThreadTaskRunner.
Also includes some other minor cleanups, e.g. removed
ClientContext::network_message_loop().
Review URL: https://chromiumcodereview.appspot.com/10454018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/chromoting_client.cc | 58 | ||||
-rw-r--r-- | remoting/client/chromoting_client.h | 16 | ||||
-rw-r--r-- | remoting/client/client_context.cc | 14 | ||||
-rw-r--r-- | remoting/client/client_context.h | 16 | ||||
-rw-r--r-- | remoting/client/frame_consumer_proxy.cc | 22 | ||||
-rw-r--r-- | remoting/client/frame_consumer_proxy.h | 7 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 11 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_network_manager.cc | 6 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_view.cc | 12 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_xmpp_proxy.cc | 24 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_xmpp_proxy.h | 15 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.cc | 26 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.h | 17 |
13 files changed, 115 insertions, 129 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index a545244..8b25885 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -26,18 +26,17 @@ ChromotingClient::QueuedVideoPacket::QueuedVideoPacket( ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() { } -ChromotingClient::ChromotingClient(const ClientConfig& config, - ClientContext* context, - protocol::ConnectionToHost* connection, - ChromotingView* view, - RectangleUpdateDecoder* rectangle_decoder, - const base::Closure& client_done) +ChromotingClient::ChromotingClient( + const ClientConfig& config, + scoped_refptr<base::SingleThreadTaskRunner> task_runner, + protocol::ConnectionToHost* connection, + ChromotingView* view, + RectangleUpdateDecoder* rectangle_decoder) : config_(config), - context_(context), + task_runner_(task_runner), connection_(connection), view_(view), rectangle_decoder_(rectangle_decoder), - client_done_(client_done), packet_being_processed_(false), last_sequence_number_(0), weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { @@ -49,7 +48,7 @@ ChromotingClient::~ChromotingClient() { void ChromotingClient::Start( scoped_refptr<XmppProxy> xmpp_proxy, scoped_ptr<protocol::TransportFactory> transport_factory) { - DCHECK(message_loop()->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); scoped_ptr<protocol::Authenticator> authenticator( protocol::NegotiatingAuthenticator::CreateForClient( @@ -63,18 +62,11 @@ void ChromotingClient::Start( config_.host_public_key, transport_factory.Pass(), authenticator.Pass(), this, this, this, this); - if (!view_->Initialize()) { - ClientDone(); - } + view_->Initialize(); } void ChromotingClient::Stop(const base::Closure& shutdown_task) { - if (!message_loop()->BelongsToCurrentThread()) { - message_loop()->PostTask( - FROM_HERE, base::Bind(&ChromotingClient::Stop, - weak_ptr_, shutdown_task)); - return; - } + DCHECK(task_runner_->BelongsToCurrentThread()); // Drop all pending packets. while(!received_packets_.empty()) { @@ -93,19 +85,14 @@ void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) { shutdown_task.Run(); } -void ChromotingClient::ClientDone() { - if (!client_done_.is_null()) { - message_loop()->PostTask(FROM_HERE, client_done_); - client_done_.Reset(); - } -} - ChromotingStats* ChromotingClient::GetStats() { + DCHECK(task_runner_->BelongsToCurrentThread()); return &stats_; } void ChromotingClient::InjectClipboardEvent( const protocol::ClipboardEvent& event) { + DCHECK(task_runner_->BelongsToCurrentThread()); view_->GetClipboardStub()->InjectClipboardEvent(event); } @@ -116,7 +103,7 @@ void ChromotingClient::SetCursorShape( void ChromotingClient::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) { - DCHECK(message_loop()->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); // If the video packet is empty then drop it. Empty packets are used to // maintain activity on the network. @@ -149,11 +136,12 @@ void ChromotingClient::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, } int ChromotingClient::GetPendingPackets() { + DCHECK(task_runner_->BelongsToCurrentThread()); return received_packets_.size(); } void ChromotingClient::DispatchPacket() { - DCHECK(message_loop()->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); CHECK(!packet_being_processed_); if (received_packets_.empty()) { @@ -180,21 +168,17 @@ void ChromotingClient::DispatchPacket() { void ChromotingClient::OnConnectionState( protocol::ConnectionToHost::State state, protocol::ErrorCode error) { - DCHECK(message_loop()->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); VLOG(1) << "ChromotingClient::OnConnectionState(" << state << ")"; if (state == protocol::ConnectionToHost::CONNECTED) Initialize(); view_->SetConnectionState(state, error); } -base::MessageLoopProxy* ChromotingClient::message_loop() { - return context_->network_message_loop(); -} - void ChromotingClient::OnPacketDone(bool last_packet, base::Time decode_start) { - if (!message_loop()->BelongsToCurrentThread()) { - message_loop()->PostTask(FROM_HERE, base::Bind( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask(FROM_HERE, base::Bind( &ChromotingClient::OnPacketDone, base::Unretained(this), last_packet, decode_start)); return; @@ -217,11 +201,7 @@ void ChromotingClient::OnPacketDone(bool last_packet, } void ChromotingClient::Initialize() { - if (!message_loop()->BelongsToCurrentThread()) { - message_loop()->PostTask(FROM_HERE, base::Bind( - &ChromotingClient::Initialize, weak_ptr_)); - return; - } + DCHECK(task_runner_->BelongsToCurrentThread()); // Initialize the decoder. rectangle_decoder_->Initialize(connection_->config()); diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h index 6856a20..9bfada3 100644 --- a/remoting/client/chromoting_client.h +++ b/remoting/client/chromoting_client.h @@ -22,7 +22,9 @@ #include "remoting/protocol/video_stub.h" #include "remoting/jingle_glue/xmpp_proxy.h" -class MessageLoop; +namespace base { +class SingleThreadTaskRunner; +} // namespace base namespace remoting { @@ -30,7 +32,6 @@ namespace protocol { class TransportFactory; } // namespace protocol -class ClientContext; class RectangleUpdateDecoder; // TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder. @@ -40,17 +41,16 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, public: // Objects passed in are not owned by this class. ChromotingClient(const ClientConfig& config, - ClientContext* context, + scoped_refptr<base::SingleThreadTaskRunner> task_runner, protocol::ConnectionToHost* connection, ChromotingView* view, - RectangleUpdateDecoder* rectangle_decoder, - const base::Closure& client_done); + RectangleUpdateDecoder* rectangle_decoder); virtual ~ChromotingClient(); + // Start/stop the client. Must be called on the main thread. void Start(scoped_refptr<XmppProxy> xmpp_proxy, scoped_ptr<protocol::TransportFactory> transport_factory); void Stop(const base::Closure& shutdown_task); - void ClientDone(); // Return the stats recorded by this client. ChromotingStats* GetStats(); @@ -82,8 +82,6 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, base::Closure done; }; - base::MessageLoopProxy* message_loop(); - // Initializes connection. void Initialize(); @@ -100,7 +98,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, // The following are not owned by this class. ClientConfig config_; - ClientContext* context_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; protocol::ConnectionToHost* connection_; ChromotingView* view_; RectangleUpdateDecoder* rectangle_decoder_; diff --git a/remoting/client/client_context.cc b/remoting/client/client_context.cc index b0bc941..7335dc3 100644 --- a/remoting/client/client_context.cc +++ b/remoting/client/client_context.cc @@ -6,8 +6,8 @@ namespace remoting { -ClientContext::ClientContext(base::MessageLoopProxy* main_message_loop_proxy) - : main_message_loop_proxy_(main_message_loop_proxy), +ClientContext::ClientContext(base::SingleThreadTaskRunner* main_task_runner) + : main_task_runner_(main_task_runner), decode_thread_("ChromotingClientDecodeThread") { } @@ -24,16 +24,12 @@ void ClientContext::Stop() { decode_thread_.Stop(); } -base::MessageLoopProxy* ClientContext::main_message_loop() { - return main_message_loop_proxy_; +base::SingleThreadTaskRunner* ClientContext::main_task_runner() { + return main_task_runner_; } -base::MessageLoopProxy* ClientContext::decode_message_loop() { +base::SingleThreadTaskRunner* ClientContext::decode_task_runner() { return decode_thread_.message_loop_proxy(); } -base::MessageLoopProxy* ClientContext::network_message_loop() { - return main_message_loop_proxy_; -} - } // namespace remoting diff --git a/remoting/client/client_context.h b/remoting/client/client_context.h index b6955b8..27a4416 100644 --- a/remoting/client/client_context.h +++ b/remoting/client/client_context.h @@ -7,27 +7,31 @@ #include <string> -#include "base/message_loop_proxy.h" #include "base/threading/thread.h" +namespace base { +class SingleThreadTaskRunner; +} // namespace base + namespace remoting { // A class that manages threads and running context for the chromoting client // process. class ClientContext { public: - ClientContext(base::MessageLoopProxy* main_message_loop_proxy); + // |main_task_runner| is the task runner for the main plugin thread + // that is used for all PPAPI calls, e.g. network and graphics. + ClientContext(base::SingleThreadTaskRunner* main_task_runner); virtual ~ClientContext(); void Start(); void Stop(); - base::MessageLoopProxy* main_message_loop(); - base::MessageLoopProxy* decode_message_loop(); - base::MessageLoopProxy* network_message_loop(); + base::SingleThreadTaskRunner* main_task_runner(); + base::SingleThreadTaskRunner* decode_task_runner(); private: - scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; // A thread that handles all decode operations. base::Thread decode_thread_; diff --git a/remoting/client/frame_consumer_proxy.cc b/remoting/client/frame_consumer_proxy.cc index b65f324..11ac1e3 100644 --- a/remoting/client/frame_consumer_proxy.cc +++ b/remoting/client/frame_consumer_proxy.cc @@ -5,22 +5,23 @@ #include "remoting/client/frame_consumer_proxy.h" #include "base/bind.h" -#include "base/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "ppapi/cpp/image_data.h" namespace remoting { FrameConsumerProxy::FrameConsumerProxy( - scoped_refptr<base::MessageLoopProxy> frame_consumer_message_loop) - : frame_consumer_message_loop_(frame_consumer_message_loop) { + scoped_refptr<base::SingleThreadTaskRunner> task_runner) + : task_runner_(task_runner) { } void FrameConsumerProxy::ApplyBuffer(const SkISize& view_size, const SkIRect& clip_area, pp::ImageData* buffer, const SkRegion& region) { - if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { - frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask(FROM_HERE, base::Bind( &FrameConsumerProxy::ApplyBuffer, this, view_size, clip_area, buffer, region)); return; @@ -31,8 +32,8 @@ void FrameConsumerProxy::ApplyBuffer(const SkISize& view_size, } void FrameConsumerProxy::ReturnBuffer(pp::ImageData* buffer) { - if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { - frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask(FROM_HERE, base::Bind( &FrameConsumerProxy::ReturnBuffer, this, buffer)); return; } @@ -42,8 +43,8 @@ void FrameConsumerProxy::ReturnBuffer(pp::ImageData* buffer) { } void FrameConsumerProxy::SetSourceSize(const SkISize& source_size) { - if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { - frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask(FROM_HERE, base::Bind( &FrameConsumerProxy::SetSourceSize, this, source_size)); return; } @@ -54,13 +55,12 @@ void FrameConsumerProxy::SetSourceSize(const SkISize& source_size) { void FrameConsumerProxy::Attach( const base::WeakPtr<FrameConsumer>& frame_consumer) { - DCHECK(frame_consumer_message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(frame_consumer_ == NULL); frame_consumer_ = frame_consumer; } FrameConsumerProxy::~FrameConsumerProxy() { - DCHECK(frame_consumer_message_loop_->BelongsToCurrentThread()); } } // namespace remoting diff --git a/remoting/client/frame_consumer_proxy.h b/remoting/client/frame_consumer_proxy.h index 0ee6e46..d5dfd45 100644 --- a/remoting/client/frame_consumer_proxy.h +++ b/remoting/client/frame_consumer_proxy.h @@ -15,7 +15,7 @@ #include "remoting/client/frame_consumer.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } // namespace base namespace remoting { @@ -26,8 +26,7 @@ class FrameConsumerProxy public: // Constructs a proxy for |frame_consumer| which will trampoline invocations // to |frame_consumer_message_loop|. - FrameConsumerProxy( - scoped_refptr<base::MessageLoopProxy> frame_consumer_message_loop); + FrameConsumerProxy(scoped_refptr<base::SingleThreadTaskRunner> task_runner); // FrameConsumer implementation. virtual void ApplyBuffer(const SkISize& view_size, @@ -46,7 +45,7 @@ class FrameConsumerProxy virtual ~FrameConsumerProxy(); base::WeakPtr<FrameConsumer> frame_consumer_; - scoped_refptr<base::MessageLoopProxy> frame_consumer_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy); }; diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 8435e1e..a3ef540 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -196,7 +196,7 @@ bool ChromotingInstance::Init(uint32_t argc, scoped_refptr<FrameConsumerProxy> consumer_proxy = new FrameConsumerProxy(plugin_message_loop_); rectangle_decoder_ = new RectangleUpdateDecoder( - context_.decode_message_loop(), consumer_proxy); + context_.decode_task_runner(), consumer_proxy); view_.reset(new PepperView(this, &context_, rectangle_decoder_.get())); consumer_proxy->Attach(view_->AsWeakPtr()); @@ -369,9 +369,9 @@ void ChromotingInstance::Connect(const ClientConfig& config) { jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); host_connection_.reset(new protocol::ConnectionToHost(true)); - client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), - view_.get(), rectangle_decoder_.get(), - base::Closure())); + client_.reset(new ChromotingClient(config, context_.main_task_runner(), + host_connection_.get(), view_.get(), + rectangle_decoder_.get())); // Construct the input pipeline mouse_input_filter_.reset( @@ -398,8 +398,7 @@ void ChromotingInstance::Connect(const ClientConfig& config) { // Setup the XMPP Proxy. xmpp_proxy_ = new PepperXmppProxy( base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()), - plugin_message_loop_, - context_.network_message_loop()); + plugin_message_loop_, context_.main_task_runner()); scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator( PepperPortAllocator::Create(this)); diff --git a/remoting/client/plugin/pepper_network_manager.cc b/remoting/client/plugin/pepper_network_manager.cc index b9c8c72..1eaabc0 100644 --- a/remoting/client/plugin/pepper_network_manager.cc +++ b/remoting/client/plugin/pepper_network_manager.cc @@ -5,7 +5,9 @@ #include "remoting/client/plugin/pepper_network_manager.h" #include "base/bind.h" -#include "base/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/private/network_list_private.h" #include "ppapi/cpp/private/net_address_private.h" @@ -27,7 +29,7 @@ PepperNetworkManager::~PepperNetworkManager() { void PepperNetworkManager::StartUpdating() { if (network_list_received_) { // Post a task to avoid reentrancy. - MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PepperNetworkManager::SendNetworksChangedSignal, weak_factory_.GetWeakPtr())); } diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc index 531ff6c..35976e4 100644 --- a/remoting/client/plugin/pepper_view.cc +++ b/remoting/client/plugin/pepper_view.cc @@ -96,7 +96,7 @@ bool PepperView::Initialize() { } void PepperView::TearDown() { - DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); + DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); DCHECK(is_initialized_); is_initialized_ = false; @@ -117,7 +117,7 @@ void PepperView::TearDown() { void PepperView::SetConnectionState(protocol::ConnectionToHost::State state, protocol::ErrorCode error) { - DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); + DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); switch (state) { case protocol::ConnectionToHost::CONNECTING: @@ -188,7 +188,7 @@ void PepperView::ApplyBuffer(const SkISize& view_size, const SkIRect& clip_area, pp::ImageData* buffer, const SkRegion& region) { - DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); + DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); if (!frame_received_) { instance_->OnFirstFrameReceived(); @@ -208,7 +208,7 @@ void PepperView::ApplyBuffer(const SkISize& view_size, } void PepperView::ReturnBuffer(pp::ImageData* buffer) { - DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); + DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); // Free the buffer if there is nothing to paint. if (!is_initialized_) { @@ -228,7 +228,7 @@ void PepperView::ReturnBuffer(pp::ImageData* buffer) { } void PepperView::SetSourceSize(const SkISize& source_size) { - DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); + DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); if (source_size_ == source_size) return; @@ -337,7 +337,7 @@ void PepperView::FlushBuffer(const SkIRect& clip_area, void PepperView::OnFlushDone(base::Time paint_start, pp::ImageData* buffer, int result) { - DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); + DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); DCHECK(flush_pending_); instance_->GetStats()->video_paint_ms()->Record( diff --git a/remoting/client/plugin/pepper_xmpp_proxy.cc b/remoting/client/plugin/pepper_xmpp_proxy.cc index 5ab0689..f289092 100644 --- a/remoting/client/plugin/pepper_xmpp_proxy.cc +++ b/remoting/client/plugin/pepper_xmpp_proxy.cc @@ -12,29 +12,31 @@ namespace remoting { PepperXmppProxy::PepperXmppProxy( const SendIqCallback& send_iq_callback, - base::MessageLoopProxy* plugin_message_loop, - base::MessageLoopProxy* callback_message_loop) + base::SingleThreadTaskRunner* plugin_task_runner, + base::SingleThreadTaskRunner* callback_task_runner) : send_iq_callback_(send_iq_callback), - plugin_message_loop_(plugin_message_loop), - callback_message_loop_(callback_message_loop) { - DCHECK(plugin_message_loop_->BelongsToCurrentThread()); + plugin_task_runner_(plugin_task_runner), + callback_task_runner_(callback_task_runner) { + DCHECK(plugin_task_runner_->BelongsToCurrentThread()); } PepperXmppProxy::~PepperXmppProxy() { } -void PepperXmppProxy::AttachCallback(base::WeakPtr<ResponseCallback> callback) { - DCHECK(callback_message_loop_->BelongsToCurrentThread()); +void PepperXmppProxy::AttachCallback( + base::WeakPtr<ResponseCallback> callback) { + DCHECK(callback_task_runner_->BelongsToCurrentThread()); callback_ = callback; } void PepperXmppProxy::DetachCallback() { + DCHECK(callback_task_runner_->BelongsToCurrentThread()); callback_.reset(); } void PepperXmppProxy::SendIq(const std::string& request_xml) { - if (!plugin_message_loop_->BelongsToCurrentThread()) { - plugin_message_loop_->PostTask(FROM_HERE, base::Bind( + if (!plugin_task_runner_->BelongsToCurrentThread()) { + plugin_task_runner_->PostTask(FROM_HERE, base::Bind( &PepperXmppProxy::SendIq, this, request_xml)); return; } @@ -43,8 +45,8 @@ void PepperXmppProxy::SendIq(const std::string& request_xml) { } void PepperXmppProxy::OnIq(const std::string& response_xml) { - if (!callback_message_loop_->BelongsToCurrentThread()) { - callback_message_loop_->PostTask( + if (!callback_task_runner_->BelongsToCurrentThread()) { + callback_task_runner_->PostTask( FROM_HERE, base::Bind(&PepperXmppProxy::OnIq, this, response_xml)); return; } diff --git a/remoting/client/plugin/pepper_xmpp_proxy.h b/remoting/client/plugin/pepper_xmpp_proxy.h index 40ba4ba..0c1bc79 100644 --- a/remoting/client/plugin/pepper_xmpp_proxy.h +++ b/remoting/client/plugin/pepper_xmpp_proxy.h @@ -11,7 +11,7 @@ #include "remoting/jingle_glue/xmpp_proxy.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } // namespace base namespace remoting { @@ -20,10 +20,15 @@ class PepperXmppProxy : public XmppProxy { public: typedef base::Callback<void(const std::string&)> SendIqCallback; + // |plugin_task_runner| is the thread on which |send_iq_callback| is + // called. Normally the callback will call JavaScript, so this has + // to be the task runner that corresponds to the plugin + // thread. |callback_task_runner| is used to call the callback + // registered with AttachCallback(). PepperXmppProxy( const SendIqCallback& send_iq_callback, - base::MessageLoopProxy* plugin_message_loop, - base::MessageLoopProxy* callback_message_loop); + base::SingleThreadTaskRunner* plugin_task_runner, + base::SingleThreadTaskRunner* callback_task_runner); // Registered the callback class with this object. // @@ -46,8 +51,8 @@ class PepperXmppProxy : public XmppProxy { SendIqCallback send_iq_callback_; - scoped_refptr<base::MessageLoopProxy> plugin_message_loop_; - scoped_refptr<base::MessageLoopProxy> callback_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_; + scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_; // Must only be access on callback_message_loop_. base::WeakPtr<ResponseCallback> callback_; diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc index 0ad0422..ffc95f0 100644 --- a/remoting/client/rectangle_update_decoder.cc +++ b/remoting/client/rectangle_update_decoder.cc @@ -25,9 +25,9 @@ using remoting::protocol::SessionConfig; namespace remoting { RectangleUpdateDecoder::RectangleUpdateDecoder( - scoped_refptr<base::MessageLoopProxy> message_loop, + scoped_refptr<base::SingleThreadTaskRunner> task_runner, scoped_refptr<FrameConsumerProxy> consumer) - : message_loop_(message_loop), + : task_runner_(task_runner), consumer_(consumer), source_size_(SkISize::Make(0, 0)), view_size_(SkISize::Make(0, 0)), @@ -54,8 +54,8 @@ void RectangleUpdateDecoder::Initialize(const SessionConfig& config) { void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) { - if (!message_loop_->BelongsToCurrentThread()) { - message_loop_->PostTask( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask( FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket, this, base::Passed(&packet), done)); return; @@ -99,7 +99,7 @@ void RectangleUpdateDecoder::SchedulePaint() { if (paint_scheduled_) return; paint_scheduled_ = true; - message_loop_->PostTask( + task_runner_->PostTask( FROM_HERE, base::Bind(&RectangleUpdateDecoder::DoPaint, this)); } @@ -131,8 +131,8 @@ void RectangleUpdateDecoder::DoPaint() { } void RectangleUpdateDecoder::RequestReturnBuffers(const base::Closure& done) { - if (!message_loop_->BelongsToCurrentThread()) { - message_loop_->PostTask( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask( FROM_HERE, base::Bind(&RectangleUpdateDecoder::RequestReturnBuffers, this, done)); return; @@ -148,8 +148,8 @@ void RectangleUpdateDecoder::RequestReturnBuffers(const base::Closure& done) { } void RectangleUpdateDecoder::DrawBuffer(pp::ImageData* buffer) { - if (!message_loop_->BelongsToCurrentThread()) { - message_loop_->PostTask( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask( FROM_HERE, base::Bind(&RectangleUpdateDecoder::DrawBuffer, this, buffer)); return; @@ -163,8 +163,8 @@ void RectangleUpdateDecoder::DrawBuffer(pp::ImageData* buffer) { } void RectangleUpdateDecoder::InvalidateRegion(const SkRegion& region) { - if (!message_loop_->BelongsToCurrentThread()) { - message_loop_->PostTask( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask( FROM_HERE, base::Bind(&RectangleUpdateDecoder::InvalidateRegion, this, region)); return; @@ -178,8 +178,8 @@ void RectangleUpdateDecoder::InvalidateRegion(const SkRegion& region) { void RectangleUpdateDecoder::SetOutputSizeAndClip(const SkISize& view_size, const SkIRect& clip_area) { - if (!message_loop_->BelongsToCurrentThread()) { - message_loop_->PostTask( + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask( FROM_HERE, base::Bind(&RectangleUpdateDecoder::SetOutputSizeAndClip, this, view_size, clip_area)); return; diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h index eee0e76..557aee2 100644 --- a/remoting/client/rectangle_update_decoder.h +++ b/remoting/client/rectangle_update_decoder.h @@ -15,7 +15,7 @@ #include "remoting/client/frame_producer.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } // namespace base namespace pp { @@ -33,14 +33,15 @@ class SessionConfig; // TODO(ajwong): Re-examine this API, especially with regards to how error // conditions on each step are reported. Should they be CHECKs? Logs? Other? // TODO(sergeyu): Rename this class. -class RectangleUpdateDecoder : - public base::RefCountedThreadSafe<RectangleUpdateDecoder>, - public FrameProducer { +class RectangleUpdateDecoder + : public base::RefCountedThreadSafe<RectangleUpdateDecoder>, + public FrameProducer { public: - // Creates an update decoder on |message_loop_|, outputting to |consumer|. + // Creates an update decoder on |task_runner_|, outputting to |consumer|. // TODO(wez): Replace the ref-counted proxy with an owned FrameConsumer. - RectangleUpdateDecoder(scoped_refptr<base::MessageLoopProxy> message_loop, - scoped_refptr<FrameConsumerProxy> consumer); + RectangleUpdateDecoder( + scoped_refptr<base::SingleThreadTaskRunner> task_runner, + scoped_refptr<FrameConsumerProxy> consumer); // Initializes decoder with the information from the protocol config. void Initialize(const protocol::SessionConfig& config); @@ -67,7 +68,7 @@ class RectangleUpdateDecoder : void SchedulePaint(); void DoPaint(); - scoped_refptr<base::MessageLoopProxy> message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<FrameConsumerProxy> consumer_; scoped_ptr<Decoder> decoder_; |