1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_
6 #define REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_
10 #include "base/callback_forward.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "remoting/protocol/errors.h"
23 class CandidateSessionConfig
;
26 class ExtensionMessage
;
30 class TransportFactory
;
31 struct TransportRoute
;
34 class ConnectionToHost
{
36 // The UI implementations maintain corresponding definitions of this
37 // enumeration in client_session.js and
38 // android/java/src/org/chromium/chromoting/jni/JniInterface.java. Be sure to
39 // update these locations if you make any changes to the ordering.
49 class HostEventCallback
{
51 virtual ~HostEventCallback() {}
53 // Called when state of the connection changes.
54 virtual void OnConnectionState(State state
, ErrorCode error
) = 0;
56 // Called when ready state of the connection changes. When |ready|
57 // is set to false some data sent by the peers may be
58 // delayed. This is used to indicate in the UI when connection is
59 // temporarily broken.
60 virtual void OnConnectionReady(bool ready
) = 0;
62 // Called when the route type (direct vs. STUN vs. proxied) changes.
63 virtual void OnRouteChanged(const std::string
& channel_name
,
64 const protocol::TransportRoute
& route
) = 0;
67 virtual ~ConnectionToHost() {}
69 // Allows to set a custom protocol configuration (e.g. for tests). Cannot be
70 // called after Connect().
71 virtual void set_candidate_config(
72 scoped_ptr
<CandidateSessionConfig
> config
) = 0;
74 // Set the stubs which will handle messages from the host.
75 // The caller must ensure that stubs out-live the connection.
76 // Unless otherwise specified, all stubs must be set before Connect()
78 virtual void set_client_stub(ClientStub
* client_stub
) = 0;
79 virtual void set_clipboard_stub(ClipboardStub
* clipboard_stub
) = 0;
80 virtual void set_video_stub(VideoStub
* video_stub
) = 0;
81 // If no audio stub is specified then audio will not be requested.
82 virtual void set_audio_stub(AudioStub
* audio_stub
) = 0;
84 // Initiates a connection to the host specified by |host_jid|.
85 // |signal_strategy| is used to signal to the host, and must outlive the
86 // connection. Data channels will be negotiated over |transport_factory|.
87 // |authenticator| will be used to authenticate the session and data channels.
88 // |event_callback| will be notified of changes in the state of the connection
89 // and must outlive the ConnectionToHost.
90 // Caller must set stubs (see below) before calling Connect.
91 virtual void Connect(SignalStrategy
* signal_strategy
,
92 scoped_ptr
<TransportFactory
> transport_factory
,
93 scoped_ptr
<Authenticator
> authenticator
,
94 const std::string
& host_jid
,
95 HostEventCallback
* event_callback
) = 0;
97 // Returns the session configuration that was negotiated with the host.
98 virtual const SessionConfig
& config() = 0;
100 // Stubs for sending data to the host.
101 virtual ClipboardStub
* clipboard_forwarder() = 0;
102 virtual HostStub
* host_stub() = 0;
103 virtual InputStub
* input_stub() = 0;
105 // Return the current state of ConnectionToHost.
106 virtual State
state() const = 0;
109 } // namespace protocol
110 } // namespace remoting
112 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_