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

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

Issue 8046018: Parse termination reason and propagate the error to the Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 2 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
« no previous file with comments | « remoting/protocol/protocol_mock_objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SESSION_H_ 5 #ifndef REMOTING_PROTOCOL_SESSION_H_
6 #define REMOTING_PROTOCOL_SESSION_H_ 6 #define REMOTING_PROTOCOL_SESSION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // TODO(sergeyu): Remove this state. 42 // TODO(sergeyu): Remove this state.
43 CONNECTED_CHANNELS, 43 CONNECTED_CHANNELS,
44 44
45 // Session has been closed. 45 // Session has been closed.
46 CLOSED, 46 CLOSED,
47 47
48 // Connection has failed. 48 // Connection has failed.
49 FAILED, 49 FAILED,
50 }; 50 };
51 51
52 enum Error {
53 OK = 0,
54 PEER_IS_OFFLINE,
55 SESSION_REJECTED,
56 INCOMPATIBLE_PROTOCOL,
57 CHANNEL_CONNECTION_ERROR,
58 };
59
52 typedef Callback1<State>::Type StateChangeCallback; 60 typedef Callback1<State>::Type StateChangeCallback;
53 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; 61 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback;
54 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; 62 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback;
55 63
56 Session() { } 64 Session() { }
57 virtual ~Session() { } 65 virtual ~Session() { }
58 66
59 // Set callback that is called when state of the connection is changed. 67 // Set callback that is called when state of the connection is changed.
60 // Must be called on the jingle thread only. 68 // Must be called on the jingle thread only.
61 virtual void SetStateChangeCallback(StateChangeCallback* callback) = 0; 69 virtual void SetStateChangeCallback(StateChangeCallback* callback) = 0;
62 70
71 // Returns error code for a failed session.
72 virtual Error error() = 0;
73
63 // Creates new channels for this connection. The specified callback 74 // Creates new channels for this connection. The specified callback
64 // is called when then new channel is created and connected. The 75 // is called when then new channel is created and connected. The
65 // callback is called with NULL if connection failed for any reason. 76 // callback is called with NULL if connection failed for any reason.
66 // Ownership of the channel socket is given to the caller when the 77 // Ownership of the channel socket is given to the caller when the
67 // callback is called. All channels must be destroyed before the 78 // callback is called. All channels must be destroyed before the
68 // session is destroyed. Can be called only when in CONNECTING or 79 // session is destroyed. Can be called only when in CONNECTING or
69 // CONNECTED state. 80 // CONNECTED state.
70 virtual void CreateStreamChannel( 81 virtual void CreateStreamChannel(
71 const std::string& name, const StreamChannelCallback& callback) = 0; 82 const std::string& name, const StreamChannelCallback& callback) = 0;
72 virtual void CreateDatagramChannel( 83 virtual void CreateDatagramChannel(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 virtual void Close() = 0; 121 virtual void Close() = 0;
111 122
112 private: 123 private:
113 DISALLOW_COPY_AND_ASSIGN(Session); 124 DISALLOW_COPY_AND_ASSIGN(Session);
114 }; 125 };
115 126
116 } // namespace protocol 127 } // namespace protocol
117 } // namespace remoting 128 } // namespace remoting
118 129
119 #endif // REMOTING_PROTOCOL_SESSION_H_ 130 #endif // REMOTING_PROTOCOL_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/protocol_mock_objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698