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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 12209080: Cleanup: Remove deprecated base::Value methods from net. Use base::Value too. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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_pool_base.cc ('k') | net/test/base_test_server.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 #include "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 const int kReadBufferSize = 8 * 1024; 44 const int kReadBufferSize = 8 * 1024;
45 const int kDefaultConnectionAtRiskOfLossSeconds = 10; 45 const int kDefaultConnectionAtRiskOfLossSeconds = 10;
46 const int kHungIntervalSeconds = 10; 46 const int kHungIntervalSeconds = 10;
47 47
48 // Always start at 1 for the first stream id. 48 // Always start at 1 for the first stream id.
49 const SpdyStreamId kFirstStreamId = 1; 49 const SpdyStreamId kFirstStreamId = 1;
50 50
51 // Minimum seconds that unclaimed pushed streams will be kept in memory. 51 // Minimum seconds that unclaimed pushed streams will be kept in memory.
52 const int kMinPushedStreamLifetimeSeconds = 300; 52 const int kMinPushedStreamLifetimeSeconds = 300;
53 53
54 Value* NetLogSpdySynCallback(const SpdyHeaderBlock* headers, 54 base::Value* NetLogSpdySynCallback(const SpdyHeaderBlock* headers,
55 bool fin, 55 bool fin,
56 bool unidirectional, 56 bool unidirectional,
57 SpdyStreamId stream_id, 57 SpdyStreamId stream_id,
58 SpdyStreamId associated_stream, 58 SpdyStreamId associated_stream,
59 NetLog::LogLevel /* log_level */) { 59 NetLog::LogLevel /* log_level */) {
60 DictionaryValue* dict = new DictionaryValue(); 60 base::DictionaryValue* dict = new base::DictionaryValue();
61 ListValue* headers_list = new ListValue(); 61 base::ListValue* headers_list = new base::ListValue();
62 for (SpdyHeaderBlock::const_iterator it = headers->begin(); 62 for (SpdyHeaderBlock::const_iterator it = headers->begin();
63 it != headers->end(); ++it) { 63 it != headers->end(); ++it) {
64 headers_list->Append(new StringValue(base::StringPrintf( 64 headers_list->Append(new base::StringValue(base::StringPrintf(
65 "%s: %s", it->first.c_str(), it->second.c_str()))); 65 "%s: %s", it->first.c_str(), it->second.c_str())));
66 } 66 }
67 dict->SetBoolean("fin", fin); 67 dict->SetBoolean("fin", fin);
68 dict->SetBoolean("unidirectional", unidirectional); 68 dict->SetBoolean("unidirectional", unidirectional);
69 dict->Set("headers", headers_list); 69 dict->Set("headers", headers_list);
70 dict->SetInteger("stream_id", stream_id); 70 dict->SetInteger("stream_id", stream_id);
71 if (associated_stream) 71 if (associated_stream)
72 dict->SetInteger("associated_stream", associated_stream); 72 dict->SetInteger("associated_stream", associated_stream);
73 return dict; 73 return dict;
74 } 74 }
75 75
76 Value* NetLogSpdyCredentialCallback(size_t slot, 76 base::Value* NetLogSpdyCredentialCallback(size_t slot,
77 const std::string* origin, 77 const std::string* origin,
78 NetLog::LogLevel /* log_level */) { 78 NetLog::LogLevel /* log_level */) {
79 DictionaryValue* dict = new DictionaryValue(); 79 base::DictionaryValue* dict = new base::DictionaryValue();
80 dict->SetInteger("slot", slot); 80 dict->SetInteger("slot", slot);
81 dict->SetString("origin", *origin); 81 dict->SetString("origin", *origin);
82 return dict; 82 return dict;
83 } 83 }
84 84
85 Value* NetLogSpdySessionCloseCallback(int net_error, 85 base::Value* NetLogSpdySessionCloseCallback(int net_error,
86 const std::string* description, 86 const std::string* description,
87 NetLog::LogLevel /* log_level */) { 87 NetLog::LogLevel /* log_level */) {
88 DictionaryValue* dict = new DictionaryValue(); 88 base::DictionaryValue* dict = new base::DictionaryValue();
89 dict->SetInteger("net_error", net_error); 89 dict->SetInteger("net_error", net_error);
90 dict->SetString("description", *description); 90 dict->SetString("description", *description);
91 return dict; 91 return dict;
92 } 92 }
93 93
94 Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair, 94 base::Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair,
95 NetLog::LogLevel /* log_level */) { 95 NetLog::LogLevel /* log_level */) {
96 DictionaryValue* dict = new DictionaryValue(); 96 base::DictionaryValue* dict = new base::DictionaryValue();
97 dict->SetString("host", host_pair->first.ToString()); 97 dict->SetString("host", host_pair->first.ToString());
98 dict->SetString("proxy", host_pair->second.ToPacString()); 98 dict->SetString("proxy", host_pair->second.ToPacString());
99 return dict; 99 return dict;
100 } 100 }
101 101
102 Value* NetLogSpdySettingCallback(SpdySettingsIds id, 102 base::Value* NetLogSpdySettingCallback(SpdySettingsIds id,
103 SpdySettingsFlags flags, 103 SpdySettingsFlags flags,
104 uint32 value, 104 uint32 value,
105 NetLog::LogLevel /* log_level */) { 105 NetLog::LogLevel /* log_level */) {
106 DictionaryValue* dict = new DictionaryValue(); 106 base::DictionaryValue* dict = new base::DictionaryValue();
107 dict->SetInteger("id", id); 107 dict->SetInteger("id", id);
108 dict->SetInteger("flags", flags); 108 dict->SetInteger("flags", flags);
109 dict->SetInteger("value", value); 109 dict->SetInteger("value", value);
110 return dict; 110 return dict;
111 } 111 }
112 112
113 Value* NetLogSpdySettingsCallback(const SettingsMap* settings, 113 base::Value* NetLogSpdySettingsCallback(const SettingsMap* settings,
114 NetLog::LogLevel /* log_level */) { 114 NetLog::LogLevel /* log_level */) {
115 DictionaryValue* dict = new DictionaryValue(); 115 base::DictionaryValue* dict = new base::DictionaryValue();
116 ListValue* settings_list = new ListValue(); 116 base::ListValue* settings_list = new base::ListValue();
117 for (SettingsMap::const_iterator it = settings->begin(); 117 for (SettingsMap::const_iterator it = settings->begin();
118 it != settings->end(); ++it) { 118 it != settings->end(); ++it) {
119 const SpdySettingsIds id = it->first; 119 const SpdySettingsIds id = it->first;
120 const SpdySettingsFlags flags = it->second.first; 120 const SpdySettingsFlags flags = it->second.first;
121 const uint32 value = it->second.second; 121 const uint32 value = it->second.second;
122 settings_list->Append(new StringValue( 122 settings_list->Append(new base::StringValue(
123 base::StringPrintf("[id:%u flags:%u value:%u]", id, flags, value))); 123 base::StringPrintf("[id:%u flags:%u value:%u]", id, flags, value)));
124 } 124 }
125 dict->Set("settings", settings_list); 125 dict->Set("settings", settings_list);
126 return dict; 126 return dict;
127 } 127 }
128 128
129 Value* NetLogSpdyWindowUpdateCallback(SpdyStreamId stream_id, 129 base::Value* NetLogSpdyWindowUpdateCallback(SpdyStreamId stream_id,
130 int32 delta, 130 int32 delta,
131 NetLog::LogLevel /* log_level */) { 131 NetLog::LogLevel /* log_level */) {
132 DictionaryValue* dict = new DictionaryValue(); 132 base::DictionaryValue* dict = new base::DictionaryValue();
133 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 133 dict->SetInteger("stream_id", static_cast<int>(stream_id));
134 dict->SetInteger("delta", delta); 134 dict->SetInteger("delta", delta);
135 return dict; 135 return dict;
136 } 136 }
137 137
138 Value* NetLogSpdyDataCallback(SpdyStreamId stream_id, 138 base::Value* NetLogSpdyDataCallback(SpdyStreamId stream_id,
139 int size, 139 int size,
140 SpdyDataFlags flags, 140 SpdyDataFlags flags,
141 NetLog::LogLevel /* log_level */) { 141 NetLog::LogLevel /* log_level */) {
142 DictionaryValue* dict = new DictionaryValue(); 142 base::DictionaryValue* dict = new base::DictionaryValue();
143 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 143 dict->SetInteger("stream_id", static_cast<int>(stream_id));
144 dict->SetInteger("size", size); 144 dict->SetInteger("size", size);
145 dict->SetInteger("flags", static_cast<int>(flags)); 145 dict->SetInteger("flags", static_cast<int>(flags));
146 return dict; 146 return dict;
147 } 147 }
148 148
149 Value* NetLogSpdyRstCallback(SpdyStreamId stream_id, 149 base::Value* NetLogSpdyRstCallback(SpdyStreamId stream_id,
150 int status, 150 int status,
151 const std::string* description, 151 const std::string* description,
152 NetLog::LogLevel /* log_level */) { 152 NetLog::LogLevel /* log_level */) {
153 DictionaryValue* dict = new DictionaryValue(); 153 base::DictionaryValue* dict = new base::DictionaryValue();
154 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 154 dict->SetInteger("stream_id", static_cast<int>(stream_id));
155 dict->SetInteger("status", status); 155 dict->SetInteger("status", status);
156 dict->SetString("description", *description); 156 dict->SetString("description", *description);
157 return dict; 157 return dict;
158 } 158 }
159 159
160 Value* NetLogSpdyPingCallback(uint32 unique_id, 160 base::Value* NetLogSpdyPingCallback(uint32 unique_id,
161 const char* type, 161 const char* type,
162 NetLog::LogLevel /* log_level */) { 162 NetLog::LogLevel /* log_level */) {
163 DictionaryValue* dict = new DictionaryValue(); 163 base::DictionaryValue* dict = new base::DictionaryValue();
164 dict->SetInteger("unique_id", unique_id); 164 dict->SetInteger("unique_id", unique_id);
165 dict->SetString("type", type); 165 dict->SetString("type", type);
166 return dict; 166 return dict;
167 } 167 }
168 168
169 Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id, 169 base::Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id,
170 int active_streams, 170 int active_streams,
171 int unclaimed_streams, 171 int unclaimed_streams,
172 SpdyGoAwayStatus status, 172 SpdyGoAwayStatus status,
173 NetLog::LogLevel /* log_level */) { 173 NetLog::LogLevel /* log_level */) {
174 DictionaryValue* dict = new DictionaryValue(); 174 base::DictionaryValue* dict = new base::DictionaryValue();
175 dict->SetInteger("last_accepted_stream_id", 175 dict->SetInteger("last_accepted_stream_id",
176 static_cast<int>(last_stream_id)); 176 static_cast<int>(last_stream_id));
177 dict->SetInteger("active_streams", active_streams); 177 dict->SetInteger("active_streams", active_streams);
178 dict->SetInteger("unclaimed_streams", unclaimed_streams); 178 dict->SetInteger("unclaimed_streams", unclaimed_streams);
179 dict->SetInteger("status", static_cast<int>(status)); 179 dict->SetInteger("status", static_cast<int>(status));
180 return dict; 180 return dict;
181 } 181 }
182 182
183 // Maximum number of concurrent streams we will create, unless the server 183 // Maximum number of concurrent streams we will create, unless the server
184 // sends a SETTINGS frame with a different value. 184 // sends a SETTINGS frame with a different value.
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 net_log().AddEvent( 743 net_log().AddEvent(
744 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM, 744 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM,
745 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description)); 745 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description));
746 746
747 DCHECK(buffered_spdy_framer_.get()); 747 DCHECK(buffered_spdy_framer_.get());
748 scoped_ptr<SpdyRstStreamControlFrame> rst_frame( 748 scoped_ptr<SpdyRstStreamControlFrame> rst_frame(
749 buffered_spdy_framer_->CreateRstStream(stream_id, status)); 749 buffered_spdy_framer_->CreateRstStream(stream_id, status));
750 750
751 // Default to lowest priority unless we know otherwise. 751 // Default to lowest priority unless we know otherwise.
752 RequestPriority priority = net::IDLE; 752 RequestPriority priority = net::IDLE;
753 if(IsStreamActive(stream_id)) { 753 if (IsStreamActive(stream_id)) {
754 scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; 754 scoped_refptr<SpdyStream> stream = active_streams_[stream_id];
755 priority = stream->priority(); 755 priority = stream->priority();
756 } 756 }
757 QueueFrame(rst_frame.release(), priority); 757 QueueFrame(rst_frame.release(), priority);
758 RecordProtocolErrorHistogram( 758 RecordProtocolErrorHistogram(
759 static_cast<SpdyProtocolErrorDetails>(status + STATUS_CODE_INVALID)); 759 static_cast<SpdyProtocolErrorDetails>(status + STATUS_CODE_INVALID));
760 DeleteStream(stream_id, ERR_SPDY_PROTOCOL_ERROR); 760 DeleteStream(stream_id, ERR_SPDY_PROTOCOL_ERROR);
761 } 761 }
762 762
763 bool SpdySession::IsStreamActive(SpdyStreamId stream_id) const { 763 bool SpdySession::IsStreamActive(SpdyStreamId stream_id) const {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 850
851 last_activity_time_ = base::TimeTicks::Now(); 851 last_activity_time_ = base::TimeTicks::Now();
852 852
853 // The SpdyFramer will use callbacks onto |this| as it parses frames. 853 // The SpdyFramer will use callbacks onto |this| as it parses frames.
854 // When errors occur, those callbacks can lead to teardown of all references 854 // When errors occur, those callbacks can lead to teardown of all references
855 // to |this|, so maintain a reference to self during this call for safe 855 // to |this|, so maintain a reference to self during this call for safe
856 // cleanup. 856 // cleanup.
857 scoped_refptr<SpdySession> self(this); 857 scoped_refptr<SpdySession> self(this);
858 858
859 DCHECK(buffered_spdy_framer_.get()); 859 DCHECK(buffered_spdy_framer_.get());
860 char *data = read_buffer_->data(); 860 char* data = read_buffer_->data();
861 while (result && 861 while (result &&
862 buffered_spdy_framer_->error_code() == 862 buffered_spdy_framer_->error_code() ==
863 SpdyFramer::SPDY_NO_ERROR) { 863 SpdyFramer::SPDY_NO_ERROR) {
864 uint32 bytes_processed = 864 uint32 bytes_processed =
865 buffered_spdy_framer_->ProcessInput(data, result); 865 buffered_spdy_framer_->ProcessInput(data, result);
866 result -= bytes_processed; 866 result -= bytes_processed;
867 data += bytes_processed; 867 data += bytes_processed;
868 if (buffered_spdy_framer_->state() == SpdyFramer::SPDY_DONE) 868 if (buffered_spdy_framer_->state() == SpdyFramer::SPDY_DONE)
869 buffered_spdy_framer_->Reset(); 869 buffered_spdy_framer_->Reset();
870 } 870 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 // an error. 1072 // an error.
1073 if (!IsClosed()) { 1073 if (!IsClosed()) {
1074 state_ = STATE_CLOSED; 1074 state_ = STATE_CLOSED;
1075 error_ = err; 1075 error_ = err;
1076 if (remove_from_pool) 1076 if (remove_from_pool)
1077 RemoveFromPool(); 1077 RemoveFromPool();
1078 CloseAllStreams(err); 1078 CloseAllStreams(err);
1079 } 1079 }
1080 } 1080 }
1081 1081
1082 Value* SpdySession::GetInfoAsValue() const { 1082 base::Value* SpdySession::GetInfoAsValue() const {
1083 DictionaryValue* dict = new DictionaryValue(); 1083 base::DictionaryValue* dict = new base::DictionaryValue();
1084 1084
1085 dict->SetInteger("source_id", net_log_.source().id); 1085 dict->SetInteger("source_id", net_log_.source().id);
1086 1086
1087 dict->SetString("host_port_pair", host_port_proxy_pair_.first.ToString()); 1087 dict->SetString("host_port_pair", host_port_proxy_pair_.first.ToString());
1088 if (!pooled_aliases_.empty()) { 1088 if (!pooled_aliases_.empty()) {
1089 ListValue* alias_list = new ListValue(); 1089 base::ListValue* alias_list = new base::ListValue();
1090 for (std::set<HostPortProxyPair>::const_iterator it = 1090 for (std::set<HostPortProxyPair>::const_iterator it =
1091 pooled_aliases_.begin(); 1091 pooled_aliases_.begin();
1092 it != pooled_aliases_.end(); it++) { 1092 it != pooled_aliases_.end(); it++) {
1093 alias_list->Append(Value::CreateStringValue(it->first.ToString())); 1093 alias_list->Append(new base::StringValue(it->first.ToString()));
1094 } 1094 }
1095 dict->Set("aliases", alias_list); 1095 dict->Set("aliases", alias_list);
1096 } 1096 }
1097 dict->SetString("proxy", host_port_proxy_pair_.second.ToURI()); 1097 dict->SetString("proxy", host_port_proxy_pair_.second.ToURI());
1098 1098
1099 dict->SetInteger("active_streams", active_streams_.size()); 1099 dict->SetInteger("active_streams", active_streams_.size());
1100 1100
1101 dict->SetInteger("unclaimed_pushed_streams", 1101 dict->SetInteger("unclaimed_pushed_streams",
1102 unclaimed_pushed_streams_.size()); 1102 unclaimed_pushed_streams_.size());
1103 1103
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 unclaimed_pushed_streams_.erase(it); 1251 unclaimed_pushed_streams_.erase(it);
1252 used_push_streams.Increment(); 1252 used_push_streams.Increment();
1253 return stream; 1253 return stream;
1254 } 1254 }
1255 return NULL; 1255 return NULL;
1256 } 1256 }
1257 1257
1258 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, 1258 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info,
1259 bool* was_npn_negotiated, 1259 bool* was_npn_negotiated,
1260 NextProto* protocol_negotiated) { 1260 NextProto* protocol_negotiated) {
1261
1262 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated(); 1261 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated();
1263 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol(); 1262 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol();
1264 return connection_->socket()->GetSSLInfo(ssl_info); 1263 return connection_->socket()->GetSSLInfo(ssl_info);
1265 } 1264 }
1266 1265
1267 bool SpdySession::GetSSLCertRequestInfo( 1266 bool SpdySession::GetSSLCertRequestInfo(
1268 SSLCertRequestInfo* cert_request_info) { 1267 SSLCertRequestInfo* cert_request_info) {
1269 if (!is_secure_) 1268 if (!is_secure_)
1270 return false; 1269 return false;
1271 GetSSLClientSocket()->GetSSLCertRequestInfo(cert_request_info); 1270 GetSSLClientSocket()->GetSSLCertRequestInfo(cert_request_info);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); 1499 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds);
1501 } 1500 }
1502 1501
1503 void SpdySession::OnSynReply(SpdyStreamId stream_id, 1502 void SpdySession::OnSynReply(SpdyStreamId stream_id,
1504 bool fin, 1503 bool fin,
1505 const SpdyHeaderBlock& headers) { 1504 const SpdyHeaderBlock& headers) {
1506 if (net_log().IsLoggingAllEvents()) { 1505 if (net_log().IsLoggingAllEvents()) {
1507 net_log().AddEvent( 1506 net_log().AddEvent(
1508 NetLog::TYPE_SPDY_SESSION_SYN_REPLY, 1507 NetLog::TYPE_SPDY_SESSION_SYN_REPLY,
1509 base::Bind(&NetLogSpdySynCallback, 1508 base::Bind(&NetLogSpdySynCallback,
1510 &headers, fin, false,// not unidirectional 1509 &headers, fin, false, // not unidirectional
1511 stream_id, 0)); 1510 stream_id, 0));
1512 } 1511 }
1513 1512
1514 if (!IsStreamActive(stream_id)) { 1513 if (!IsStreamActive(stream_id)) {
1515 // NOTE: it may just be that the stream was cancelled. 1514 // NOTE: it may just be that the stream was cancelled.
1516 return; 1515 return;
1517 } 1516 }
1518 1517
1519 scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; 1518 scoped_refptr<SpdyStream> stream = active_streams_[stream_id];
1520 CHECK_EQ(stream->stream_id(), stream_id); 1519 CHECK_EQ(stream->stream_id(), stream_id);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1983 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1985 if (!is_secure_) 1984 if (!is_secure_)
1986 return NULL; 1985 return NULL;
1987 SSLClientSocket* ssl_socket = 1986 SSLClientSocket* ssl_socket =
1988 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1987 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1989 DCHECK(ssl_socket); 1988 DCHECK(ssl_socket);
1990 return ssl_socket; 1989 return ssl_socket;
1991 } 1990 }
1992 1991
1993 } // namespace net 1992 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/test/base_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698