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

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

Issue 3050040: Reland 54771 (and 54795) To enable TCP Preconnection by default... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/net.gyp ('k') | net/socket/client_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) 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 #ifndef NET_SOCKET_CLIENT_SOCKET_H_ 5 #ifndef NET_SOCKET_CLIENT_SOCKET_H_
6 #define NET_SOCKET_CLIENT_SOCKET_H_ 6 #define NET_SOCKET_CLIENT_SOCKET_H_
7 #pragma once 7 #pragma once
8 8
9 #include "net/socket/socket.h" 9 #include "net/socket/socket.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 class AddressList; 13 class AddressList;
14 class BoundNetLog; 14 class BoundNetLog;
15 15
16 class ClientSocket : public Socket { 16 class ClientSocket : public Socket {
17 public: 17 public:
18 ClientSocket();
19
20 // Destructor emits statistics for this socket's lifetime.
21 virtual ~ClientSocket();
22
23 // Set the annotation to indicate this socket was created for speculative
24 // reasons. Note that if the socket was used before calling this method, then
25 // the call will be ignored (no annotation will be added).
26 void SetSubresourceSpeculation();
27 void SetOmniboxSpeculation();
28
29 // Establish values of was_ever_connected_ and was_used_to_transmit_data_.
30 // The argument indicates if the socket's state, as reported by a
31 // ClientSocketHandle::is_reused(), should show that the socket has already
32 // been used to transmit data.
33 // This is typically called when a transaction finishes, and
34 // ClientSocketHandle is being destroyed. Calling at that point it allows us
35 // to aggregates the impact of that connect job into this instance.
36 void UpdateConnectivityState(bool is_reused);
37
18 // Called to establish a connection. Returns OK if the connection could be 38 // Called to establish a connection. Returns OK if the connection could be
19 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the 39 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the
20 // given callback will run asynchronously when the connection is established 40 // given callback will run asynchronously when the connection is established
21 // or when an error occurs. The result is some other error code if the 41 // or when an error occurs. The result is some other error code if the
22 // connection could not be established. 42 // connection could not be established.
23 // 43 //
24 // The socket's Read and Write methods may not be called until Connect 44 // The socket's Read and Write methods may not be called until Connect
25 // succeeds. 45 // succeeds.
26 // 46 //
27 // It is valid to call Connect on an already connected socket, in which case 47 // It is valid to call Connect on an already connected socket, in which case
(...skipping 19 matching lines...) Expand all
47 // Called to test if the connection is still alive and idle. Returns false 67 // Called to test if the connection is still alive and idle. Returns false
48 // if a connection wasn't established, the connection is dead, or some data 68 // if a connection wasn't established, the connection is dead, or some data
49 // have been received. 69 // have been received.
50 virtual bool IsConnectedAndIdle() const = 0; 70 virtual bool IsConnectedAndIdle() const = 0;
51 71
52 // Copies the peer address to |address| and returns a network error code. 72 // Copies the peer address to |address| and returns a network error code.
53 virtual int GetPeerAddress(AddressList* address) const = 0; 73 virtual int GetPeerAddress(AddressList* address) const = 0;
54 74
55 // Gets the NetLog for this socket. 75 // Gets the NetLog for this socket.
56 virtual const BoundNetLog& NetLog() const = 0; 76 virtual const BoundNetLog& NetLog() const = 0;
77
78 private:
79 // Publish histogram to help evaluate preconnection utilization.
80 void EmitPreconnectionHistograms() const;
81
82 // Indicate if any ClientSocketHandle that used this socket was connected as
83 // would be indicated by the IsConnected() method. This variable set by a
84 // ClientSocketHandle before releasing this ClientSocket.
85 bool was_ever_connected_;
86
87 // Indicate if this socket was first created for speculative use, and identify
88 // the motivation.
89 bool omnibox_speculation_;
90 bool subresource_speculation_;
91
92 // Indicate if this socket was ever used. This state is set by a
93 // ClientSocketHandle before releasing this ClientSocket.
94 bool was_used_to_transmit_data_;
57 }; 95 };
58 96
59 } // namespace net 97 } // namespace net
60 98
61 #endif // NET_SOCKET_CLIENT_SOCKET_H_ 99 #endif // NET_SOCKET_CLIENT_SOCKET_H_
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | net/socket/client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698