OLD | NEW |
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 // 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/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/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" | |
24 #include "talk/xmpp/asyncsocket.h" | 23 #include "talk/xmpp/asyncsocket.h" |
25 | 24 |
26 namespace net { | 25 namespace net { |
27 class IOBufferWithSize; | 26 class IOBufferWithSize; |
28 class StreamSocket; | 27 class StreamSocket; |
29 } // namespace net | 28 } // namespace net |
30 | 29 |
31 namespace notifier { | 30 namespace notifier { |
32 | 31 |
33 class ResolvingClientSocketFactory; | 32 class ResolvingClientSocketFactory; |
34 | 33 |
35 class ChromeAsyncSocket : public buzz::AsyncSocket { | 34 class ChromeAsyncSocket : public buzz::AsyncSocket { |
36 public: | 35 public: |
37 // Takes ownership of |client_socket_factory| but not |net_log|. | 36 // Takes ownership of |client_socket_factory|. |
38 // |net_log| may be NULL. | |
39 ChromeAsyncSocket(ResolvingClientSocketFactory* client_socket_factory, | 37 ChromeAsyncSocket(ResolvingClientSocketFactory* client_socket_factory, |
40 size_t read_buf_size, | 38 size_t read_buf_size, |
41 size_t write_buf_size, | 39 size_t write_buf_size); |
42 net::NetLog* net_log); | |
43 | 40 |
44 // Does not raise any signals. | 41 // Does not raise any signals. |
45 virtual ~ChromeAsyncSocket(); | 42 virtual ~ChromeAsyncSocket(); |
46 | 43 |
47 // buzz::AsyncSocket implementation. | 44 // buzz::AsyncSocket implementation. |
48 | 45 |
49 // The current state (see buzz::AsyncSocket::State; all but | 46 // The current state (see buzz::AsyncSocket::State; all but |
50 // STATE_CLOSING is used). | 47 // STATE_CLOSING is used). |
51 virtual State state(); | 48 virtual State state(); |
52 | 49 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // Close functions. | 175 // Close functions. |
179 void DoClose(); | 176 void DoClose(); |
180 | 177 |
181 // Callbacks passed to |transport_socket_|. | 178 // Callbacks passed to |transport_socket_|. |
182 net::CompletionCallbackImpl<ChromeAsyncSocket> connect_callback_; | 179 net::CompletionCallbackImpl<ChromeAsyncSocket> connect_callback_; |
183 net::CompletionCallbackImpl<ChromeAsyncSocket> read_callback_; | 180 net::CompletionCallbackImpl<ChromeAsyncSocket> read_callback_; |
184 net::CompletionCallbackImpl<ChromeAsyncSocket> write_callback_; | 181 net::CompletionCallbackImpl<ChromeAsyncSocket> write_callback_; |
185 net::CompletionCallbackImpl<ChromeAsyncSocket> ssl_connect_callback_; | 182 net::CompletionCallbackImpl<ChromeAsyncSocket> ssl_connect_callback_; |
186 | 183 |
187 scoped_ptr<ResolvingClientSocketFactory> client_socket_factory_; | 184 scoped_ptr<ResolvingClientSocketFactory> client_socket_factory_; |
188 net::BoundNetLog bound_net_log_; | |
189 | 185 |
190 // buzz::AsyncSocket state. | 186 // buzz::AsyncSocket state. |
191 buzz::AsyncSocket::State state_; | 187 buzz::AsyncSocket::State state_; |
192 buzz::AsyncSocket::Error error_; | 188 buzz::AsyncSocket::Error error_; |
193 net::Error net_error_; | 189 net::Error net_error_; |
194 | 190 |
195 // Used by read/write loops. | 191 // Used by read/write loops. |
196 ScopedRunnableMethodFactory<ChromeAsyncSocket> | 192 ScopedRunnableMethodFactory<ChromeAsyncSocket> |
197 scoped_runnable_method_factory_; | 193 scoped_runnable_method_factory_; |
198 | 194 |
(...skipping 15 matching lines...) Expand all Loading... |
214 AsyncIOState write_state_; | 210 AsyncIOState write_state_; |
215 scoped_refptr<net::IOBufferWithSize> write_buf_; | 211 scoped_refptr<net::IOBufferWithSize> write_buf_; |
216 size_t write_end_; | 212 size_t write_end_; |
217 | 213 |
218 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocket); | 214 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocket); |
219 }; | 215 }; |
220 | 216 |
221 } // namespace notifier | 217 } // namespace notifier |
222 | 218 |
223 #endif // JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ | 219 #endif // JINGLE_NOTIFIER_BASE_CHROME_ASYNC_SOCKET_H_ |
OLD | NEW |