1 // Copyright 2013 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 PPAPI_SHARED_IMPL_PPB_TCP_SOCKET_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_TCP_SOCKET_SHARED_H_
8 #include "ppapi/shared_impl/ppapi_shared_export.h"
12 class PPAPI_SHARED_EXPORT TCPSocketState
{
15 // The socket hasn't been bound or connected.
17 // The socket has been bound.
19 // A connection has been established.
21 // An SSL connection has been established.
23 // The socket is listening.
25 // The socket has been closed.
29 // Transitions that will change the socket state. Please note that
30 // read/write/accept are not included because they don't change the socket
32 enum TransitionType
{ NONE
, BIND
, CONNECT
, SSL_CONNECT
, LISTEN
, CLOSE
};
34 explicit TCPSocketState(StateType state
);
37 StateType
state() const { return state_
; }
39 void SetPendingTransition(TransitionType pending_transition
);
40 void CompletePendingTransition(bool success
);
42 void DoTransition(TransitionType transition
, bool success
);
44 bool IsValidTransition(TransitionType transition
) const;
45 bool IsPending(TransitionType transition
) const;
47 bool IsConnected() const;
52 TransitionType pending_transition_
;
55 // TCP socket API versions.
56 enum TCPSocketVersion
{
57 // PPB_TCPSocket_Private.
58 TCP_SOCKET_VERSION_PRIVATE
,
59 // PPB_TCPSocket v1.0.
60 TCP_SOCKET_VERSION_1_0
,
61 // PPB_TCPSocket v1.1 or above.
62 TCP_SOCKET_VERSION_1_1_OR_ABOVE
67 #endif // PPAPI_SHARED_IMPL_PPB_TCP_SOCKET_SHARED_H_