diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-12 23:47:51 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-12 23:47:51 +0000 |
commit | 22aae95df95ac05d0fe4bf5a206e5631ea9c3242 (patch) | |
tree | e443dd13f566b2adb6be3191b7b66d98e2918ff6 /remoting/protocol/pepper_stream_channel.h | |
parent | 82ca9b9f30b2c497b9f224086de0089a6cb7a419 (diff) | |
download | chromium_src-22aae95df95ac05d0fe4bf5a206e5631ea9c3242.zip chromium_src-22aae95df95ac05d0fe4bf5a206e5631ea9c3242.tar.gz chromium_src-22aae95df95ac05d0fe4bf5a206e5631ea9c3242.tar.bz2 |
Chromoting protocol implementation based on P2P Transport API.
Then new code is not enabled yet, there are still some issues that
need to be resolved before this code is used by default. I plan to
make the switch in M16, as there isn't enough time left in M15.
TEST=Manual
BUG=51198
Review URL: http://codereview.chromium.org/7778022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/pepper_stream_channel.h')
-rw-r--r-- | remoting/protocol/pepper_stream_channel.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/remoting/protocol/pepper_stream_channel.h b/remoting/protocol/pepper_stream_channel.h new file mode 100644 index 0000000..d5afe27 --- /dev/null +++ b/remoting/protocol/pepper_stream_channel.h @@ -0,0 +1,92 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ +#define REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ + +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "net/base/completion_callback.h" +#include "remoting/protocol/channel_authenticator.h" +#include "remoting/protocol/pepper_channel.h" +#include "remoting/protocol/pepper_transport_socket_adapter.h" +#include "remoting/protocol/session.h" + +namespace net { +class CertVerifier; +class StreamSocket; +class SSLClientSocket; +class SSLServerSocket; +} // namespace net + +namespace remoting { +namespace protocol { + +class PepperSession; + +class PepperStreamChannel : public PepperChannel, + public PepperTransportSocketAdapter::Observer { + public: + PepperStreamChannel(PepperSession* session, + const std::string& name, + const Session::StreamChannelCallback& callback); + virtual ~PepperStreamChannel(); + + // PepperChannel implementation. + virtual void Connect(pp::Instance* pp_instance, + const TransportConfig& transport_config, + const std::string& remote_cert) OVERRIDE; + virtual void AddRemoveCandidate(const cricket::Candidate& candidate) OVERRIDE; + virtual const std::string& name() OVERRIDE; + + // PepperTransportSocketAdapter implementation. + virtual void OnChannelDeleted() OVERRIDE; + virtual void OnChannelNewLocalCandidate( + const std::string& candidate) OVERRIDE; + + private: + void OnP2PConnect(int result); + + bool EstablishSSLConnection(); + void OnSSLConnect(int result); + + void AuthenticateChannel(); + void OnAuthenticationDone(ChannelAuthenticator::Result result); + + void NotifyConnected(net::StreamSocket* socket); + void NotifyConnectFailed(); + + PepperSession* session_; + std::string name_; + Session::StreamChannelCallback callback_; + + std::string remote_cert_; + + // We own |channel_| until it is connected. After that + // SSLClientSocket owns it. + scoped_ptr<PepperTransportSocketAdapter> owned_channel_; + PepperTransportSocketAdapter* channel_; + + // Indicates that we've finished connecting. + bool connected_; + + scoped_ptr<net::StreamSocket> socket_; + net::SSLClientSocket* ssl_client_socket_; + + // Used to verify the certificate received in SSLClientSocket. + scoped_ptr<net::CertVerifier> cert_verifier_; + + scoped_ptr<ChannelAuthenticator> authenticator_; + + // Callback called by the TCP and SSL layers. + net::CompletionCallbackImpl<PepperStreamChannel> p2p_connect_callback_; + net::CompletionCallbackImpl<PepperStreamChannel> ssl_connect_callback_; + + DISALLOW_COPY_AND_ASSIGN(PepperStreamChannel); +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |