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

Side by Side Diff: net/http/http_response_info.cc

Issue 6369003: New extension API: "tab.socketAddress" (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_response_info.h ('k') | net/http/http_stream_parser.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 #include "net/http/http_response_info.h" 5 #include "net/http/http_response_info.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "net/base/auth.h" 10 #include "net/base/auth.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // This bit is set if the request has NPN negotiated. 49 // This bit is set if the request has NPN negotiated.
50 RESPONSE_INFO_WAS_NPN = 1 << 14, 50 RESPONSE_INFO_WAS_NPN = 1 << 14,
51 51
52 // This bit is set if the request was fetched via an explicit proxy. 52 // This bit is set if the request was fetched via an explicit proxy.
53 RESPONSE_INFO_WAS_PROXY = 1 << 15, 53 RESPONSE_INFO_WAS_PROXY = 1 << 15,
54 54
55 // This bit is set if response could use alternate protocol. However, browser 55 // This bit is set if response could use alternate protocol. However, browser
56 // will ingore the alternate protocol if spdy is not enabled. 56 // will ingore the alternate protocol if spdy is not enabled.
57 RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE = 1 << 16, 57 RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE = 1 << 16,
58 58
59 // This bit is set if the response info has a socket_address string.
60 RESPONSE_INFO_HAS_SOCKET_ADDRESS = 1 << 17,
61
59 // TODO(darin): Add other bits to indicate alternate request methods. 62 // TODO(darin): Add other bits to indicate alternate request methods.
60 // For now, we don't support storing those. 63 // For now, we don't support storing those.
61 }; 64 };
62 65
63 HttpResponseInfo::HttpResponseInfo() 66 HttpResponseInfo::HttpResponseInfo()
64 : was_cached(false), 67 : was_cached(false),
65 was_fetched_via_spdy(false), 68 was_fetched_via_spdy(false),
66 was_npn_negotiated(false), 69 was_npn_negotiated(false),
67 was_alternate_protocol_available(false), 70 was_alternate_protocol_available(false),
68 was_fetched_via_proxy(false) { 71 was_fetched_via_proxy(false) {
69 } 72 }
70 73
71 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) 74 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs)
72 : was_cached(rhs.was_cached), 75 : was_cached(rhs.was_cached),
73 was_fetched_via_spdy(rhs.was_fetched_via_spdy), 76 was_fetched_via_spdy(rhs.was_fetched_via_spdy),
74 was_npn_negotiated(rhs.was_npn_negotiated), 77 was_npn_negotiated(rhs.was_npn_negotiated),
75 was_alternate_protocol_available(rhs.was_alternate_protocol_available), 78 was_alternate_protocol_available(rhs.was_alternate_protocol_available),
76 was_fetched_via_proxy(rhs.was_fetched_via_proxy), 79 was_fetched_via_proxy(rhs.was_fetched_via_proxy),
80 socket_address(rhs.socket_address),
77 request_time(rhs.request_time), 81 request_time(rhs.request_time),
78 response_time(rhs.response_time), 82 response_time(rhs.response_time),
79 auth_challenge(rhs.auth_challenge), 83 auth_challenge(rhs.auth_challenge),
80 cert_request_info(rhs.cert_request_info), 84 cert_request_info(rhs.cert_request_info),
81 ssl_info(rhs.ssl_info), 85 ssl_info(rhs.ssl_info),
82 headers(rhs.headers), 86 headers(rhs.headers),
83 vary_data(rhs.vary_data), 87 vary_data(rhs.vary_data),
84 metadata(rhs.metadata) { 88 metadata(rhs.metadata) {
85 } 89 }
86 90
87 HttpResponseInfo::~HttpResponseInfo() { 91 HttpResponseInfo::~HttpResponseInfo() {
88 } 92 }
89 93
90 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { 94 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) {
91 was_cached = rhs.was_cached; 95 was_cached = rhs.was_cached;
92 was_fetched_via_spdy = rhs.was_fetched_via_spdy; 96 was_fetched_via_spdy = rhs.was_fetched_via_spdy;
93 was_npn_negotiated = rhs.was_npn_negotiated; 97 was_npn_negotiated = rhs.was_npn_negotiated;
94 was_alternate_protocol_available = rhs.was_alternate_protocol_available; 98 was_alternate_protocol_available = rhs.was_alternate_protocol_available;
95 was_fetched_via_proxy = rhs.was_fetched_via_proxy; 99 was_fetched_via_proxy = rhs.was_fetched_via_proxy;
100 socket_address = rhs.socket_address;
96 request_time = rhs.request_time; 101 request_time = rhs.request_time;
97 response_time = rhs.response_time; 102 response_time = rhs.response_time;
98 auth_challenge = rhs.auth_challenge; 103 auth_challenge = rhs.auth_challenge;
99 cert_request_info = rhs.cert_request_info; 104 cert_request_info = rhs.cert_request_info;
100 ssl_info = rhs.ssl_info; 105 ssl_info = rhs.ssl_info;
101 headers = rhs.headers; 106 headers = rhs.headers;
102 vary_data = rhs.vary_data; 107 vary_data = rhs.vary_data;
103 metadata = rhs.metadata; 108 metadata = rhs.metadata;
104 return *this; 109 return *this;
105 } 110 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return false; 156 return false;
152 ssl_info.security_bits = security_bits; 157 ssl_info.security_bits = security_bits;
153 } 158 }
154 159
155 // read vary-data 160 // read vary-data
156 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { 161 if (flags & RESPONSE_INFO_HAS_VARY_DATA) {
157 if (!vary_data.InitFromPickle(pickle, &iter)) 162 if (!vary_data.InitFromPickle(pickle, &iter))
158 return false; 163 return false;
159 } 164 }
160 165
166 // read socket_address.
167 if (flags & RESPONSE_INFO_HAS_SOCKET_ADDRESS) {
168 if (!pickle.ReadString(&iter, &socket_address))
169 return false;
170 }
171
161 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; 172 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0;
162 173
163 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; 174 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0;
164 175
165 was_alternate_protocol_available = 176 was_alternate_protocol_available =
166 (flags & RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE) != 0; 177 (flags & RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE) != 0;
167 178
168 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; 179 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0;
169 180
170 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) ? true : false; 181 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) ? true : false;
(...skipping 17 matching lines...) Expand all
188 if (response_truncated) 199 if (response_truncated)
189 flags |= RESPONSE_INFO_TRUNCATED; 200 flags |= RESPONSE_INFO_TRUNCATED;
190 if (was_fetched_via_spdy) 201 if (was_fetched_via_spdy)
191 flags |= RESPONSE_INFO_WAS_SPDY; 202 flags |= RESPONSE_INFO_WAS_SPDY;
192 if (was_npn_negotiated) 203 if (was_npn_negotiated)
193 flags |= RESPONSE_INFO_WAS_NPN; 204 flags |= RESPONSE_INFO_WAS_NPN;
194 if (was_alternate_protocol_available) 205 if (was_alternate_protocol_available)
195 flags |= RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE; 206 flags |= RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE;
196 if (was_fetched_via_proxy) 207 if (was_fetched_via_proxy)
197 flags |= RESPONSE_INFO_WAS_PROXY; 208 flags |= RESPONSE_INFO_WAS_PROXY;
209 if (!socket_address.empty())
210 flags |= RESPONSE_INFO_HAS_SOCKET_ADDRESS;
eroman 2011/01/19 19:21:30 Is the flag necessary? I would expect that pickle-
pmarks 2011/01/21 08:21:56 I added this flag so that it'd be possible to unpi
198 211
199 pickle->WriteInt(flags); 212 pickle->WriteInt(flags);
200 pickle->WriteInt64(request_time.ToInternalValue()); 213 pickle->WriteInt64(request_time.ToInternalValue());
201 pickle->WriteInt64(response_time.ToInternalValue()); 214 pickle->WriteInt64(response_time.ToInternalValue());
202 215
203 net::HttpResponseHeaders::PersistOptions persist_options = 216 net::HttpResponseHeaders::PersistOptions persist_options =
204 net::HttpResponseHeaders::PERSIST_RAW; 217 net::HttpResponseHeaders::PERSIST_RAW;
205 218
206 if (skip_transient_headers) { 219 if (skip_transient_headers) {
207 persist_options = 220 persist_options =
208 net::HttpResponseHeaders::PERSIST_SANS_COOKIES | 221 net::HttpResponseHeaders::PERSIST_SANS_COOKIES |
209 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES | 222 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES |
210 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP | 223 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP |
211 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE | 224 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE |
212 net::HttpResponseHeaders::PERSIST_SANS_RANGES; 225 net::HttpResponseHeaders::PERSIST_SANS_RANGES;
213 } 226 }
214 227
215 headers->Persist(pickle, persist_options); 228 headers->Persist(pickle, persist_options);
216 229
217 if (ssl_info.is_valid()) { 230 if (ssl_info.is_valid()) {
218 ssl_info.cert->Persist(pickle); 231 ssl_info.cert->Persist(pickle);
219 pickle->WriteInt(ssl_info.cert_status); 232 pickle->WriteInt(ssl_info.cert_status);
220 if (ssl_info.security_bits != -1) 233 if (ssl_info.security_bits != -1)
221 pickle->WriteInt(ssl_info.security_bits); 234 pickle->WriteInt(ssl_info.security_bits);
222 } 235 }
223 236
224 if (vary_data.is_valid()) 237 if (vary_data.is_valid())
225 vary_data.Persist(pickle); 238 vary_data.Persist(pickle);
239
240 if (!socket_address.empty())
241 pickle->WriteString(socket_address);
226 } 242 }
227 243
228 } // namespace net 244 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_info.h ('k') | net/http/http_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698