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

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

Issue 6930014: Rename ClientSocket to StreamSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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/stream_socket.h ('k') | net/socket/tcp_client_socket_libevent.h » ('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 #include "net/socket/client_socket.h" 5 #include "net/socket/stream_socket.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 namespace { 14 namespace {
15 15
(...skipping 24 matching lines...) Expand all
40 Value* NetLogBytesTransferredParameter::ToValue() const { 40 Value* NetLogBytesTransferredParameter::ToValue() const {
41 DictionaryValue* dict = new DictionaryValue(); 41 DictionaryValue* dict = new DictionaryValue();
42 dict->SetInteger("byte_count", byte_count_); 42 dict->SetInteger("byte_count", byte_count_);
43 if (has_bytes_) 43 if (has_bytes_)
44 dict->SetString("hex_encoded_bytes", hex_encoded_bytes_); 44 dict->SetString("hex_encoded_bytes", hex_encoded_bytes_);
45 return dict; 45 return dict;
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 ClientSocket::UseHistory::UseHistory() 50 StreamSocket::UseHistory::UseHistory()
51 : was_ever_connected_(false), 51 : was_ever_connected_(false),
52 was_used_to_convey_data_(false), 52 was_used_to_convey_data_(false),
53 omnibox_speculation_(false), 53 omnibox_speculation_(false),
54 subresource_speculation_(false) { 54 subresource_speculation_(false) {
55 } 55 }
56 56
57 ClientSocket::UseHistory::~UseHistory() { 57 StreamSocket::UseHistory::~UseHistory() {
58 EmitPreconnectionHistograms(); 58 EmitPreconnectionHistograms();
59 } 59 }
60 60
61 void ClientSocket::UseHistory::Reset() { 61 void StreamSocket::UseHistory::Reset() {
62 EmitPreconnectionHistograms(); 62 EmitPreconnectionHistograms();
63 was_ever_connected_ = false; 63 was_ever_connected_ = false;
64 was_used_to_convey_data_ = false; 64 was_used_to_convey_data_ = false;
65 // omnibox_speculation_ and subresource_speculation_ values 65 // omnibox_speculation_ and subresource_speculation_ values
66 // are intentionally preserved. 66 // are intentionally preserved.
67 } 67 }
68 68
69 void ClientSocket::UseHistory::set_was_ever_connected() { 69 void StreamSocket::UseHistory::set_was_ever_connected() {
70 DCHECK(!was_used_to_convey_data_); 70 DCHECK(!was_used_to_convey_data_);
71 was_ever_connected_ = true; 71 was_ever_connected_ = true;
72 } 72 }
73 73
74 void ClientSocket::UseHistory::set_was_used_to_convey_data() { 74 void StreamSocket::UseHistory::set_was_used_to_convey_data() {
75 DCHECK(was_ever_connected_); 75 DCHECK(was_ever_connected_);
76 was_used_to_convey_data_ = true; 76 was_used_to_convey_data_ = true;
77 } 77 }
78 78
79 79
80 void ClientSocket::UseHistory::set_subresource_speculation() { 80 void StreamSocket::UseHistory::set_subresource_speculation() {
81 DCHECK(was_ever_connected_); 81 DCHECK(was_ever_connected_);
82 // TODO(jar): We should transition to marking a socket (or stream) at 82 // TODO(jar): We should transition to marking a socket (or stream) at
83 // construction time as being created for speculative reasons. This current 83 // construction time as being created for speculative reasons. This current
84 // approach of trying to track use of a socket to convey data can make 84 // approach of trying to track use of a socket to convey data can make
85 // mistakes when other sockets (such as ones sitting in the pool for a long 85 // mistakes when other sockets (such as ones sitting in the pool for a long
86 // time) are issued. Unused sockets can be left over when a when a set of 86 // time) are issued. Unused sockets can be left over when a when a set of
87 // connections to a host are made, and one is "unlucky" and takes so long to 87 // connections to a host are made, and one is "unlucky" and takes so long to
88 // complete a connection, that another socket is used, and recycled before a 88 // complete a connection, that another socket is used, and recycled before a
89 // second connection comes available. Similarly, re-try connections can leave 89 // second connection comes available. Similarly, re-try connections can leave
90 // an original (slow to connect socket) in the pool, and that can be issued 90 // an original (slow to connect socket) in the pool, and that can be issued
91 // to a speculative requester. In any cases such old sockets will fail when an 91 // to a speculative requester. In any cases such old sockets will fail when an
92 // attempt is made to used them!... and then it will look like a speculative 92 // attempt is made to used them!... and then it will look like a speculative
93 // socket was discarded without any user!?!?! 93 // socket was discarded without any user!?!?!
94 if (was_used_to_convey_data_) 94 if (was_used_to_convey_data_)
95 return; 95 return;
96 subresource_speculation_ = true; 96 subresource_speculation_ = true;
97 } 97 }
98 98
99 void ClientSocket::UseHistory::set_omnibox_speculation() { 99 void StreamSocket::UseHistory::set_omnibox_speculation() {
100 DCHECK(was_ever_connected_); 100 DCHECK(was_ever_connected_);
101 if (was_used_to_convey_data_) 101 if (was_used_to_convey_data_)
102 return; 102 return;
103 omnibox_speculation_ = true; 103 omnibox_speculation_ = true;
104 } 104 }
105 105
106 bool ClientSocket::UseHistory::was_used_to_convey_data() const { 106 bool StreamSocket::UseHistory::was_used_to_convey_data() const {
107 DCHECK(!was_used_to_convey_data_ || was_ever_connected_); 107 DCHECK(!was_used_to_convey_data_ || was_ever_connected_);
108 return was_used_to_convey_data_; 108 return was_used_to_convey_data_;
109 } 109 }
110 110
111 void ClientSocket::UseHistory::EmitPreconnectionHistograms() const { 111 void StreamSocket::UseHistory::EmitPreconnectionHistograms() const {
112 DCHECK(!subresource_speculation_ || !omnibox_speculation_); 112 DCHECK(!subresource_speculation_ || !omnibox_speculation_);
113 // 0 ==> non-speculative, never connected. 113 // 0 ==> non-speculative, never connected.
114 // 1 ==> non-speculative never used (but connected). 114 // 1 ==> non-speculative never used (but connected).
115 // 2 ==> non-speculative and used. 115 // 2 ==> non-speculative and used.
116 // 3 ==> omnibox_speculative never connected. 116 // 3 ==> omnibox_speculative never connected.
117 // 4 ==> omnibox_speculative never used (but connected). 117 // 4 ==> omnibox_speculative never used (but connected).
118 // 5 ==> omnibox_speculative and used. 118 // 5 ==> omnibox_speculative and used.
119 // 6 ==> subresource_speculative never connected. 119 // 6 ==> subresource_speculative never connected.
120 // 7 ==> subresource_speculative never used (but connected). 120 // 7 ==> subresource_speculative never used (but connected).
121 // 8 ==> subresource_speculative and used. 121 // 8 ==> subresource_speculative and used.
(...skipping 15 matching lines...) Expand all
137 base::FieldTrialList::Find("ConnnectBackupJobs") && 137 base::FieldTrialList::Find("ConnnectBackupJobs") &&
138 !base::FieldTrialList::Find("ConnnectBackupJobs")->group_name().empty(); 138 !base::FieldTrialList::Find("ConnnectBackupJobs")->group_name().empty();
139 if (connect_backup_jobs_fieldtrial) { 139 if (connect_backup_jobs_fieldtrial) {
140 UMA_HISTOGRAM_ENUMERATION( 140 UMA_HISTOGRAM_ENUMERATION(
141 base::FieldTrial::MakeName("Net.PreconnectUtilization2", 141 base::FieldTrial::MakeName("Net.PreconnectUtilization2",
142 "ConnnectBackupJobs"), 142 "ConnnectBackupJobs"),
143 result, 9); 143 result, 9);
144 } 144 }
145 } 145 }
146 146
147 void ClientSocket::LogByteTransfer(const BoundNetLog& net_log, 147 void StreamSocket::LogByteTransfer(const BoundNetLog& net_log,
148 NetLog::EventType event_type, 148 NetLog::EventType event_type,
149 int byte_count, 149 int byte_count,
150 char* bytes) const { 150 char* bytes) const {
151 scoped_refptr<NetLog::EventParameters> params; 151 scoped_refptr<NetLog::EventParameters> params;
152 if (net_log.IsLoggingBytes()) { 152 if (net_log.IsLoggingBytes()) {
153 params = new NetLogBytesTransferredParameter(byte_count, bytes); 153 params = new NetLogBytesTransferredParameter(byte_count, bytes);
154 } else { 154 } else {
155 params = new NetLogBytesTransferredParameter(byte_count, NULL); 155 params = new NetLogBytesTransferredParameter(byte_count, NULL);
156 } 156 }
157 net_log.AddEvent(event_type, params); 157 net_log.AddEvent(event_type, params);
158 } 158 }
159 159
160 } // namespace net 160 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/stream_socket.h ('k') | net/socket/tcp_client_socket_libevent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698