diff options
author | agayev@chromium.org <agayev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-18 21:47:35 +0000 |
---|---|---|
committer | agayev@chromium.org <agayev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-18 21:47:35 +0000 |
commit | eaf10dc5d0fd4d093bb92445207dc9e0679222c7 (patch) | |
tree | 0d9235fab4b03b1098f7f6a18928b85c059b7a91 | |
parent | 8d779bd5a0776a415297e6068a1eed904e31dff9 (diff) | |
download | chromium_src-eaf10dc5d0fd4d093bb92445207dc9e0679222c7.zip chromium_src-eaf10dc5d0fd4d093bb92445207dc9e0679222c7.tar.gz chromium_src-eaf10dc5d0fd4d093bb92445207dc9e0679222c7.tar.bz2 |
DatagramSocket: added NetLog accessor.
BUG=60149
TEST=None
Review URL: http://codereview.chromium.org/7395033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92904 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/p2p/socket_host_udp_unittest.cc | 5 | ||||
-rw-r--r-- | net/socket/socket_test_util.cc | 10 | ||||
-rw-r--r-- | net/socket/socket_test_util.h | 5 | ||||
-rw-r--r-- | net/udp/datagram_socket.h | 4 | ||||
-rw-r--r-- | net/udp/udp_client_socket.cc | 4 | ||||
-rw-r--r-- | net/udp/udp_client_socket.h | 1 | ||||
-rw-r--r-- | net/udp/udp_server_socket.cc | 4 | ||||
-rw-r--r-- | net/udp/udp_server_socket.h | 1 | ||||
-rw-r--r-- | net/udp/udp_socket_libevent.h | 2 | ||||
-rw-r--r-- | net/udp/udp_socket_win.h | 2 |
10 files changed, 35 insertions, 3 deletions
diff --git a/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc b/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc index cd517b8..e40d288 100644 --- a/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc +++ b/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc @@ -95,10 +95,15 @@ class FakeDatagramServerSocket : public net::DatagramServerSocket { } } + virtual const net::BoundNetLog& NetLog() const { + return net_log_; + } + private: net::IPEndPoint address_; std::deque<UDPPacket>* sent_packets_; std::deque<UDPPacket> incoming_packets_; + net::BoundNetLog net_log_; scoped_refptr<net::IOBuffer> recv_buffer_; net::IPEndPoint* recv_address_; diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index c32d6bb..2a11ec0 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -594,7 +594,7 @@ DatagramClientSocket* MockClientSocketFactory::CreateDatagramClientSocket( NetLog* net_log, const NetLog::Source& source) { SocketDataProvider* data_provider = mock_data_.GetNext(); - MockUDPClientSocket* socket = new MockUDPClientSocket(data_provider); + MockUDPClientSocket* socket = new MockUDPClientSocket(data_provider, net_log); data_provider->set_socket(socket); udp_client_sockets_.push_back(socket); return socket; @@ -1162,7 +1162,8 @@ void MockSSLClientSocket::OnReadComplete(const MockRead& data) { NOTIMPLEMENTED(); } -MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data) +MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, + net::NetLog* net_log) : connected_(false), data_(data), read_offset_(0), @@ -1171,6 +1172,7 @@ MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data) pending_buf_(NULL), pending_buf_len_(0), pending_callback_(NULL), + net_log_(NetLog::Source(), net_log), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { DCHECK(data_); data_->Reset(); @@ -1245,6 +1247,10 @@ int MockUDPClientSocket::GetLocalAddress(IPEndPoint* address) const { return OK; } +const BoundNetLog& MockUDPClientSocket::NetLog() const { + return net_log_; +} + int MockUDPClientSocket::Connect(const IPEndPoint& address) { connected_ = true; return OK; diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index 3de7c75..ae4014c 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -768,7 +768,7 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket { class MockUDPClientSocket : public DatagramClientSocket, public AsyncSocket { public: - explicit MockUDPClientSocket(SocketDataProvider* data); + MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log); virtual ~MockUDPClientSocket(); // Socket interface @@ -783,6 +783,7 @@ class MockUDPClientSocket : public DatagramClientSocket, virtual void Close(); virtual int GetPeerAddress(IPEndPoint* address) const; virtual int GetLocalAddress(IPEndPoint* address) const; + virtual const BoundNetLog& NetLog() const; // DatagramClientSocket interface virtual int Connect(const IPEndPoint& address); @@ -807,6 +808,8 @@ class MockUDPClientSocket : public DatagramClientSocket, int pending_buf_len_; net::CompletionCallback* pending_callback_; + BoundNetLog net_log_; + ScopedRunnableMethodFactory<MockUDPClientSocket> method_factory_; DISALLOW_COPY_AND_ASSIGN(MockUDPClientSocket); diff --git a/net/udp/datagram_socket.h b/net/udp/datagram_socket.h index 65bc5d6..514df6e 100644 --- a/net/udp/datagram_socket.h +++ b/net/udp/datagram_socket.h @@ -10,6 +10,7 @@ namespace net { +class BoundNetLog; class IPEndPoint; // A datagram socket is an interface to a protocol which exchanges @@ -33,6 +34,9 @@ class NET_TEST DatagramSocket { // Copy the local udp address into |address| and return a network error code. // (similar to getsockname) virtual int GetLocalAddress(IPEndPoint* address) const = 0; + + // Gets the NetLog for this socket. + virtual const BoundNetLog& NetLog() const = 0; }; } // namespace net diff --git a/net/udp/udp_client_socket.cc b/net/udp/udp_client_socket.cc index 8df1fca..32fc50b 100644 --- a/net/udp/udp_client_socket.cc +++ b/net/udp/udp_client_socket.cc @@ -54,4 +54,8 @@ bool UDPClientSocket::SetSendBufferSize(int32 size) { return true; } +const BoundNetLog& UDPClientSocket::NetLog() const { + return socket_.NetLog(); +} + } // namespace net diff --git a/net/udp/udp_client_socket.h b/net/udp/udp_client_socket.h index b26393c..64b17dca 100644 --- a/net/udp/udp_client_socket.h +++ b/net/udp/udp_client_socket.h @@ -33,6 +33,7 @@ class NET_TEST UDPClientSocket : public DatagramClientSocket { virtual int GetLocalAddress(IPEndPoint* address) const; virtual bool SetReceiveBufferSize(int32 size); virtual bool SetSendBufferSize(int32 size); + virtual const BoundNetLog& NetLog() const; private: UDPSocket socket_; diff --git a/net/udp/udp_server_socket.cc b/net/udp/udp_server_socket.cc index 31df603..80b831f 100644 --- a/net/udp/udp_server_socket.cc +++ b/net/udp/udp_server_socket.cc @@ -49,4 +49,8 @@ int UDPServerSocket::GetLocalAddress(IPEndPoint* address) const { return socket_.GetLocalAddress(address); } +const BoundNetLog& UDPServerSocket::NetLog() const { + return socket_.NetLog(); +} + } // namespace net diff --git a/net/udp/udp_server_socket.h b/net/udp/udp_server_socket.h index 300899e..643949e 100644 --- a/net/udp/udp_server_socket.h +++ b/net/udp/udp_server_socket.h @@ -35,6 +35,7 @@ class NET_API UDPServerSocket : public DatagramServerSocket { virtual void Close(); virtual int GetPeerAddress(IPEndPoint* address) const; virtual int GetLocalAddress(IPEndPoint* address) const; + virtual const BoundNetLog& NetLog() const; private: UDPSocket socket_; diff --git a/net/udp/udp_socket_libevent.h b/net/udp/udp_socket_libevent.h index 6efaf49..a078150 100644 --- a/net/udp/udp_socket_libevent.h +++ b/net/udp/udp_socket_libevent.h @@ -97,6 +97,8 @@ class UDPSocketLibevent : public base::NonThreadSafe { // Returns true if the socket is already connected or bound. bool is_connected() const { return socket_ != kInvalidSocket; } + const BoundNetLog& NetLog() const { return net_log_; } + private: static const int kInvalidSocket = -1; diff --git a/net/udp/udp_socket_win.h b/net/udp/udp_socket_win.h index 01d5855..2dc818a 100644 --- a/net/udp/udp_socket_win.h +++ b/net/udp/udp_socket_win.h @@ -99,6 +99,8 @@ class UDPSocketWin : public base::NonThreadSafe { // Returns true if the socket is already connected or bound. bool is_connected() const { return socket_ != INVALID_SOCKET; } + const BoundNetLog& NetLog() const { return net_log_; } + private: class ReadDelegate : public base::win::ObjectWatcher::Delegate { public: |