Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / remoting / protocol / connection_to_host_impl.h
blobfc2306d9760c5c671629d4b1010ad24348b3c22e
1 // Copyright 2015 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_IMPL_H_
6 #define REMOTING_PROTOCOL_CONNECTION_TO_HOST_IMPL_H_
8 #include <set>
9 #include <string>
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/non_thread_safe.h"
15 #include "remoting/proto/internal.pb.h"
16 #include "remoting/protocol/channel_dispatcher_base.h"
17 #include "remoting/protocol/clipboard_filter.h"
18 #include "remoting/protocol/connection_to_host.h"
19 #include "remoting/protocol/errors.h"
20 #include "remoting/protocol/input_filter.h"
21 #include "remoting/protocol/message_reader.h"
22 #include "remoting/protocol/monitored_video_stub.h"
23 #include "remoting/protocol/session.h"
24 #include "remoting/protocol/session_config.h"
25 #include "remoting/protocol/session_manager.h"
26 #include "remoting/signaling/signal_strategy.h"
28 namespace remoting {
30 class XmppProxy;
31 class VideoPacket;
33 namespace protocol {
35 class AudioReader;
36 class ClientControlDispatcher;
37 class ClientEventDispatcher;
38 class ClientVideoDispatcher;
40 class ConnectionToHostImpl : public ConnectionToHost,
41 public SignalStrategy::Listener,
42 public SessionManager::Listener,
43 public Session::EventHandler,
44 public ChannelDispatcherBase::EventHandler,
45 public base::NonThreadSafe {
46 public:
47 ConnectionToHostImpl();
48 ~ConnectionToHostImpl() override;
50 // ConnectionToHost interface.
51 void set_candidate_config(scoped_ptr<CandidateSessionConfig> config) override;
52 void set_client_stub(ClientStub* client_stub) override;
53 void set_clipboard_stub(ClipboardStub* clipboard_stub) override;
54 void set_video_stub(VideoStub* video_stub) override;
55 void set_audio_stub(AudioStub* audio_stub) override;
56 void Connect(SignalStrategy* signal_strategy,
57 scoped_ptr<TransportFactory> transport_factory,
58 scoped_ptr<Authenticator> authenticator,
59 const std::string& host_jid,
60 HostEventCallback* event_callback) override;
61 const SessionConfig& config() override;
62 ClipboardStub* clipboard_forwarder() override;
63 HostStub* host_stub() override;
64 InputStub* input_stub() override;
65 State state() const override;
67 private:
68 // SignalStrategy::StatusObserver interface.
69 void OnSignalStrategyStateChange(SignalStrategy::State state) override;
70 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override;
72 // SessionManager::Listener interface.
73 void OnSessionManagerReady() override;
74 void OnIncomingSession(
75 Session* session,
76 SessionManager::IncomingSessionResponse* response) override;
78 // Session::EventHandler interface.
79 void OnSessionStateChange(Session::State state) override;
80 void OnSessionRouteChange(const std::string& channel_name,
81 const TransportRoute& route) override;
83 // ChannelDispatcherBase::EventHandler interface.
84 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override;
85 void OnChannelError(ChannelDispatcherBase* channel_dispatcher,
86 ErrorCode error) override;
88 // MonitoredVideoStub::EventHandler interface.
89 virtual void OnVideoChannelStatus(bool active);
91 void NotifyIfChannelsReady();
93 void CloseOnError(ErrorCode error);
95 // Stops writing in the channels.
96 void CloseChannels();
98 void SetState(State state, ErrorCode error);
100 std::string host_jid_;
101 std::string host_public_key_;
102 scoped_ptr<Authenticator> authenticator_;
104 HostEventCallback* event_callback_;
106 scoped_ptr<CandidateSessionConfig> candidate_config_;
108 // Stub for incoming messages.
109 ClientStub* client_stub_;
110 ClipboardStub* clipboard_stub_;
111 AudioStub* audio_stub_;
113 SignalStrategy* signal_strategy_;
114 scoped_ptr<SessionManager> session_manager_;
115 scoped_ptr<Session> session_;
116 scoped_ptr<MonitoredVideoStub> monitored_video_stub_;
118 scoped_ptr<ClientVideoDispatcher> video_dispatcher_;
119 scoped_ptr<AudioReader> audio_reader_;
120 scoped_ptr<ClientControlDispatcher> control_dispatcher_;
121 scoped_ptr<ClientEventDispatcher> event_dispatcher_;
122 ClipboardFilter clipboard_forwarder_;
123 InputFilter event_forwarder_;
125 // Internal state of the connection.
126 State state_;
127 ErrorCode error_;
129 private:
130 DISALLOW_COPY_AND_ASSIGN(ConnectionToHostImpl);
133 } // namespace protocol
134 } // namespace remoting
136 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_IMPL_H_