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

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

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « net/http/disk_cache_based_quic_server_info.cc ('k') | net/http/http_network_transaction.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) 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/http/http_cache_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 void RecordOfflineStatus(int load_flags, RequestOfflineStatus status) { 209 void RecordOfflineStatus(int load_flags, RequestOfflineStatus status) {
210 // Restrict to main frame to keep statistics close to 210 // Restrict to main frame to keep statistics close to
211 // "would have shown them something useful if offline mode was enabled". 211 // "would have shown them something useful if offline mode was enabled".
212 if (load_flags & net::LOAD_MAIN_FRAME) { 212 if (load_flags & net::LOAD_MAIN_FRAME) {
213 UMA_HISTOGRAM_ENUMERATION("HttpCache.OfflineStatus", status, 213 UMA_HISTOGRAM_ENUMERATION("HttpCache.OfflineStatus", status,
214 OFFLINE_STATUS_MAX_ENTRIES); 214 OFFLINE_STATUS_MAX_ENTRIES);
215 } 215 }
216 } 216 }
217 217
218 // TODO(rvargas): Remove once we get the data.
219 void RecordVaryHeaderHistogram(const net::HttpResponseInfo* response) {
220 enum VaryType {
221 VARY_NOT_PRESENT,
222 VARY_UA,
223 VARY_OTHER,
224 VARY_MAX
225 };
226 VaryType vary = VARY_NOT_PRESENT;
227 if (response->vary_data.is_valid()) {
228 vary = VARY_OTHER;
229 if (response->headers->HasHeaderValue("vary", "user-agent"))
230 vary = VARY_UA;
231 }
232 UMA_HISTOGRAM_ENUMERATION("HttpCache.Vary", vary, VARY_MAX);
233 }
234
235 void RecordNoStoreHeaderHistogram(int load_flags, 218 void RecordNoStoreHeaderHistogram(int load_flags,
236 const net::HttpResponseInfo* response) { 219 const net::HttpResponseInfo* response) {
237 if (load_flags & net::LOAD_MAIN_FRAME) { 220 if (load_flags & net::LOAD_MAIN_FRAME) {
238 UMA_HISTOGRAM_BOOLEAN( 221 UMA_HISTOGRAM_BOOLEAN(
239 "Net.MainFrameNoStore", 222 "Net.MainFrameNoStore",
240 response->headers->HasHeaderValue("cache-control", "no-store")); 223 response->headers->HasHeaderValue("cache-control", "no-store"));
241 } 224 }
242 } 225 }
243 226
244 base::Value* NetLogAsyncRevalidationInfoCallback( 227 base::Value* NetLogAsyncRevalidationInfoCallback(
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 mode_ = NONE; 1203 mode_ = NONE;
1221 } 1204 }
1222 1205
1223 // Invalidate any cached GET with a successful POST. 1206 // Invalidate any cached GET with a successful POST.
1224 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) && 1207 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) &&
1225 request_->method == "POST" && 1208 request_->method == "POST" &&
1226 NonErrorResponse(new_response->headers->response_code())) { 1209 NonErrorResponse(new_response->headers->response_code())) {
1227 cache_->DoomMainEntryForUrl(request_->url); 1210 cache_->DoomMainEntryForUrl(request_->url);
1228 } 1211 }
1229 1212
1230 RecordVaryHeaderHistogram(new_response);
1231 RecordNoStoreHeaderHistogram(request_->load_flags, new_response); 1213 RecordNoStoreHeaderHistogram(request_->load_flags, new_response);
1232 1214
1233 if (new_response_->headers->response_code() == 416 && 1215 if (new_response_->headers->response_code() == 416 &&
1234 (request_->method == "GET" || request_->method == "POST")) { 1216 (request_->method == "GET" || request_->method == "POST")) {
1235 // If there is an active entry it may be destroyed with this transaction. 1217 // If there is an active entry it may be destroyed with this transaction.
1236 response_ = *new_response_; 1218 response_ = *new_response_;
1237 return OK; 1219 return OK;
1238 } 1220 }
1239 1221
1240 // Are we expecting a response to a conditional query? 1222 // Are we expecting a response to a conditional query?
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, 1336 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY,
1355 result); 1337 result);
1356 cache_pending_ = false; 1338 cache_pending_ = false;
1357 next_state_ = STATE_ADD_TO_ENTRY; 1339 next_state_ = STATE_ADD_TO_ENTRY;
1358 1340
1359 if (result == ERR_CACHE_RACE) { 1341 if (result == ERR_CACHE_RACE) {
1360 next_state_ = STATE_INIT_ENTRY; 1342 next_state_ = STATE_INIT_ENTRY;
1361 return OK; 1343 return OK;
1362 } 1344 }
1363 1345
1364 if (result == OK) { 1346 if (result != OK) {
1365 UMA_HISTOGRAM_BOOLEAN("HttpCache.OpenToCreateRace", false);
1366 } else {
1367 UMA_HISTOGRAM_BOOLEAN("HttpCache.OpenToCreateRace", true);
1368 // We have a race here: Maybe we failed to open the entry and decided to 1347 // We have a race here: Maybe we failed to open the entry and decided to
1369 // create one, but by the time we called create, another transaction already 1348 // create one, but by the time we called create, another transaction already
1370 // created the entry. If we want to eliminate this issue, we need an atomic 1349 // created the entry. If we want to eliminate this issue, we need an atomic
1371 // OpenOrCreate() method exposed by the disk cache. 1350 // OpenOrCreate() method exposed by the disk cache.
1372 DLOG(WARNING) << "Unable to create cache entry"; 1351 DLOG(WARNING) << "Unable to create cache entry";
1373 mode_ = NONE; 1352 mode_ = NONE;
1374 if (partial_.get()) 1353 if (partial_.get())
1375 partial_->RestoreHeaders(&custom_request_->extra_headers); 1354 partial_->RestoreHeaders(&custom_request_->extra_headers);
1376 next_state_ = STATE_SEND_REQUEST; 1355 next_state_ = STATE_SEND_REQUEST;
1377 } 1356 }
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 2928
2950 void HttpCache::Transaction::OnIOComplete(int result) { 2929 void HttpCache::Transaction::OnIOComplete(int result) {
2951 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. 2930 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
2952 tracked_objects::ScopedTracker tracking_profile( 2931 tracked_objects::ScopedTracker tracking_profile(
2953 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 Transaction::OnIOComplete")); 2932 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 Transaction::OnIOComplete"));
2954 2933
2955 DoLoop(result); 2934 DoLoop(result);
2956 } 2935 }
2957 2936
2958 } // namespace net 2937 } // namespace net
OLDNEW
« no previous file with comments | « net/http/disk_cache_based_quic_server_info.cc ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698