Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Unified Diff: remoting/protocol/message_reader.cc

Issue 10332304: Don't depend on MessageLoopProxy in remoting protocol code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/message_reader.h ('k') | remoting/protocol/protobuf_video_writer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/message_reader.cc
diff --git a/remoting/protocol/message_reader.cc b/remoting/protocol/message_reader.cc
index 5bf540fe7f81a60b280c435fa9e000b641b51586..02dc99792626db5dba362f006509267d696a769b 100644
--- a/remoting/protocol/message_reader.cc
+++ b/remoting/protocol/message_reader.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
+#include "base/thread_task_runner_handle.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/socket/socket.h"
@@ -91,26 +92,23 @@ void MessageReader::OnDataReceived(net::IOBuffer* data, int data_size) {
pending_messages_ += new_messages.size();
- // TODO(lambroslambrou): MessageLoopProxy::current() will not work from the
- // plugin thread if this code is compiled into a separate binary. Fix this.
for (std::vector<CompoundBuffer*>::iterator it = new_messages.begin();
it != new_messages.end(); ++it) {
message_received_callback_.Run(
scoped_ptr<CompoundBuffer>(*it),
base::Bind(&MessageReader::OnMessageDone, this,
- base::MessageLoopProxy::current()));
+ base::ThreadTaskRunnerHandle::Get()));
}
}
void MessageReader::OnMessageDone(
- scoped_refptr<base::MessageLoopProxy> message_loop) {
- if (!message_loop->BelongsToCurrentThread()) {
- message_loop->PostTask(
- FROM_HERE,
- base::Bind(&MessageReader::OnMessageDone, this, message_loop));
- return;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ if (task_runner->BelongsToCurrentThread()) {
+ ProcessDoneEvent();
+ } else {
+ task_runner->PostTask(
+ FROM_HERE, base::Bind(&MessageReader::ProcessDoneEvent, this));
}
- ProcessDoneEvent();
}
void MessageReader::ProcessDoneEvent() {
« no previous file with comments | « remoting/protocol/message_reader.h ('k') | remoting/protocol/protobuf_video_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698