[Sync] Test Android passphrase creation UI
[chromium-blink-merge.git] / remoting / protocol / connection_to_host.h
bloba20bd22605986474c53152c975dc089c8bd99b20
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_
8 #include <string>
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"
15 namespace remoting {
17 class SignalStrategy;
19 namespace protocol {
21 class AudioStub;
22 class Authenticator;
23 class CandidateSessionConfig;
24 class ClientStub;
25 class ClipboardStub;
26 class ExtensionMessage;
27 class HostStub;
28 class InputStub;
29 class SessionConfig;
30 class TransportFactory;
31 struct TransportRoute;
32 class VideoStub;
34 class ConnectionToHost {
35 public:
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.
40 enum State {
41 INITIALIZING,
42 CONNECTING,
43 AUTHENTICATED,
44 CONNECTED,
45 FAILED,
46 CLOSED,
49 class HostEventCallback {
50 public:
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()
77 // is called.
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_