Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // An implementation of buzz::AsyncSocket that uses Chrome sockets. | 5 // An implementation of buzz::AsyncSocket that uses Chrome sockets. |
| 6 | 6 |
| 7 #ifndef JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ | 7 #ifndef JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ |
| 8 #define JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ | 8 #define JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ |
| 9 | 9 |
| 10 #if !defined(FEATURE_ENABLE_SSL) | 10 #if !defined(FEATURE_ENABLE_SSL) |
| 11 #error ChromeAsyncSocket expects FEATURE_ENABLE_SSL to be defined | 11 #error ChromeAsyncSocket expects FEATURE_ENABLE_SSL to be defined |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/ref_counted.h" | 18 #include "base/ref_counted.h" |
| 19 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
| 20 #include "base/task.h" | 20 #include "base/task.h" |
| 21 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
| 22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 23 #include "net/base/net_log.h" | 23 #include "net/base/net_log.h" |
| 24 #include "net/base/ssl_config_service.h" | 24 #include "net/base/ssl_config_service.h" |
| 25 #include "talk/xmpp/asyncsocket.h" | 25 #include "talk/xmpp/asyncsocket.h" |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 class CertVerifier; | |
| 28 class ClientSocket; | 29 class ClientSocket; |
| 29 class ClientSocketFactory; | 30 class ClientSocketFactory; |
| 30 class IOBufferWithSize; | 31 class IOBufferWithSize; |
| 31 } // namespace net | 32 } // namespace net |
| 32 | 33 |
| 33 namespace notifier { | 34 namespace notifier { |
| 34 | 35 |
| 35 class ChromeAsyncSocket : public buzz::AsyncSocket { | 36 class ChromeAsyncSocket : public buzz::AsyncSocket { |
| 36 public: | 37 public: |
| 37 // Takes ownership of |client_socket_factory| but not |net_log|. | 38 // Takes ownership of |client_socket_factory| but not |cert_verifier| and |
| 38 // |net_log| may be NULL. | 39 // |net_log|. |cert_verifier| may not be NULL. |net_log| may be NULL. |
| 39 ChromeAsyncSocket(net::ClientSocketFactory* client_socket_factory, | 40 ChromeAsyncSocket(net::ClientSocketFactory* client_socket_factory, |
|
akalin
2010/12/17 06:36:08
You'll need to change the constructor call in the
| |
| 40 const net::SSLConfig& ssl_config, | 41 const net::SSLConfig& ssl_config, |
| 42 net::CertVerifier *cert_verifier, | |
|
akalin
2010/12/17 06:36:08
'Verifier *' -> "Verifier* '
| |
| 41 size_t read_buf_size, | 43 size_t read_buf_size, |
| 42 size_t write_buf_size, | 44 size_t write_buf_size, |
| 43 net::NetLog* net_log); | 45 net::NetLog* net_log); |
| 44 | 46 |
| 45 // Does not raise any signals. | 47 // Does not raise any signals. |
| 46 virtual ~ChromeAsyncSocket(); | 48 virtual ~ChromeAsyncSocket(); |
| 47 | 49 |
| 48 // buzz::AsyncSocket implementation. | 50 // buzz::AsyncSocket implementation. |
| 49 | 51 |
| 50 // The current state (see buzz::AsyncSocket::State; all but | 52 // The current state (see buzz::AsyncSocket::State; all but |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 void DoClose(); | 182 void DoClose(); |
| 181 | 183 |
| 182 // Callbacks passed to |transport_socket_|. | 184 // Callbacks passed to |transport_socket_|. |
| 183 net::CompletionCallbackImpl<ChromeAsyncSocket> connect_callback_; | 185 net::CompletionCallbackImpl<ChromeAsyncSocket> connect_callback_; |
| 184 net::CompletionCallbackImpl<ChromeAsyncSocket> read_callback_; | 186 net::CompletionCallbackImpl<ChromeAsyncSocket> read_callback_; |
| 185 net::CompletionCallbackImpl<ChromeAsyncSocket> write_callback_; | 187 net::CompletionCallbackImpl<ChromeAsyncSocket> write_callback_; |
| 186 net::CompletionCallbackImpl<ChromeAsyncSocket> ssl_connect_callback_; | 188 net::CompletionCallbackImpl<ChromeAsyncSocket> ssl_connect_callback_; |
| 187 | 189 |
| 188 scoped_ptr<net::ClientSocketFactory> client_socket_factory_; | 190 scoped_ptr<net::ClientSocketFactory> client_socket_factory_; |
| 189 const net::SSLConfig ssl_config_; | 191 const net::SSLConfig ssl_config_; |
| 192 net::CertVerifier* cert_verifier_; | |
| 190 net::BoundNetLog bound_net_log_; | 193 net::BoundNetLog bound_net_log_; |
| 191 | 194 |
| 192 // buzz::AsyncSocket state. | 195 // buzz::AsyncSocket state. |
| 193 buzz::AsyncSocket::State state_; | 196 buzz::AsyncSocket::State state_; |
| 194 buzz::AsyncSocket::Error error_; | 197 buzz::AsyncSocket::Error error_; |
| 195 net::Error net_error_; | 198 net::Error net_error_; |
| 196 | 199 |
| 197 // Used by read/write loops. | 200 // Used by read/write loops. |
| 198 ScopedRunnableMethodFactory<ChromeAsyncSocket> | 201 ScopedRunnableMethodFactory<ChromeAsyncSocket> |
| 199 scoped_runnable_method_factory_; | 202 scoped_runnable_method_factory_; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 216 AsyncIOState write_state_; | 219 AsyncIOState write_state_; |
| 217 scoped_refptr<net::IOBufferWithSize> write_buf_; | 220 scoped_refptr<net::IOBufferWithSize> write_buf_; |
| 218 size_t write_end_; | 221 size_t write_end_; |
| 219 | 222 |
| 220 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocket); | 223 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocket); |
| 221 }; | 224 }; |
| 222 | 225 |
| 223 } // namespace notifier | 226 } // namespace notifier |
| 224 | 227 |
| 225 #endif // JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ | 228 #endif // JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ |
| OLD | NEW |