Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: net/socket/stream_socket.h

Issue 2623803002: Avoid creating MemoryAllocatorDump for individual sockets (Closed)
Patch Set: Address Eric's comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/ssl_client_socket_unittest.cc ('k') | net/socket/stream_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 NET_SOCKET_STREAM_SOCKET_H_ 5 #ifndef NET_SOCKET_STREAM_SOCKET_H_
6 #define NET_SOCKET_STREAM_SOCKET_H_ 6 #define NET_SOCKET_STREAM_SOCKET_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 #include "net/socket/connection_attempts.h" 12 #include "net/socket/connection_attempts.h"
13 #include "net/socket/next_proto.h" 13 #include "net/socket/next_proto.h"
14 #include "net/socket/socket.h" 14 #include "net/socket/socket.h"
15 15
16 namespace base {
17 namespace trace_event {
18 class ProcessMemoryDump;
19 }
20 }
21
22 namespace net { 16 namespace net {
23 17
24 class IPEndPoint; 18 class IPEndPoint;
25 class NetLogWithSource; 19 class NetLogWithSource;
26 class SSLInfo; 20 class SSLInfo;
27 21
28 class NET_EXPORT_PRIVATE StreamSocket : public Socket { 22 class NET_EXPORT_PRIVATE StreamSocket : public Socket {
29 public: 23 public:
24 // This is used in DumpMemoryStats() to track the estimate of memory usage of
25 // a socket.
26 struct NET_EXPORT_PRIVATE SocketMemoryStats {
27 public:
28 SocketMemoryStats();
29 ~SocketMemoryStats();
30 // Estimated total memory usage of this socket in bytes.
31 size_t total_size;
32 // Size of all buffers used by this socket in bytes.
33 size_t buffer_size;
34 // Number of certs used by this socket.
35 size_t cert_count;
36 // Total size of certs used by this socket in bytes.
37 size_t serialized_cert_size;
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(SocketMemoryStats);
41 };
42
30 ~StreamSocket() override {} 43 ~StreamSocket() override {}
31 44
32 // Called to establish a connection. Returns OK if the connection could be 45 // Called to establish a connection. Returns OK if the connection could be
33 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the 46 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the
34 // given callback will run asynchronously when the connection is established 47 // given callback will run asynchronously when the connection is established
35 // or when an error occurs. The result is some other error code if the 48 // or when an error occurs. The result is some other error code if the
36 // connection could not be established. 49 // connection could not be established.
37 // 50 //
38 // The socket's Read and Write methods may not be called until Connect 51 // The socket's Read and Write methods may not be called until Connect
39 // succeeds. 52 // succeeds.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 122
110 // Adds |attempts| to the socket's list of connection attempts. 123 // Adds |attempts| to the socket's list of connection attempts.
111 virtual void AddConnectionAttempts(const ConnectionAttempts& attempts) = 0; 124 virtual void AddConnectionAttempts(const ConnectionAttempts& attempts) = 0;
112 125
113 // Returns the total number of number bytes read by the socket. This only 126 // Returns the total number of number bytes read by the socket. This only
114 // counts the payload bytes. Transport headers are not counted. Returns 127 // counts the payload bytes. Transport headers are not counted. Returns
115 // 0 if the socket does not implement the function. The count is reset when 128 // 0 if the socket does not implement the function. The count is reset when
116 // Disconnect() is called. 129 // Disconnect() is called.
117 virtual int64_t GetTotalReceivedBytes() const = 0; 130 virtual int64_t GetTotalReceivedBytes() const = 0;
118 131
119 // Dumps memory allocation stats. |parent_dump_absolute_name| is the name 132 // Dumps memory allocation stats into |stats|. |stats| can be assumed as being
120 // used by the parent MemoryAllocatorDump in the memory dump hierarchy. 133 // default initialized upon entry. Implementations should override fields in
121 // Default implementation does nothing. 134 // |stats|. Default implementation does nothing.
122 virtual void DumpMemoryStats( 135 virtual void DumpMemoryStats(SocketMemoryStats* stats) const {}
123 base::trace_event::ProcessMemoryDump* pmd,
124 const std::string& parent_dump_absolute_name) const {};
125 136
126 protected: 137 protected:
127 // The following class is only used to gather statistics about the history of 138 // The following class is only used to gather statistics about the history of
128 // a socket. It is only instantiated and used in basic sockets, such as 139 // a socket. It is only instantiated and used in basic sockets, such as
129 // TCPClientSocket* instances. Other classes that are derived from 140 // TCPClientSocket* instances. Other classes that are derived from
130 // StreamSocket should forward any potential settings to their underlying 141 // StreamSocket should forward any potential settings to their underlying
131 // transport sockets. 142 // transport sockets.
132 class UseHistory { 143 class UseHistory {
133 public: 144 public:
134 UseHistory(); 145 UseHistory();
(...skipping 27 matching lines...) Expand all
162 // identify the motivation. 173 // identify the motivation.
163 bool omnibox_speculation_; 174 bool omnibox_speculation_;
164 bool subresource_speculation_; 175 bool subresource_speculation_;
165 DISALLOW_COPY_AND_ASSIGN(UseHistory); 176 DISALLOW_COPY_AND_ASSIGN(UseHistory);
166 }; 177 };
167 }; 178 };
168 179
169 } // namespace net 180 } // namespace net
170 181
171 #endif // NET_SOCKET_STREAM_SOCKET_H_ 182 #endif // NET_SOCKET_STREAM_SOCKET_H_
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_unittest.cc ('k') | net/socket/stream_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698