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 "remoting/protocol/connection_to_client.h" | 5 #include "remoting/protocol/connection_to_client.h" |
6 | 6 |
7 #include "google/protobuf/message.h" | 7 #include "google/protobuf/message.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "remoting/protocol/client_control_sender.h" | 9 #include "remoting/protocol/client_control_sender.h" |
10 #include "remoting/protocol/host_message_dispatcher.h" | 10 #include "remoting/protocol/host_message_dispatcher.h" |
| 11 #include "remoting/protocol/host_stub.h" |
| 12 #include "remoting/protocol/input_stub.h" |
11 | 13 |
12 // TODO(hclam): Remove this header once MessageDispatcher is used. | 14 // TODO(hclam): Remove this header once MessageDispatcher is used. |
13 #include "remoting/base/compound_buffer.h" | 15 #include "remoting/base/compound_buffer.h" |
14 | 16 |
15 namespace remoting { | 17 namespace remoting { |
16 namespace protocol { | 18 namespace protocol { |
17 | 19 |
18 // Determine how many update streams we should count to find the size of | 20 // Determine how many update streams we should count to find the size of |
19 // average update stream. | 21 // average update stream. |
20 static const size_t kAverageUpdateStream = 10; | 22 static const size_t kAverageUpdateStream = 10; |
21 | 23 |
22 ConnectionToClient::ConnectionToClient(MessageLoop* message_loop, | 24 ConnectionToClient::ConnectionToClient(MessageLoop* message_loop, |
23 EventHandler* handler, | 25 EventHandler* handler, |
24 HostStub* host_stub, | 26 HostStub* host_stub, |
25 InputStub* input_stub) | 27 InputStub* input_stub) |
26 : loop_(message_loop), | 28 : client_authenticated_(false), |
| 29 loop_(message_loop), |
27 handler_(handler), | 30 handler_(handler), |
28 host_stub_(host_stub), | 31 host_stub_(host_stub), |
29 input_stub_(input_stub) { | 32 input_stub_(input_stub) { |
30 DCHECK(loop_); | 33 DCHECK(loop_); |
31 DCHECK(handler_); | 34 DCHECK(handler_); |
32 } | 35 } |
33 | 36 |
34 ConnectionToClient::~ConnectionToClient() { | 37 ConnectionToClient::~ConnectionToClient() { |
35 // TODO(hclam): When we shut down the viewer we may have to close the | 38 // TODO(hclam): When we shut down the viewer we may have to close the |
36 // connection. | 39 // connection. |
(...skipping 29 matching lines...) Expand all Loading... |
66 | 69 |
67 VideoStub* ConnectionToClient::video_stub() { | 70 VideoStub* ConnectionToClient::video_stub() { |
68 return video_writer_.get(); | 71 return video_writer_.get(); |
69 } | 72 } |
70 | 73 |
71 // Return pointer to ClientStub. | 74 // Return pointer to ClientStub. |
72 ClientStub* ConnectionToClient::client_stub() { | 75 ClientStub* ConnectionToClient::client_stub() { |
73 return client_stub_.get(); | 76 return client_stub_.get(); |
74 } | 77 } |
75 | 78 |
76 ConnectionToClient::ConnectionToClient() { | |
77 } | |
78 | |
79 void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { | 79 void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { |
80 if (state == protocol::Session::CONNECTED) { | 80 if (state == protocol::Session::CONNECTED) { |
81 client_stub_.reset(new ClientControlSender(session_->control_channel())); | 81 client_stub_.reset(new ClientControlSender(session_->control_channel())); |
82 video_writer_.reset(VideoWriter::Create(session_->config())); | 82 video_writer_.reset(VideoWriter::Create(session_->config())); |
83 video_writer_->Init(session_); | 83 video_writer_->Init(session_); |
84 | 84 |
85 dispatcher_.reset(new HostMessageDispatcher()); | 85 dispatcher_.reset(new HostMessageDispatcher()); |
86 dispatcher_->Initialize(session_.get(), host_stub_, input_stub_); | 86 dispatcher_->Initialize(session_.get(), host_stub_, input_stub_); |
87 } | 87 } |
88 | 88 |
(...skipping 27 matching lines...) Expand all Loading... |
116 default: | 116 default: |
117 // We shouldn't receive other states. | 117 // We shouldn't receive other states. |
118 NOTREACHED(); | 118 NOTREACHED(); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 // OnClosed() is used as a callback for protocol::Session::Close(). | 122 // OnClosed() is used as a callback for protocol::Session::Close(). |
123 void ConnectionToClient::OnClosed() { | 123 void ConnectionToClient::OnClosed() { |
124 } | 124 } |
125 | 125 |
| 126 void ConnectionToClient::OnClientAuthenticated() { |
| 127 client_authenticated_ = true; |
| 128 |
| 129 // Enable/disable each of the channels. |
| 130 if (input_stub_) |
| 131 input_stub_->OnAuthenticated(); |
| 132 if (host_stub_) |
| 133 host_stub_->OnAuthenticated(); |
| 134 if (client_stub_.get()) |
| 135 client_stub_->OnAuthenticated(); |
| 136 } |
| 137 |
126 } // namespace protocol | 138 } // namespace protocol |
127 } // namespace remoting | 139 } // namespace remoting |
OLD | NEW |