OLD | NEW |
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 PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ |
6 #define PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 virtual PP_Resource GetServerCertificate() OVERRIDE; | 59 virtual PP_Resource GetServerCertificate() OVERRIDE; |
60 virtual PP_Bool AddChainBuildingCertificate(PP_Resource certificate, | 60 virtual PP_Bool AddChainBuildingCertificate(PP_Resource certificate, |
61 PP_Bool trusted) OVERRIDE; | 61 PP_Bool trusted) OVERRIDE; |
62 virtual int32_t Read(char* buffer, | 62 virtual int32_t Read(char* buffer, |
63 int32_t bytes_to_read, | 63 int32_t bytes_to_read, |
64 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 64 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
65 virtual int32_t Write(const char* buffer, | 65 virtual int32_t Write(const char* buffer, |
66 int32_t bytes_to_write, | 66 int32_t bytes_to_write, |
67 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 67 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
68 virtual void Disconnect() OVERRIDE; | 68 virtual void Disconnect() OVERRIDE; |
| 69 virtual int32_t SetOption(PP_TCPSocketOption_Private name, |
| 70 const PP_Var& value, |
| 71 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
69 | 72 |
70 // Notifications on operations completion. | 73 // Notifications on operations completion. |
71 void OnConnectCompleted(bool succeeded, | 74 void OnConnectCompleted(bool succeeded, |
72 const PP_NetAddress_Private& local_addr, | 75 const PP_NetAddress_Private& local_addr, |
73 const PP_NetAddress_Private& remote_addr); | 76 const PP_NetAddress_Private& remote_addr); |
74 void OnSSLHandshakeCompleted( | 77 void OnSSLHandshakeCompleted( |
75 bool succeeded, | 78 bool succeeded, |
76 const PPB_X509Certificate_Fields& certificate_fields); | 79 const PPB_X509Certificate_Fields& certificate_fields); |
77 void OnReadCompleted(bool succeeded, const std::string& data); | 80 void OnReadCompleted(bool succeeded, const std::string& data); |
78 void OnWriteCompleted(bool succeeded, int32_t bytes_written); | 81 void OnWriteCompleted(bool succeeded, int32_t bytes_written); |
| 82 void OnSetOptionCompleted(bool succeeded); |
79 | 83 |
80 // Send functions that need to be implemented differently for the | 84 // Send functions that need to be implemented differently for the |
81 // proxied and non-proxied derived classes. | 85 // proxied and non-proxied derived classes. |
82 virtual void SendConnect(const std::string& host, uint16_t port) = 0; | 86 virtual void SendConnect(const std::string& host, uint16_t port) = 0; |
83 virtual void SendConnectWithNetAddress(const PP_NetAddress_Private& addr) = 0; | 87 virtual void SendConnectWithNetAddress(const PP_NetAddress_Private& addr) = 0; |
84 virtual void SendSSLHandshake( | 88 virtual void SendSSLHandshake( |
85 const std::string& server_name, | 89 const std::string& server_name, |
86 uint16_t server_port, | 90 uint16_t server_port, |
87 const std::vector<std::vector<char> >& trusted_certs, | 91 const std::vector<std::vector<char> >& trusted_certs, |
88 const std::vector<std::vector<char> >& untrusted_certs) = 0; | 92 const std::vector<std::vector<char> >& untrusted_certs) = 0; |
89 virtual void SendRead(int32_t bytes_to_read) = 0; | 93 virtual void SendRead(int32_t bytes_to_read) = 0; |
90 virtual void SendWrite(const std::string& buffer) = 0; | 94 virtual void SendWrite(const std::string& buffer) = 0; |
91 virtual void SendDisconnect() = 0; | 95 virtual void SendDisconnect() = 0; |
| 96 virtual void SendSetBoolOption(PP_TCPSocketOption_Private name, |
| 97 bool value) = 0; |
92 | 98 |
93 protected: | 99 protected: |
94 enum ConnectionState { | 100 enum ConnectionState { |
95 // Before a connection is successfully established (including a connect | 101 // Before a connection is successfully established (including a connect |
96 // request is pending or a previous connect request failed). | 102 // request is pending or a previous connect request failed). |
97 BEFORE_CONNECT, | 103 BEFORE_CONNECT, |
98 // A connection has been successfully established (including a request of | 104 // A connection has been successfully established (including a request of |
99 // initiating SSL is pending). | 105 // initiating SSL is pending). |
100 CONNECTED, | 106 CONNECTED, |
101 // An SSL connection has been successfully established. | 107 // An SSL connection has been successfully established. |
102 SSL_CONNECTED, | 108 SSL_CONNECTED, |
103 // The connection has been ended. | 109 // The connection has been ended. |
104 DISCONNECTED | 110 DISCONNECTED |
105 }; | 111 }; |
106 | 112 |
107 void Init(uint32 socket_id); | 113 void Init(uint32 socket_id); |
108 bool IsConnected() const; | 114 bool IsConnected() const; |
109 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); | 115 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); |
110 | 116 |
111 ResourceObjectType resource_type_; | 117 ResourceObjectType resource_type_; |
112 | 118 |
113 uint32 socket_id_; | 119 uint32 socket_id_; |
114 ConnectionState connection_state_; | 120 ConnectionState connection_state_; |
115 | 121 |
116 scoped_refptr<TrackedCallback> connect_callback_; | 122 scoped_refptr<TrackedCallback> connect_callback_; |
117 scoped_refptr<TrackedCallback> ssl_handshake_callback_; | 123 scoped_refptr<TrackedCallback> ssl_handshake_callback_; |
118 scoped_refptr<TrackedCallback> read_callback_; | 124 scoped_refptr<TrackedCallback> read_callback_; |
119 scoped_refptr<TrackedCallback> write_callback_; | 125 scoped_refptr<TrackedCallback> write_callback_; |
| 126 scoped_refptr<TrackedCallback> set_option_callback_; |
120 | 127 |
121 char* read_buffer_; | 128 char* read_buffer_; |
122 int32_t bytes_to_read_; | 129 int32_t bytes_to_read_; |
123 | 130 |
124 PP_NetAddress_Private local_addr_; | 131 PP_NetAddress_Private local_addr_; |
125 PP_NetAddress_Private remote_addr_; | 132 PP_NetAddress_Private remote_addr_; |
126 | 133 |
127 scoped_refptr<PPB_X509Certificate_Private_Shared> server_certificate_; | 134 scoped_refptr<PPB_X509Certificate_Private_Shared> server_certificate_; |
128 | 135 |
129 std::vector<std::vector<char> > trusted_certificates_; | 136 std::vector<std::vector<char> > trusted_certificates_; |
130 std::vector<std::vector<char> > untrusted_certificates_; | 137 std::vector<std::vector<char> > untrusted_certificates_; |
131 | 138 |
132 DISALLOW_COPY_AND_ASSIGN(TCPSocketPrivateImpl); | 139 DISALLOW_COPY_AND_ASSIGN(TCPSocketPrivateImpl); |
133 }; | 140 }; |
134 | 141 |
135 } // namespace ppapi | 142 } // namespace ppapi |
136 | 143 |
137 #endif // PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ | 144 #endif // PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ |
OLD | NEW |