Chromium Code Reviews

Side by Side Diff: chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h

Issue 1696005: Add net log entries that summarize transmit and receive byte counts. (Closed)
Patch Set: More tests and address comments Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ 5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_
6 #define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ 6 #define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_
7 7
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "net/base/completion_callback.h" 9 #include "net/base/completion_callback.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/net_log.h"
12 #include "net/socket/client_socket.h" 13 #include "net/socket/client_socket.h"
13 #include "net/socket/ssl_client_socket.h" 14 #include "net/socket/ssl_client_socket.h"
14 #include "talk/base/asyncsocket.h" 15 #include "talk/base/asyncsocket.h"
15 #include "talk/base/ssladapter.h" 16 #include "talk/base/ssladapter.h"
16 17
17 namespace net {
18 class BoundNetLog;
19 } // namespace net
20
21 namespace notifier { 18 namespace notifier {
22 19
23 class SSLSocketAdapter; 20 class SSLSocketAdapter;
24 21
25 // This class provides a wrapper to libjingle's talk_base::AsyncSocket that 22 // This class provides a wrapper to libjingle's talk_base::AsyncSocket that
26 // implements Chromium's net::ClientSocket interface. It's used by 23 // implements Chromium's net::ClientSocket interface. It's used by
27 // SSLSocketAdapter to enable Chromium's SSL implementation to work over 24 // SSLSocketAdapter to enable Chromium's SSL implementation to work over
28 // libjingle's socket class. 25 // libjingle's socket class.
29 class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> { 26 class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> {
30 public: 27 public:
31 TransportSocket(talk_base::AsyncSocket* socket, 28 TransportSocket(talk_base::AsyncSocket* socket,
32 SSLSocketAdapter *ssl_adapter); 29 SSLSocketAdapter *ssl_adapter);
33 30
34 void set_addr(const talk_base::SocketAddress& addr) { 31 void set_addr(const talk_base::SocketAddress& addr) {
35 addr_ = addr; 32 addr_ = addr;
36 } 33 }
37 34
38 // net::ClientSocket implementation 35 // net::ClientSocket implementation
39 36
40 virtual int Connect(net::CompletionCallback* callback, 37 virtual int Connect(net::CompletionCallback* callback);
41 const net::BoundNetLog& /* net_log */);
42 virtual void Disconnect(); 38 virtual void Disconnect();
43 virtual bool IsConnected() const; 39 virtual bool IsConnected() const;
44 virtual bool IsConnectedAndIdle() const; 40 virtual bool IsConnectedAndIdle() const;
45 virtual int GetPeerAddress(net::AddressList* address) const; 41 virtual int GetPeerAddress(net::AddressList* address) const;
42 virtual const net::BoundNetLog& NetLog() const { return net_log_; }
46 43
47 // net::Socket implementation 44 // net::Socket implementation
48 45
49 virtual int Read(net::IOBuffer* buf, int buf_len, 46 virtual int Read(net::IOBuffer* buf, int buf_len,
50 net::CompletionCallback* callback); 47 net::CompletionCallback* callback);
51 virtual int Write(net::IOBuffer* buf, int buf_len, 48 virtual int Write(net::IOBuffer* buf, int buf_len,
52 net::CompletionCallback* callback); 49 net::CompletionCallback* callback);
53 virtual bool SetReceiveBufferSize(int32 size); 50 virtual bool SetReceiveBufferSize(int32 size);
54 virtual bool SetSendBufferSize(int32 size); 51 virtual bool SetSendBufferSize(int32 size);
55 52
56 private: 53 private:
57 friend class SSLSocketAdapter; 54 friend class SSLSocketAdapter;
58 55
59 void OnConnectEvent(talk_base::AsyncSocket * socket); 56 void OnConnectEvent(talk_base::AsyncSocket * socket);
60 bool OnReadEvent(talk_base::AsyncSocket * socket); 57 bool OnReadEvent(talk_base::AsyncSocket * socket);
61 bool OnWriteEvent(talk_base::AsyncSocket * socket); 58 bool OnWriteEvent(talk_base::AsyncSocket * socket);
62 59
63 net::CompletionCallback* connect_callback_; 60 net::CompletionCallback* connect_callback_;
64 net::CompletionCallback* read_callback_; 61 net::CompletionCallback* read_callback_;
65 net::CompletionCallback* write_callback_; 62 net::CompletionCallback* write_callback_;
66 63
67 scoped_refptr<net::IOBuffer> read_buffer_; 64 scoped_refptr<net::IOBuffer> read_buffer_;
68 int read_buffer_len_; 65 int read_buffer_len_;
69 scoped_refptr<net::IOBuffer> write_buffer_; 66 scoped_refptr<net::IOBuffer> write_buffer_;
70 int write_buffer_len_; 67 int write_buffer_len_;
71 68
69 net::BoundNetLog net_log_;
70
72 talk_base::AsyncSocket *socket_; 71 talk_base::AsyncSocket *socket_;
73 talk_base::SocketAddress addr_; 72 talk_base::SocketAddress addr_;
74 73
75 DISALLOW_COPY_AND_ASSIGN(TransportSocket); 74 DISALLOW_COPY_AND_ASSIGN(TransportSocket);
76 }; 75 };
77 76
78 // This provides a talk_base::AsyncSocketAdapter interface around Chromium's 77 // This provides a talk_base::AsyncSocketAdapter interface around Chromium's
79 // net::SSLClientSocket class. This allows notifier to use Chromium's SSL 78 // net::SSLClientSocket class. This allows notifier to use Chromium's SSL
80 // implementation instead of OpenSSL. 79 // implementation instead of OpenSSL.
81 class SSLSocketAdapter : public talk_base::SSLAdapter { 80 class SSLSocketAdapter : public talk_base::SSLAdapter {
(...skipping 44 matching lines...)
126 State state_; 125 State state_;
127 scoped_refptr<net::IOBuffer> transport_buf_; 126 scoped_refptr<net::IOBuffer> transport_buf_;
128 int data_transferred_; 127 int data_transferred_;
129 128
130 DISALLOW_COPY_AND_ASSIGN(SSLSocketAdapter); 129 DISALLOW_COPY_AND_ASSIGN(SSLSocketAdapter);
131 }; 130 };
132 131
133 } // namespace notifier 132 } // namespace notifier
134 133
135 #endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ 134 #endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/view_net_internals_job_factory.cc ('k') | chrome/browser/sync/notifier/communicator/ssl_socket_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine