| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 5 #include "base/memory/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 15 matching lines...) Expand all Loading... |
| 26 protocol::Session* session, ClientStub* client_stub) { | 26 protocol::Session* session, ClientStub* client_stub) { |
| 27 if (!session || !client_stub || !session->control_channel()) { | 27 if (!session || !client_stub || !session->control_channel()) { |
| 28 return; | 28 return; |
| 29 } | 29 } |
| 30 | 30 |
| 31 control_message_reader_.reset(new ProtobufMessageReader<ControlMessage>()); | 31 control_message_reader_.reset(new ProtobufMessageReader<ControlMessage>()); |
| 32 client_stub_ = client_stub; | 32 client_stub_ = client_stub; |
| 33 | 33 |
| 34 control_message_reader_->Init( | 34 control_message_reader_->Init( |
| 35 session->control_channel(), | 35 session->control_channel(), |
| 36 NewCallback(this, &ClientMessageDispatcher::OnControlMessageReceived)); | 36 base::Bind(&ClientMessageDispatcher::OnControlMessageReceived, |
| 37 base::Unretained(this))); |
| 37 return; | 38 return; |
| 38 } | 39 } |
| 39 | 40 |
| 40 void ClientMessageDispatcher::OnControlMessageReceived( | 41 void ClientMessageDispatcher::OnControlMessageReceived( |
| 41 ControlMessage* message, Task* done_task) { | 42 ControlMessage* message, const base::Closure& done_task) { |
| 42 if (message->has_begin_session_response()) { | 43 if (message->has_begin_session_response()) { |
| 43 const BeginSessionResponse& response = message->begin_session_response(); | 44 const BeginSessionResponse& response = message->begin_session_response(); |
| 44 if (response.has_login_status() && | 45 if (response.has_login_status() && |
| 45 response.login_status().has_success()) { | 46 response.login_status().has_success()) { |
| 46 client_stub_->BeginSessionResponse( | 47 client_stub_->BeginSessionResponse( |
| 47 &response.login_status(), done_task); | 48 &response.login_status(), done_task); |
| 48 return; | 49 return; |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 | 52 |
| 52 LOG(WARNING) << "Invalid control message received."; | 53 LOG(WARNING) << "Invalid control message received."; |
| 53 | 54 |
| 54 done_task->Run(); | 55 done_task.Run(); |
| 55 delete done_task; | |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace protocol | 58 } // namespace protocol |
| 59 } // namespace remoting | 59 } // namespace remoting |
| OLD | NEW |