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

Side by Side Diff: remoting/protocol/client_message_dispatcher.cc

Issue 6271004: Changed MessageReader so that it doesn't read from the socket if there are (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/ref_counted.h" 5 #include "base/ref_counted.h"
6 #include "net/base/io_buffer.h" 6 #include "net/base/io_buffer.h"
7 #include "remoting/proto/control.pb.h" 7 #include "remoting/proto/control.pb.h"
8 #include "remoting/proto/event.pb.h" 8 #include "remoting/proto/event.pb.h"
9 #include "remoting/proto/internal.pb.h" 9 #include "remoting/proto/internal.pb.h"
10 #include "remoting/protocol/client_message_dispatcher.h" 10 #include "remoting/protocol/client_message_dispatcher.h"
11 #include "remoting/protocol/client_stub.h" 11 #include "remoting/protocol/client_stub.h"
12 #include "remoting/protocol/input_stub.h" 12 #include "remoting/protocol/input_stub.h"
13 #include "remoting/protocol/message_reader.h" 13 #include "remoting/protocol/message_reader.h"
14 #include "remoting/protocol/ref_counted_message.h" 14 #include "remoting/protocol/ref_counted_task.h"
15 #include "remoting/protocol/session.h" 15 #include "remoting/protocol/session.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 namespace protocol { 18 namespace protocol {
19 19
20 ClientMessageDispatcher::ClientMessageDispatcher() : client_stub_(NULL) { 20 ClientMessageDispatcher::ClientMessageDispatcher() : client_stub_(NULL) {
21 } 21 }
22 22
23 ClientMessageDispatcher::~ClientMessageDispatcher() { 23 ClientMessageDispatcher::~ClientMessageDispatcher() {
24 } 24 }
25 25
26 void ClientMessageDispatcher::Initialize( 26 void ClientMessageDispatcher::Initialize(
27 protocol::Session* session, ClientStub* client_stub) { 27 protocol::Session* session, ClientStub* client_stub) {
28 if (!session || !client_stub || !session->control_channel()) { 28 if (!session || !client_stub || !session->control_channel()) {
29 return; 29 return;
30 } 30 }
31 31
32 control_message_reader_.reset(new ProtobufMessageReader<ControlMessage>()); 32 control_message_reader_.reset(new ProtobufMessageReader<ControlMessage>());
33 client_stub_ = client_stub; 33 client_stub_ = client_stub;
34 34
35 control_message_reader_->Init( 35 control_message_reader_->Init(
36 session->control_channel(), 36 session->control_channel(),
37 NewCallback(this, &ClientMessageDispatcher::OnControlMessageReceived)); 37 NewCallback(this, &ClientMessageDispatcher::OnControlMessageReceived));
38 return; 38 return;
39 } 39 }
40 40
41 void ClientMessageDispatcher::OnControlMessageReceived( 41 void ClientMessageDispatcher::OnControlMessageReceived(
42 ControlMessage* message) { 42 ControlMessage* message, Task* done_task) {
43 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = 43 scoped_refptr<RefCountedTask > ref_counted_task =
44 new RefCountedMessage<ControlMessage>(message); 44 new RefCountedTask(done_task);
45 if (message->has_notify_resolution()) { 45 if (message->has_notify_resolution()) {
46 client_stub_->NotifyResolution( 46 client_stub_->NotifyResolution(
47 &message->notify_resolution(), NewDeleteTask(ref_msg)); 47 &message->notify_resolution(), NewDeleteTask(ref_counted_task));
48 } else if (message->has_begin_session_response()) { 48 } else if (message->has_begin_session_response()) {
49 client_stub_->BeginSessionResponse( 49 client_stub_->BeginSessionResponse(
50 &message->begin_session_response().login_status(), 50 &message->begin_session_response().login_status(),
51 NewDeleteTask(ref_msg)); 51 NewDeleteTask(ref_counted_task));
52 } else { 52 } else {
53 NOTREACHED() << "Invalid control message received"; 53 NOTREACHED() << "Invalid control message received";
54 } 54 }
55 } 55 }
56 56
57 } // namespace protocol 57 } // namespace protocol
58 } // namespace remoting 58 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698