| OLD | NEW |
| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 MessageReader()); | 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<ControlMessage>( | 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) { |
| 43 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = | 43 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = |
| 44 new RefCountedMessage<ControlMessage>(message); | 44 new RefCountedMessage<ControlMessage>(message); |
| 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_msg)); |
| 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_msg)); |
| 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 |
| OLD | NEW |