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

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

Issue 9567033: Cleanup error handling in the client plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 9 months 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) 2012 The Chromium Authors. All rights reserved. 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 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/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "remoting/jingle_glue/signal_strategy.h" 13 #include "remoting/jingle_glue/signal_strategy.h"
14 #include "remoting/proto/internal.pb.h" 14 #include "remoting/proto/internal.pb.h"
15 #include "remoting/protocol/errors.h"
15 #include "remoting/protocol/input_filter.h" 16 #include "remoting/protocol/input_filter.h"
16 #include "remoting/protocol/message_reader.h" 17 #include "remoting/protocol/message_reader.h"
17 #include "remoting/protocol/session.h" 18 #include "remoting/protocol/session.h"
18 #include "remoting/protocol/session_manager.h" 19 #include "remoting/protocol/session_manager.h"
19 20
20 namespace base { 21 namespace base {
21 class MessageLoopProxy; 22 class MessageLoopProxy;
22 } // namespace base 23 } // namespace base
23 24
24 namespace pp { 25 namespace pp {
(...skipping 20 matching lines...) Expand all
45 class ConnectionToHost : public SignalStrategy::Listener, 46 class ConnectionToHost : public SignalStrategy::Listener,
46 public SessionManager::Listener { 47 public SessionManager::Listener {
47 public: 48 public:
48 enum State { 49 enum State {
49 CONNECTING, 50 CONNECTING,
50 CONNECTED, 51 CONNECTED,
51 FAILED, 52 FAILED,
52 CLOSED, 53 CLOSED,
53 }; 54 };
54 55
55 enum Error {
56 OK,
57 HOST_IS_OFFLINE,
58 SESSION_REJECTED,
59 INCOMPATIBLE_PROTOCOL,
60 NETWORK_FAILURE,
61 };
62
63 class HostEventCallback { 56 class HostEventCallback {
64 public: 57 public:
65 virtual ~HostEventCallback() {} 58 virtual ~HostEventCallback() {}
66 59
67 // Called when state of the connection changes. 60 // Called when state of the connection changes.
68 virtual void OnConnectionState(State state, Error error) = 0; 61 virtual void OnConnectionState(State state, ErrorCode error) = 0;
69 }; 62 };
70 63
71 ConnectionToHost(base::MessageLoopProxy* message_loop, 64 ConnectionToHost(base::MessageLoopProxy* message_loop,
72 pp::Instance* pp_instance, 65 pp::Instance* pp_instance,
73 bool allow_nat_traversal); 66 bool allow_nat_traversal);
74 virtual ~ConnectionToHost(); 67 virtual ~ConnectionToHost();
75 68
76 virtual void Connect(scoped_refptr<XmppProxy> xmpp_proxy, 69 virtual void Connect(scoped_refptr<XmppProxy> xmpp_proxy,
77 const std::string& local_jid, 70 const std::string& local_jid,
78 const std::string& host_jid, 71 const std::string& host_jid,
(...skipping 30 matching lines...) Expand all
109 void OnSessionStateChange(Session::State state); 102 void OnSessionStateChange(Session::State state);
110 103
111 // Callbacks for channel initialization 104 // Callbacks for channel initialization
112 void OnChannelInitialized(bool successful); 105 void OnChannelInitialized(bool successful);
113 106
114 void NotifyIfChannelsReady(); 107 void NotifyIfChannelsReady();
115 108
116 // Callback for |video_reader_|. 109 // Callback for |video_reader_|.
117 void OnVideoPacket(VideoPacket* packet); 110 void OnVideoPacket(VideoPacket* packet);
118 111
119 void CloseOnError(Error error); 112 void CloseOnError(ErrorCode error);
120 113
121 // Stops writing in the channels. 114 // Stops writing in the channels.
122 void CloseChannels(); 115 void CloseChannels();
123 116
124 void SetState(State state, Error error); 117 void SetState(State state, ErrorCode error);
125 118
126 scoped_refptr<base::MessageLoopProxy> message_loop_; 119 scoped_refptr<base::MessageLoopProxy> message_loop_;
127 pp::Instance* pp_instance_; 120 pp::Instance* pp_instance_;
128 bool allow_nat_traversal_; 121 bool allow_nat_traversal_;
129 122
130 std::string host_jid_; 123 std::string host_jid_;
131 std::string host_public_key_; 124 std::string host_public_key_;
132 scoped_ptr<Authenticator> authenticator_; 125 scoped_ptr<Authenticator> authenticator_;
133 126
134 HostEventCallback* event_callback_; 127 HostEventCallback* event_callback_;
135 128
136 // Stub for incoming messages. 129 // Stub for incoming messages.
137 ClientStub* client_stub_; 130 ClientStub* client_stub_;
138 VideoStub* video_stub_; 131 VideoStub* video_stub_;
139 132
140 scoped_ptr<SignalStrategy> signal_strategy_; 133 scoped_ptr<SignalStrategy> signal_strategy_;
141 scoped_ptr<SessionManager> session_manager_; 134 scoped_ptr<SessionManager> session_manager_;
142 scoped_ptr<Session> session_; 135 scoped_ptr<Session> session_;
143 136
144 scoped_ptr<VideoReader> video_reader_; 137 scoped_ptr<VideoReader> video_reader_;
145 scoped_ptr<ClientControlDispatcher> control_dispatcher_; 138 scoped_ptr<ClientControlDispatcher> control_dispatcher_;
146 scoped_ptr<ClientEventDispatcher> event_dispatcher_; 139 scoped_ptr<ClientEventDispatcher> event_dispatcher_;
147 InputFilter event_forwarder_; 140 InputFilter event_forwarder_;
148 141
149 // Internal state of the connection. 142 // Internal state of the connection.
150 State state_; 143 State state_;
151 Error error_; 144 ErrorCode error_;
152 145
153 private: 146 private:
154 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost); 147 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost);
155 }; 148 };
156 149
157 } // namespace protocol 150 } // namespace protocol
158 } // namespace remoting 151 } // namespace remoting
159 152
160 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ 153 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_
OLDNEW
« no previous file with comments | « remoting/protocol/connection_to_client_unittest.cc ('k') | remoting/protocol/connection_to_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698