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

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

Issue 8774017: Add AUTHENTICATED session state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years 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) 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 "remoting/protocol/connection_to_client.h" 5 #include "remoting/protocol/connection_to_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "google/protobuf/message.h" 10 #include "google/protobuf/message.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { 81 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) {
82 DCHECK(CalledOnValidThread()); 82 DCHECK(CalledOnValidThread());
83 host_stub_ = host_stub; 83 host_stub_ = host_stub;
84 } 84 }
85 85
86 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { 86 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) {
87 DCHECK(CalledOnValidThread()); 87 DCHECK(CalledOnValidThread());
88 input_stub_ = input_stub; 88 input_stub_ = input_stub;
89 } 89 }
90 90
91 void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { 91 void ConnectionToClient::OnSessionStateChange(Session::State state) {
92 DCHECK(CalledOnValidThread()); 92 DCHECK(CalledOnValidThread());
93 93
94 DCHECK(handler_); 94 DCHECK(handler_);
95 switch(state) { 95 switch(state) {
96 case protocol::Session::CONNECTING: 96 case Session::INITIALIZING:
97 // Don't care about this message. 97 case Session::CONNECTING:
98 case Session::CONNECTED:
99 // Don't care about these events.
98 break; 100 break;
99 101
100 case protocol::Session::CONNECTED: 102 case Session::AUTHENTICATED:
101 // Initialize channels. 103 // Initialize channels.
102 control_dispatcher_.reset(new HostControlDispatcher()); 104 control_dispatcher_.reset(new HostControlDispatcher());
103 control_dispatcher_->Init(session_.get(), base::Bind( 105 control_dispatcher_->Init(session_.get(), base::Bind(
104 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); 106 &ConnectionToClient::OnChannelInitialized, base::Unretained(this)));
105 control_dispatcher_->set_host_stub(host_stub_); 107 control_dispatcher_->set_host_stub(host_stub_);
106 108
107 event_dispatcher_.reset(new HostEventDispatcher()); 109 event_dispatcher_.reset(new HostEventDispatcher());
108 event_dispatcher_->Init(session_.get(), base::Bind( 110 event_dispatcher_->Init(session_.get(), base::Bind(
109 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); 111 &ConnectionToClient::OnChannelInitialized, base::Unretained(this)));
110 event_dispatcher_->set_input_stub(input_stub_); 112 event_dispatcher_->set_input_stub(input_stub_);
111 event_dispatcher_->set_sequence_number_callback(base::Bind( 113 event_dispatcher_->set_sequence_number_callback(base::Bind(
112 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this))); 114 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this)));
113 115
114 video_writer_.reset(VideoWriter::Create( 116 video_writer_.reset(VideoWriter::Create(
115 base::MessageLoopProxy::current(), session_->config())); 117 base::MessageLoopProxy::current(), session_->config()));
116 video_writer_->Init(session_.get(), base::Bind( 118 video_writer_->Init(session_.get(), base::Bind(
117 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); 119 &ConnectionToClient::OnChannelInitialized, base::Unretained(this)));
118 120
119 break; 121 break;
120 122
121 case protocol::Session::CLOSED: 123 case Session::CLOSED:
122 CloseChannels(); 124 CloseChannels();
123 handler_->OnConnectionClosed(this); 125 handler_->OnConnectionClosed(this);
124 break; 126 break;
125 127
126 case protocol::Session::FAILED: 128 case Session::FAILED:
127 CloseOnError(); 129 CloseOnError();
128 break; 130 break;
129
130 default:
131 // We shouldn't receive other states.
132 NOTREACHED();
133 } 131 }
134 } 132 }
135 133
136 void ConnectionToClient::OnChannelInitialized(bool successful) { 134 void ConnectionToClient::OnChannelInitialized(bool successful) {
137 DCHECK(CalledOnValidThread()); 135 DCHECK(CalledOnValidThread());
138 136
139 if (!successful) { 137 if (!successful) {
140 LOG(ERROR) << "Failed to connect a channel"; 138 LOG(ERROR) << "Failed to connect a channel";
141 CloseOnError(); 139 CloseOnError();
142 return; 140 return;
(...skipping 18 matching lines...) Expand all
161 } 159 }
162 160
163 void ConnectionToClient::CloseChannels() { 161 void ConnectionToClient::CloseChannels() {
164 control_dispatcher_.reset(); 162 control_dispatcher_.reset();
165 event_dispatcher_.reset(); 163 event_dispatcher_.reset();
166 video_writer_.reset(); 164 video_writer_.reset();
167 } 165 }
168 166
169 } // namespace protocol 167 } // namespace protocol
170 } // namespace remoting 168 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_view.cc ('k') | remoting/protocol/connection_to_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698