| 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 // This stub is thread safe because of the use of BufferedSocketWriter. | 5 // This stub is thread safe because of the use of BufferedSocketWriter. |
| 6 // BufferedSocketWriter buffers messages and send them on them right thread. | 6 // BufferedSocketWriter buffers messages and send them on them right thread. |
| 7 | 7 |
| 8 #include "remoting/protocol/host_control_sender.h" | 8 #include "remoting/protocol/host_control_sender.h" |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "remoting/protocol/buffered_socket_writer.h" | 11 #include "remoting/protocol/buffered_socket_writer.h" |
| 12 #include "remoting/proto/control.pb.h" | 12 #include "remoting/proto/control.pb.h" |
| 13 #include "remoting/proto/internal.pb.h" | 13 #include "remoting/proto/internal.pb.h" |
| 14 #include "remoting/protocol/util.h" | 14 #include "remoting/protocol/util.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 namespace protocol { | 17 namespace protocol { |
| 18 | 18 |
| 19 HostControlSender::HostControlSender(base::MessageLoopProxy* message_loop, | 19 HostControlSender::HostControlSender(base::MessageLoopProxy* message_loop, |
| 20 net::Socket* socket) | 20 net::Socket* socket) |
| 21 : buffered_writer_(new BufferedSocketWriter(message_loop)) { | 21 : buffered_writer_(new BufferedSocketWriter(message_loop)) { |
| 22 buffered_writer_->Init(socket, NULL); | 22 buffered_writer_->Init(socket, BufferedSocketWriter::WriteFailedCallback()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 HostControlSender::~HostControlSender() { | 25 HostControlSender::~HostControlSender() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void HostControlSender::BeginSessionRequest(const LocalLoginCredentials* msg, | 28 void HostControlSender::BeginSessionRequest(const LocalLoginCredentials* msg, |
| 29 Task* done) { | 29 const base::Closure& done) { |
| 30 protocol::ControlMessage message; | 30 protocol::ControlMessage message; |
| 31 message.mutable_begin_session_request()->mutable_credentials()->CopyFrom( | 31 message.mutable_begin_session_request()->mutable_credentials()->CopyFrom( |
| 32 *msg); | 32 *msg); |
| 33 buffered_writer_->Write(SerializeAndFrameMessage(message), done); | 33 buffered_writer_->Write(SerializeAndFrameMessage(message), done); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void HostControlSender::Close() { | 36 void HostControlSender::Close() { |
| 37 buffered_writer_->Close(); | 37 buffered_writer_->Close(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace protocol | 40 } // namespace protocol |
| 41 } // namespace remoting | 41 } // namespace remoting |
| OLD | NEW |