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

Side by Side Diff: remoting/protocol/connection_to_host.h

Issue 9005034: Refactor SignalStrategy so that it can be reused for multiple connections. (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 #ifndef REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ 5 #ifndef REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_
6 #define REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ 6 #define REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 22 matching lines...) Expand all
33 33
34 class ClientControlDispatcher; 34 class ClientControlDispatcher;
35 class ClientEventDispatcher; 35 class ClientEventDispatcher;
36 class ClientStub; 36 class ClientStub;
37 class HostStub; 37 class HostStub;
38 class InputStub; 38 class InputStub;
39 class SessionConfig; 39 class SessionConfig;
40 class VideoReader; 40 class VideoReader;
41 class VideoStub; 41 class VideoStub;
42 42
43 class ConnectionToHost : public SignalStrategy::StatusObserver, 43 class ConnectionToHost : public SignalStrategy::Listener,
44 public SessionManager::Listener { 44 public SessionManager::Listener {
45 public: 45 public:
46 enum State { 46 enum State {
47 CONNECTING, 47 CONNECTING,
48 CONNECTED, 48 CONNECTED,
49 FAILED, 49 FAILED,
50 CLOSED, 50 CLOSED,
51 }; 51 };
52 52
53 enum Error { 53 enum Error {
(...skipping 28 matching lines...) Expand all
82 82
83 virtual void Disconnect(const base::Closure& shutdown_task); 83 virtual void Disconnect(const base::Closure& shutdown_task);
84 84
85 virtual const SessionConfig& config(); 85 virtual const SessionConfig& config();
86 86
87 virtual InputStub* input_stub(); 87 virtual InputStub* input_stub();
88 88
89 virtual HostStub* host_stub(); 89 virtual HostStub* host_stub();
90 90
91 // SignalStrategy::StatusObserver interface. 91 // SignalStrategy::StatusObserver interface.
92 virtual void OnStateChange( 92 virtual void OnSignalStrategyStateChange(
93 SignalStrategy::StatusObserver::State state) OVERRIDE; 93 SignalStrategy::State state) OVERRIDE;
94 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; 94 virtual bool OnSignalStrategyIncomingStanza(
95 const buzz::XmlElement* stanza) OVERRIDE;
95 96
96 // SessionManager::Listener interface. 97 // SessionManager::Listener interface.
97 virtual void OnSessionManagerInitialized() OVERRIDE; 98 virtual void OnSessionManagerReady() OVERRIDE;
98 virtual void OnIncomingSession( 99 virtual void OnIncomingSession(
99 Session* session, 100 Session* session,
100 SessionManager::IncomingSessionResponse* response) OVERRIDE; 101 SessionManager::IncomingSessionResponse* response) OVERRIDE;
101 102
102 // Called when the host accepts the client authentication. 103 // Called when the host accepts the client authentication.
103 void OnClientAuthenticated(); 104 void OnClientAuthenticated();
104 105
105 // Return the current state of ConnectionToHost. 106 // Return the current state of ConnectionToHost.
106 State state() const; 107 State state() const;
107 108
108 private: 109 private:
109 // Called on the jingle thread after we've successfully to XMPP server. Starts
110 // P2P connection to the host.
111 void InitSession();
112
113 // Callback for |session_|. 110 // Callback for |session_|.
114 void OnSessionStateChange(Session::State state); 111 void OnSessionStateChange(Session::State state);
115 112
116 // Callbacks for channel initialization 113 // Callbacks for channel initialization
117 void OnChannelInitialized(bool successful); 114 void OnChannelInitialized(bool successful);
118 115
119 void NotifyIfChannelsReady(); 116 void NotifyIfChannelsReady();
120 117
121 // Callback for |video_reader_|. 118 // Callback for |video_reader_|.
122 void OnVideoPacket(VideoPacket* packet); 119 void OnVideoPacket(VideoPacket* packet);
(...skipping 13 matching lines...) Expand all
136 std::string host_public_key_; 133 std::string host_public_key_;
137 std::string access_code_; 134 std::string access_code_;
138 135
139 HostEventCallback* event_callback_; 136 HostEventCallback* event_callback_;
140 137
141 // Stub for incoming messages. 138 // Stub for incoming messages.
142 ClientStub* client_stub_; 139 ClientStub* client_stub_;
143 VideoStub* video_stub_; 140 VideoStub* video_stub_;
144 141
145 scoped_ptr<SignalStrategy> signal_strategy_; 142 scoped_ptr<SignalStrategy> signal_strategy_;
146 std::string local_jid_;
147 scoped_ptr<SessionManager> session_manager_; 143 scoped_ptr<SessionManager> session_manager_;
148 scoped_ptr<Session> session_; 144 scoped_ptr<Session> session_;
149 145
150 scoped_ptr<VideoReader> video_reader_; 146 scoped_ptr<VideoReader> video_reader_;
151 scoped_ptr<ClientControlDispatcher> control_dispatcher_; 147 scoped_ptr<ClientControlDispatcher> control_dispatcher_;
152 scoped_ptr<ClientEventDispatcher> event_dispatcher_; 148 scoped_ptr<ClientEventDispatcher> event_dispatcher_;
153 149
154 // Internal state of the connection. 150 // Internal state of the connection.
155 State state_; 151 State state_;
156 Error error_; 152 Error error_;
157 153
158 private: 154 private:
159 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost); 155 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost);
160 }; 156 };
161 157
162 } // namespace protocol 158 } // namespace protocol
163 } // namespace remoting 159 } // namespace remoting
164 160
165 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ 161 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698