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

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

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/socket/client_socket.h ('k') | net/socket/client_socket_handle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/socket/client_socket.h"
6
7 #include "base/histogram.h"
8
9 namespace net {
10
11 ClientSocket::ClientSocket()
12 : was_ever_connected_(false),
13 omnibox_speculation_(false),
14 subresource_speculation_(false),
15 was_used_to_transmit_data_(false) {}
16
17 ClientSocket::~ClientSocket() {
18 EmitPreconnectionHistograms();
19 }
20
21 void ClientSocket::EmitPreconnectionHistograms() const {
22 DCHECK(!subresource_speculation_ || !omnibox_speculation_);
23 // 0 ==> non-speculative, never connected.
24 // 1 ==> non-speculative never used (but connected).
25 // 2 ==> non-speculative and used.
26 // 3 ==> omnibox_speculative never connected.
27 // 4 ==> omnibox_speculative never used (but connected).
28 // 5 ==> omnibox_speculative and used.
29 // 6 ==> subresource_speculative never connected.
30 // 7 ==> subresource_speculative never used (but connected).
31 // 8 ==> subresource_speculative and used.
32 int result;
33 if (was_used_to_transmit_data_)
34 result = 2;
35 else if (was_ever_connected_)
36 result = 1;
37 else
38 result = 0; // Never used, and not really connected.
39
40 if (omnibox_speculation_)
41 result += 3;
42 else if (subresource_speculation_)
43 result += 6;
44 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectUtilization", result, 9);
45 }
46
47 void ClientSocket::SetSubresourceSpeculation() {
48 if (was_used_to_transmit_data_)
49 return;
50 subresource_speculation_ = true;
51 }
52
53 void ClientSocket::SetOmniboxSpeculation() {
54 if (was_used_to_transmit_data_)
55 return;
56 omnibox_speculation_ = true;
57 }
58
59 void ClientSocket::UpdateConnectivityState(bool is_reused) {
60 // Record if this connection has every actually connected successfully.
61 // Note that IsConnected() won't be defined at destruction time, so we need
62 // to record this data now, while the derived class is present.
63 was_ever_connected_ |= IsConnected();
64 // A socket is_reused only after it has transmitted some data.
65 was_used_to_transmit_data_ |= is_reused;
66 }
67
68 } // namespace net
69
OLDNEW
« no previous file with comments | « net/socket/client_socket.h ('k') | net/socket/client_socket_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698