Make castv2 performance test work.
[chromium-blink-merge.git] / ppapi / shared_impl / ppb_tcp_socket_shared.h
blob82286702bb33d8a086c18da097559bee627dacf9
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"
10 namespace ppapi {
12 class PPAPI_SHARED_EXPORT TCPSocketState {
13 public:
14 enum StateType {
15 // The socket hasn't been bound or connected.
16 INITIAL,
17 // The socket has been bound.
18 BOUND,
19 // A connection has been established.
20 CONNECTED,
21 // An SSL connection has been established.
22 SSL_CONNECTED,
23 // The socket is listening.
24 LISTENING,
25 // The socket has been closed.
26 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
31 // state.
32 enum TransitionType { NONE, BIND, CONNECT, SSL_CONNECT, LISTEN, CLOSE };
34 explicit TCPSocketState(StateType state);
35 ~TCPSocketState();
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;
48 bool IsBound() const;
50 private:
51 StateType state_;
52 TransitionType pending_transition_;
55 // TCP socket API versions.
56 enum PPAPI_SHARED_EXPORT 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
65 } // namespace ppapi
67 #endif // PPAPI_SHARED_IMPL_PPB_TCP_SOCKET_SHARED_H_