| OLD | NEW |
| 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" // For OS_POSIX | 7 #include "build/build_config.h" // For OS_POSIX |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "net/http/http_util.h" | 41 #include "net/http/http_util.h" |
| 42 #include "net/ssl/ssl_cert_request_info.h" | 42 #include "net/ssl/ssl_cert_request_info.h" |
| 43 #include "net/ssl/ssl_config_service.h" | 43 #include "net/ssl/ssl_config_service.h" |
| 44 | 44 |
| 45 using base::Time; | 45 using base::Time; |
| 46 using base::TimeDelta; | 46 using base::TimeDelta; |
| 47 using base::TimeTicks; | 47 using base::TimeTicks; |
| 48 | 48 |
| 49 namespace net { | 49 namespace net { |
| 50 | 50 |
| 51 using CacheEntryStatus = HttpResponseInfo::CacheEntryStatus; |
| 52 |
| 51 namespace { | 53 namespace { |
| 52 | 54 |
| 53 // TODO(ricea): Move this to HttpResponseHeaders once it is standardised. | 55 // TODO(ricea): Move this to HttpResponseHeaders once it is standardised. |
| 54 static const char kFreshnessHeader[] = "Resource-Freshness"; | 56 static const char kFreshnessHeader[] = "Resource-Freshness"; |
| 55 | 57 |
| 56 // From http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-21#section-6 | 58 // From http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-21#section-6 |
| 57 // a "non-error response" is one with a 2xx (Successful) or 3xx | 59 // a "non-error response" is one with a 2xx (Successful) or 3xx |
| 58 // (Redirection) status code. | 60 // (Redirection) status code. |
| 59 bool NonErrorResponse(int status_code) { | 61 bool NonErrorResponse(int status_code) { |
| 60 int status_code_range = status_code / 100; | 62 int status_code_range = status_code / 100; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 cache_pending_(false), | 160 cache_pending_(false), |
| 159 done_reading_(false), | 161 done_reading_(false), |
| 160 vary_mismatch_(false), | 162 vary_mismatch_(false), |
| 161 couldnt_conditionalize_request_(false), | 163 couldnt_conditionalize_request_(false), |
| 162 bypass_lock_for_test_(false), | 164 bypass_lock_for_test_(false), |
| 163 fail_conditionalization_for_test_(false), | 165 fail_conditionalization_for_test_(false), |
| 164 io_buf_len_(0), | 166 io_buf_len_(0), |
| 165 read_offset_(0), | 167 read_offset_(0), |
| 166 effective_load_flags_(0), | 168 effective_load_flags_(0), |
| 167 write_len_(0), | 169 write_len_(0), |
| 168 transaction_pattern_(PATTERN_UNDEFINED), | 170 cache_entry_status_(CacheEntryStatus::ENTRY_UNDEFINED), |
| 169 validation_cause_(VALIDATION_CAUSE_UNDEFINED), | 171 validation_cause_(VALIDATION_CAUSE_UNDEFINED), |
| 170 total_received_bytes_(0), | 172 total_received_bytes_(0), |
| 171 total_sent_bytes_(0), | 173 total_sent_bytes_(0), |
| 172 websocket_handshake_stream_base_create_helper_(NULL), | 174 websocket_handshake_stream_base_create_helper_(NULL), |
| 173 weak_factory_(this) { | 175 weak_factory_(this) { |
| 174 static_assert(HttpCache::Transaction::kNumValidationHeaders == | 176 static_assert(HttpCache::Transaction::kNumValidationHeaders == |
| 175 arraysize(kValidationHeaders), | 177 arraysize(kValidationHeaders), |
| 176 "invalid number of validation headers"); | 178 "invalid number of validation headers"); |
| 177 | 179 |
| 178 io_callback_ = base::Bind(&Transaction::OnIOComplete, | 180 io_callback_ = base::Bind(&Transaction::OnIOComplete, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 DCHECK(auth_response_.headers.get()); | 327 DCHECK(auth_response_.headers.get()); |
| 326 DCHECK(!callback.is_null()); | 328 DCHECK(!callback.is_null()); |
| 327 | 329 |
| 328 // Ensure that we only have one asynchronous call at a time. | 330 // Ensure that we only have one asynchronous call at a time. |
| 329 DCHECK(callback_.is_null()); | 331 DCHECK(callback_.is_null()); |
| 330 | 332 |
| 331 if (!cache_.get()) | 333 if (!cache_.get()) |
| 332 return ERR_UNEXPECTED; | 334 return ERR_UNEXPECTED; |
| 333 | 335 |
| 334 // Clear the intermediate response since we are going to start over. | 336 // Clear the intermediate response since we are going to start over. |
| 335 auth_response_ = HttpResponseInfo(); | 337 SetAuthResponse(HttpResponseInfo()); |
| 336 | 338 |
| 337 int rv = RestartNetworkRequestWithAuth(credentials); | 339 int rv = RestartNetworkRequestWithAuth(credentials); |
| 338 | 340 |
| 339 if (rv == ERR_IO_PENDING) | 341 if (rv == ERR_IO_PENDING) |
| 340 callback_ = callback; | 342 callback_ = callback; |
| 341 | 343 |
| 342 return rv; | 344 return rv; |
| 343 } | 345 } |
| 344 | 346 |
| 345 bool HttpCache::Transaction::IsReadyToRestartForAuth() { | 347 bool HttpCache::Transaction::IsReadyToRestartForAuth() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 357 | 359 |
| 358 DCHECK(callback_.is_null()); | 360 DCHECK(callback_.is_null()); |
| 359 | 361 |
| 360 if (!cache_.get()) | 362 if (!cache_.get()) |
| 361 return ERR_UNEXPECTED; | 363 return ERR_UNEXPECTED; |
| 362 | 364 |
| 363 // If we have an intermediate auth response at this point, then it means the | 365 // If we have an intermediate auth response at this point, then it means the |
| 364 // user wishes to read the network response (the error page). If there is a | 366 // user wishes to read the network response (the error page). If there is a |
| 365 // previous response in the cache then we should leave it intact. | 367 // previous response in the cache then we should leave it intact. |
| 366 if (auth_response_.headers.get() && mode_ != NONE) { | 368 if (auth_response_.headers.get() && mode_ != NONE) { |
| 367 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 369 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 368 DCHECK(mode_ & WRITE); | 370 DCHECK(mode_ & WRITE); |
| 369 DoneWritingToEntry(mode_ == READ_WRITE); | 371 DoneWritingToEntry(mode_ == READ_WRITE); |
| 370 mode_ = NONE; | 372 mode_ = NONE; |
| 371 } | 373 } |
| 372 | 374 |
| 373 reading_ = true; | 375 reading_ = true; |
| 374 read_buf_ = buf; | 376 read_buf_ = buf; |
| 375 io_buf_len_ = buf_len; | 377 io_buf_len_ = buf_len; |
| 376 if (network_trans_) { | 378 if (network_trans_) { |
| 377 DCHECK(mode_ == WRITE || mode_ == NONE || | 379 DCHECK(mode_ == WRITE || mode_ == NONE || |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 // for mode_ to be NONE and entry_ non-NULL with a write entry | 444 // for mode_ to be NONE and entry_ non-NULL with a write entry |
| 443 // if StopCaching was called. | 445 // if StopCaching was called. |
| 444 cache_->DoneReadingFromEntry(entry_, this); | 446 cache_->DoneReadingFromEntry(entry_, this); |
| 445 entry_ = NULL; | 447 entry_ = NULL; |
| 446 } | 448 } |
| 447 } | 449 } |
| 448 } | 450 } |
| 449 | 451 |
| 450 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { | 452 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { |
| 451 // Null headers means we encountered an error or haven't a response yet | 453 // Null headers means we encountered an error or haven't a response yet |
| 452 if (auth_response_.headers.get()) | 454 if (auth_response_.headers.get()) { |
| 455 DCHECK_EQ(cache_entry_status_, auth_response_.cache_entry_status) |
| 456 << "These must be in sync via SetResponse and SetAuthResponse."; |
| 453 return &auth_response_; | 457 return &auth_response_; |
| 458 } |
| 459 DCHECK_EQ(cache_entry_status_, response_.cache_entry_status) |
| 460 << "These must be in sync via SetResponse and SetAuthResponse."; |
| 454 return &response_; | 461 return &response_; |
| 455 } | 462 } |
| 456 | 463 |
| 457 LoadState HttpCache::Transaction::GetLoadState() const { | 464 LoadState HttpCache::Transaction::GetLoadState() const { |
| 458 LoadState state = GetWriterLoadState(); | 465 LoadState state = GetWriterLoadState(); |
| 459 if (state != LOAD_STATE_WAITING_FOR_CACHE) | 466 if (state != LOAD_STATE_WAITING_FOR_CACHE) |
| 460 return state; | 467 return state; |
| 461 | 468 |
| 462 if (cache_.get()) | 469 if (cache_.get()) |
| 463 return cache_->GetLoadStateForPendingTransaction(this); | 470 return cache_->GetLoadStateForPendingTransaction(this); |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 // to be validated and then issue a network request if needed or just read | 1250 // to be validated and then issue a network request if needed or just read |
| 1244 // from the cache if the cache entry is already valid. | 1251 // from the cache if the cache entry is already valid. |
| 1245 // | 1252 // |
| 1246 // o if we are set to UPDATE, then we are handling an externally | 1253 // o if we are set to UPDATE, then we are handling an externally |
| 1247 // conditionalized request (if-modified-since / if-none-match). We check | 1254 // conditionalized request (if-modified-since / if-none-match). We check |
| 1248 // if the request headers define a validation request. | 1255 // if the request headers define a validation request. |
| 1249 // | 1256 // |
| 1250 int result = ERR_FAILED; | 1257 int result = ERR_FAILED; |
| 1251 switch (mode_) { | 1258 switch (mode_) { |
| 1252 case READ: | 1259 case READ: |
| 1253 UpdateTransactionPattern(PATTERN_ENTRY_USED); | 1260 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_USED); |
| 1254 result = BeginCacheRead(); | 1261 result = BeginCacheRead(); |
| 1255 break; | 1262 break; |
| 1256 case READ_WRITE: | 1263 case READ_WRITE: |
| 1257 result = BeginPartialCacheValidation(); | 1264 result = BeginPartialCacheValidation(); |
| 1258 break; | 1265 break; |
| 1259 case UPDATE: | 1266 case UPDATE: |
| 1260 result = BeginExternallyConditionalizedRequest(); | 1267 result = BeginExternallyConditionalizedRequest(); |
| 1261 break; | 1268 break; |
| 1262 case WRITE: | 1269 case WRITE: |
| 1263 default: | 1270 default: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 | 1359 |
| 1353 if (result == OK) { | 1360 if (result == OK) { |
| 1354 next_state_ = STATE_SUCCESSFUL_SEND_REQUEST; | 1361 next_state_ = STATE_SUCCESSFUL_SEND_REQUEST; |
| 1355 return OK; | 1362 return OK; |
| 1356 } | 1363 } |
| 1357 | 1364 |
| 1358 const HttpResponseInfo* response = network_trans_->GetResponseInfo(); | 1365 const HttpResponseInfo* response = network_trans_->GetResponseInfo(); |
| 1359 response_.network_accessed = response->network_accessed; | 1366 response_.network_accessed = response->network_accessed; |
| 1360 | 1367 |
| 1361 // Do not record requests that have network errors or restarts. | 1368 // Do not record requests that have network errors or restarts. |
| 1362 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 1369 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 1363 if (IsCertificateError(result)) { | 1370 if (IsCertificateError(result)) { |
| 1364 // If we get a certificate error, then there is a certificate in ssl_info, | 1371 // If we get a certificate error, then there is a certificate in ssl_info, |
| 1365 // so GetResponseInfo() should never return NULL here. | 1372 // so GetResponseInfo() should never return NULL here. |
| 1366 DCHECK(response); | 1373 DCHECK(response); |
| 1367 response_.ssl_info = response->ssl_info; | 1374 response_.ssl_info = response->ssl_info; |
| 1368 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 1375 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
| 1369 DCHECK(response); | 1376 DCHECK(response); |
| 1370 response_.cert_request_info = response->cert_request_info; | 1377 response_.cert_request_info = response->cert_request_info; |
| 1371 } else if (response_.was_cached) { | 1378 } else if (response_.was_cached) { |
| 1372 DoneWritingToEntry(true); | 1379 DoneWritingToEntry(true); |
| 1373 } | 1380 } |
| 1374 | 1381 |
| 1375 return result; | 1382 return result; |
| 1376 } | 1383 } |
| 1377 | 1384 |
| 1378 // We received the response headers and there is no error. | 1385 // We received the response headers and there is no error. |
| 1379 int HttpCache::Transaction::DoSuccessfulSendRequest() { | 1386 int HttpCache::Transaction::DoSuccessfulSendRequest() { |
| 1380 DCHECK(!new_response_); | 1387 DCHECK(!new_response_); |
| 1381 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); | 1388 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); |
| 1382 | 1389 |
| 1383 if (new_response->headers->response_code() == 401 || | 1390 if (new_response->headers->response_code() == 401 || |
| 1384 new_response->headers->response_code() == 407) { | 1391 new_response->headers->response_code() == 407) { |
| 1385 auth_response_ = *new_response; | 1392 SetAuthResponse(*new_response); |
| 1386 if (!reading_) | 1393 if (!reading_) |
| 1387 return OK; | 1394 return OK; |
| 1388 | 1395 |
| 1389 // We initiated a second request the caller doesn't know about. We should be | 1396 // We initiated a second request the caller doesn't know about. We should be |
| 1390 // able to authenticate this request because we should have authenticated | 1397 // able to authenticate this request because we should have authenticated |
| 1391 // this URL moments ago. | 1398 // this URL moments ago. |
| 1392 if (IsReadyToRestartForAuth()) { | 1399 if (IsReadyToRestartForAuth()) { |
| 1393 DCHECK(!response_.auth_challenge.get()); | 1400 DCHECK(!response_.auth_challenge.get()); |
| 1394 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 1401 next_state_ = STATE_SEND_REQUEST_COMPLETE; |
| 1395 // In theory we should check to see if there are new cookies, but there | 1402 // In theory we should check to see if there are new cookies, but there |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1410 return ERR_CACHE_AUTH_FAILURE_AFTER_READ; | 1417 return ERR_CACHE_AUTH_FAILURE_AFTER_READ; |
| 1411 } | 1418 } |
| 1412 | 1419 |
| 1413 new_response_ = new_response; | 1420 new_response_ = new_response; |
| 1414 if (!ValidatePartialResponse() && !auth_response_.headers.get()) { | 1421 if (!ValidatePartialResponse() && !auth_response_.headers.get()) { |
| 1415 // Something went wrong with this request and we have to restart it. | 1422 // Something went wrong with this request and we have to restart it. |
| 1416 // If we have an authentication response, we are exposed to weird things | 1423 // If we have an authentication response, we are exposed to weird things |
| 1417 // hapenning if the user cancels the authentication before we receive | 1424 // hapenning if the user cancels the authentication before we receive |
| 1418 // the new response. | 1425 // the new response. |
| 1419 net_log_.AddEvent(NetLog::TYPE_HTTP_CACHE_RE_SEND_PARTIAL_REQUEST); | 1426 net_log_.AddEvent(NetLog::TYPE_HTTP_CACHE_RE_SEND_PARTIAL_REQUEST); |
| 1420 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 1427 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 1421 response_ = HttpResponseInfo(); | 1428 SetResponse(HttpResponseInfo()); |
| 1422 ResetNetworkTransaction(); | 1429 ResetNetworkTransaction(); |
| 1423 new_response_ = NULL; | 1430 new_response_ = NULL; |
| 1424 next_state_ = STATE_SEND_REQUEST; | 1431 next_state_ = STATE_SEND_REQUEST; |
| 1425 return OK; | 1432 return OK; |
| 1426 } | 1433 } |
| 1427 | 1434 |
| 1428 if (handling_206_ && mode_ == READ_WRITE && !truncated_ && !is_sparse_) { | 1435 if (handling_206_ && mode_ == READ_WRITE && !truncated_ && !is_sparse_) { |
| 1429 // We have stored the full entry, but it changed and the server is | 1436 // We have stored the full entry, but it changed and the server is |
| 1430 // sending a range. We have to delete the old entry. | 1437 // sending a range. We have to delete the old entry. |
| 1431 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 1438 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 1432 DoneWritingToEntry(false); | 1439 DoneWritingToEntry(false); |
| 1433 } | 1440 } |
| 1434 | 1441 |
| 1435 if (mode_ == WRITE && | 1442 if (mode_ == WRITE && |
| 1436 transaction_pattern_ != PATTERN_ENTRY_CANT_CONDITIONALIZE) { | 1443 cache_entry_status_ != CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE) { |
| 1437 UpdateTransactionPattern(PATTERN_ENTRY_NOT_CACHED); | 1444 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_NOT_IN_CACHE); |
| 1438 } | 1445 } |
| 1439 | 1446 |
| 1440 // Invalidate any cached GET with a successful PUT or DELETE. | 1447 // Invalidate any cached GET with a successful PUT or DELETE. |
| 1441 if (mode_ == WRITE && | 1448 if (mode_ == WRITE && |
| 1442 (request_->method == "PUT" || request_->method == "DELETE")) { | 1449 (request_->method == "PUT" || request_->method == "DELETE")) { |
| 1443 if (NonErrorResponse(new_response->headers->response_code())) { | 1450 if (NonErrorResponse(new_response->headers->response_code())) { |
| 1444 int ret = cache_->DoomEntry(cache_key_, NULL); | 1451 int ret = cache_->DoomEntry(cache_key_, NULL); |
| 1445 DCHECK_EQ(OK, ret); | 1452 DCHECK_EQ(OK, ret); |
| 1446 } | 1453 } |
| 1447 cache_->DoneWritingToEntry(entry_, true); | 1454 cache_->DoneWritingToEntry(entry_, true); |
| 1448 entry_ = NULL; | 1455 entry_ = NULL; |
| 1449 mode_ = NONE; | 1456 mode_ = NONE; |
| 1450 } | 1457 } |
| 1451 | 1458 |
| 1452 // Invalidate any cached GET with a successful POST. | 1459 // Invalidate any cached GET with a successful POST. |
| 1453 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) && | 1460 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) && |
| 1454 request_->method == "POST" && | 1461 request_->method == "POST" && |
| 1455 NonErrorResponse(new_response->headers->response_code())) { | 1462 NonErrorResponse(new_response->headers->response_code())) { |
| 1456 cache_->DoomMainEntryForUrl(request_->url); | 1463 cache_->DoomMainEntryForUrl(request_->url); |
| 1457 } | 1464 } |
| 1458 | 1465 |
| 1459 RecordNoStoreHeaderHistogram(request_->load_flags, new_response); | 1466 RecordNoStoreHeaderHistogram(request_->load_flags, new_response); |
| 1460 | 1467 |
| 1461 if (new_response_->headers->response_code() == 416 && | 1468 if (new_response_->headers->response_code() == 416 && |
| 1462 (request_->method == "GET" || request_->method == "POST")) { | 1469 (request_->method == "GET" || request_->method == "POST")) { |
| 1463 // If there is an active entry it may be destroyed with this transaction. | 1470 // If there is an active entry it may be destroyed with this transaction. |
| 1464 response_ = *new_response_; | 1471 SetResponse(*new_response_); |
| 1465 return OK; | 1472 return OK; |
| 1466 } | 1473 } |
| 1467 | 1474 |
| 1468 // Are we expecting a response to a conditional query? | 1475 // Are we expecting a response to a conditional query? |
| 1469 if (mode_ == READ_WRITE || mode_ == UPDATE) { | 1476 if (mode_ == READ_WRITE || mode_ == UPDATE) { |
| 1470 if (new_response->headers->response_code() == 304 || handling_206_) { | 1477 if (new_response->headers->response_code() == 304 || handling_206_) { |
| 1471 UpdateTransactionPattern(PATTERN_ENTRY_VALIDATED); | 1478 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_VALIDATED); |
| 1472 next_state_ = STATE_UPDATE_CACHED_RESPONSE; | 1479 next_state_ = STATE_UPDATE_CACHED_RESPONSE; |
| 1473 return OK; | 1480 return OK; |
| 1474 } | 1481 } |
| 1475 UpdateTransactionPattern(PATTERN_ENTRY_UPDATED); | 1482 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_UPDATED); |
| 1476 mode_ = WRITE; | 1483 mode_ = WRITE; |
| 1477 } | 1484 } |
| 1478 | 1485 |
| 1479 next_state_ = STATE_OVERWRITE_CACHED_RESPONSE; | 1486 next_state_ = STATE_OVERWRITE_CACHED_RESPONSE; |
| 1480 return OK; | 1487 return OK; |
| 1481 } | 1488 } |
| 1482 | 1489 |
| 1483 // We received 304 or 206 and we want to update the cached response headers. | 1490 // We received 304 or 206 and we want to update the cached response headers. |
| 1484 int HttpCache::Transaction::DoUpdateCachedResponse() { | 1491 int HttpCache::Transaction::DoUpdateCachedResponse() { |
| 1485 next_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE; | 1492 next_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 int HttpCache::Transaction::DoOverwriteCachedResponse() { | 1571 int HttpCache::Transaction::DoOverwriteCachedResponse() { |
| 1565 if (mode_ & READ) { | 1572 if (mode_ & READ) { |
| 1566 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; | 1573 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; |
| 1567 return OK; | 1574 return OK; |
| 1568 } | 1575 } |
| 1569 | 1576 |
| 1570 // We change the value of Content-Length for partial content. | 1577 // We change the value of Content-Length for partial content. |
| 1571 if (handling_206_ && partial_) | 1578 if (handling_206_ && partial_) |
| 1572 partial_->FixContentLength(new_response_->headers.get()); | 1579 partial_->FixContentLength(new_response_->headers.get()); |
| 1573 | 1580 |
| 1574 response_ = *new_response_; | 1581 SetResponse(*new_response_); |
| 1575 | 1582 |
| 1576 if (request_->method == "HEAD") { | 1583 if (request_->method == "HEAD") { |
| 1577 // This response is replacing the cached one. | 1584 // This response is replacing the cached one. |
| 1578 DoneWritingToEntry(false); | 1585 DoneWritingToEntry(false); |
| 1579 mode_ = NONE; | 1586 mode_ = NONE; |
| 1580 new_response_ = NULL; | 1587 new_response_ = NULL; |
| 1581 return OK; | 1588 return OK; |
| 1582 } | 1589 } |
| 1583 | 1590 |
| 1584 if (handling_206_ && !CanResume(false)) { | 1591 if (handling_206_ && !CanResume(false)) { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_DATA, | 1744 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_DATA, |
| 1738 result); | 1745 result); |
| 1739 } | 1746 } |
| 1740 | 1747 |
| 1741 if (!cache_.get()) | 1748 if (!cache_.get()) |
| 1742 return ERR_UNEXPECTED; | 1749 return ERR_UNEXPECTED; |
| 1743 | 1750 |
| 1744 if (partial_) { | 1751 if (partial_) { |
| 1745 // Partial requests are confusing to report in histograms because they may | 1752 // Partial requests are confusing to report in histograms because they may |
| 1746 // have multiple underlying requests. | 1753 // have multiple underlying requests. |
| 1747 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 1754 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 1748 return DoPartialCacheReadCompleted(result); | 1755 return DoPartialCacheReadCompleted(result); |
| 1749 } | 1756 } |
| 1750 | 1757 |
| 1751 if (result > 0) { | 1758 if (result > 0) { |
| 1752 read_offset_ += result; | 1759 read_offset_ += result; |
| 1753 } else if (result == 0) { // End of file. | 1760 } else if (result == 0) { // End of file. |
| 1754 RecordHistograms(); | 1761 RecordHistograms(); |
| 1755 cache_->DoneReadingFromEntry(entry_, this); | 1762 cache_->DoneReadingFromEntry(entry_, this); |
| 1756 entry_ = NULL; | 1763 entry_ = NULL; |
| 1757 } else { | 1764 } else { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 | 1913 |
| 1907 // If there is more than one validation header, we can't treat this request as | 1914 // If there is more than one validation header, we can't treat this request as |
| 1908 // a cache validation, since we don't know for sure which header the server | 1915 // a cache validation, since we don't know for sure which header the server |
| 1909 // will give us a response for (and they could be contradictory). | 1916 // will give us a response for (and they could be contradictory). |
| 1910 if (external_validation_error) { | 1917 if (external_validation_error) { |
| 1911 LOG(WARNING) << "Multiple or malformed validation headers found."; | 1918 LOG(WARNING) << "Multiple or malformed validation headers found."; |
| 1912 effective_load_flags_ |= LOAD_DISABLE_CACHE; | 1919 effective_load_flags_ |= LOAD_DISABLE_CACHE; |
| 1913 } | 1920 } |
| 1914 | 1921 |
| 1915 if (range_found && !(effective_load_flags_ & LOAD_DISABLE_CACHE)) { | 1922 if (range_found && !(effective_load_flags_ & LOAD_DISABLE_CACHE)) { |
| 1916 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 1923 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 1917 partial_.reset(new PartialData); | 1924 partial_.reset(new PartialData); |
| 1918 if (request_->method == "GET" && partial_->Init(request_->extra_headers)) { | 1925 if (request_->method == "GET" && partial_->Init(request_->extra_headers)) { |
| 1919 // We will be modifying the actual range requested to the server, so | 1926 // We will be modifying the actual range requested to the server, so |
| 1920 // let's remove the header here. | 1927 // let's remove the header here. |
| 1921 custom_request_.reset(new HttpRequestInfo(*request_)); | 1928 custom_request_.reset(new HttpRequestInfo(*request_)); |
| 1922 custom_request_->extra_headers.RemoveHeader(HttpRequestHeaders::kRange); | 1929 custom_request_->extra_headers.RemoveHeader(HttpRequestHeaders::kRange); |
| 1923 request_ = custom_request_.get(); | 1930 request_ = custom_request_.get(); |
| 1924 partial_->SetHeaders(custom_request_->extra_headers); | 1931 partial_->SetHeaders(custom_request_->extra_headers); |
| 1925 } else { | 1932 } else { |
| 1926 // The range is invalid or we cannot handle it properly. | 1933 // The range is invalid or we cannot handle it properly. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 | 2006 |
| 2000 // Bail out! | 2007 // Bail out! |
| 2001 next_state_ = STATE_SEND_REQUEST; | 2008 next_state_ = STATE_SEND_REQUEST; |
| 2002 mode_ = NONE; | 2009 mode_ = NONE; |
| 2003 return OK; | 2010 return OK; |
| 2004 } | 2011 } |
| 2005 | 2012 |
| 2006 if (truncated_) { | 2013 if (truncated_) { |
| 2007 // Truncated entries can cause partial gets, so we shouldn't record this | 2014 // Truncated entries can cause partial gets, so we shouldn't record this |
| 2008 // load in histograms. | 2015 // load in histograms. |
| 2009 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 2016 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 2010 skip_validation = !partial_->initial_validation(); | 2017 skip_validation = !partial_->initial_validation(); |
| 2011 } | 2018 } |
| 2012 | 2019 |
| 2013 if (partial_ && (is_sparse_ || truncated_) && | 2020 if (partial_ && (is_sparse_ || truncated_) && |
| 2014 (!partial_->IsCurrentRangeCached() || invalid_range_)) { | 2021 (!partial_->IsCurrentRangeCached() || invalid_range_)) { |
| 2015 // Force revalidation for sparse or truncated entries. Note that we don't | 2022 // Force revalidation for sparse or truncated entries. Note that we don't |
| 2016 // want to ignore the regular validation logic just because a byte range was | 2023 // want to ignore the regular validation logic just because a byte range was |
| 2017 // part of the request. | 2024 // part of the request. |
| 2018 skip_validation = false; | 2025 skip_validation = false; |
| 2019 } | 2026 } |
| 2020 | 2027 |
| 2021 if (skip_validation) { | 2028 if (skip_validation) { |
| 2022 UpdateTransactionPattern(PATTERN_ENTRY_USED); | 2029 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_USED); |
| 2023 return SetupEntryForRead(); | 2030 return SetupEntryForRead(); |
| 2024 } else { | 2031 } else { |
| 2025 // Make the network request conditional, to see if we may reuse our cached | 2032 // Make the network request conditional, to see if we may reuse our cached |
| 2026 // response. If we cannot do so, then we just resort to a normal fetch. | 2033 // response. If we cannot do so, then we just resort to a normal fetch. |
| 2027 // Our mode remains READ_WRITE for a conditional request. Even if the | 2034 // Our mode remains READ_WRITE for a conditional request. Even if the |
| 2028 // conditionalization fails, we don't switch to WRITE mode until we | 2035 // conditionalization fails, we don't switch to WRITE mode until we |
| 2029 // know we won't be falling back to using the cache entry in the | 2036 // know we won't be falling back to using the cache entry in the |
| 2030 // LOAD_FROM_CACHE_IF_OFFLINE case. | 2037 // LOAD_FROM_CACHE_IF_OFFLINE case. |
| 2031 if (!ConditionalizeRequest()) { | 2038 if (!ConditionalizeRequest()) { |
| 2032 couldnt_conditionalize_request_ = true; | 2039 couldnt_conditionalize_request_ = true; |
| 2033 UpdateTransactionPattern(PATTERN_ENTRY_CANT_CONDITIONALIZE); | 2040 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE); |
| 2034 if (partial_) | 2041 if (partial_) |
| 2035 return DoRestartPartialRequest(); | 2042 return DoRestartPartialRequest(); |
| 2036 | 2043 |
| 2037 DCHECK_NE(206, response_.headers->response_code()); | 2044 DCHECK_NE(206, response_.headers->response_code()); |
| 2038 } | 2045 } |
| 2039 next_state_ = STATE_SEND_REQUEST; | 2046 next_state_ = STATE_SEND_REQUEST; |
| 2040 } | 2047 } |
| 2041 return OK; | 2048 return OK; |
| 2042 } | 2049 } |
| 2043 | 2050 |
| 2044 int HttpCache::Transaction::BeginPartialCacheValidation() { | 2051 int HttpCache::Transaction::BeginPartialCacheValidation() { |
| 2045 DCHECK_EQ(mode_, READ_WRITE); | 2052 DCHECK_EQ(mode_, READ_WRITE); |
| 2046 | 2053 |
| 2047 if (response_.headers->response_code() != 206 && !partial_ && !truncated_) | 2054 if (response_.headers->response_code() != 206 && !partial_ && !truncated_) |
| 2048 return BeginCacheValidation(); | 2055 return BeginCacheValidation(); |
| 2049 | 2056 |
| 2050 // Partial requests should not be recorded in histograms. | 2057 // Partial requests should not be recorded in histograms. |
| 2051 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 2058 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 2052 if (request_->method == "HEAD") | 2059 if (request_->method == "HEAD") |
| 2053 return BeginCacheValidation(); | 2060 return BeginCacheValidation(); |
| 2054 | 2061 |
| 2055 if (!range_requested_) { | 2062 if (!range_requested_) { |
| 2056 // The request is not for a range, but we have stored just ranges. | 2063 // The request is not for a range, but we have stored just ranges. |
| 2057 | 2064 |
| 2058 partial_.reset(new PartialData()); | 2065 partial_.reset(new PartialData()); |
| 2059 partial_->SetHeaders(request_->extra_headers); | 2066 partial_->SetHeaders(request_->extra_headers); |
| 2060 if (!custom_request_.get()) { | 2067 if (!custom_request_.get()) { |
| 2061 custom_request_.reset(new HttpRequestInfo(*request_)); | 2068 custom_request_.reset(new HttpRequestInfo(*request_)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 std::string validator; | 2106 std::string validator; |
| 2100 response_.headers->EnumerateHeader( | 2107 response_.headers->EnumerateHeader( |
| 2101 NULL, | 2108 NULL, |
| 2102 kValidationHeaders[i].related_response_header_name, | 2109 kValidationHeaders[i].related_response_header_name, |
| 2103 &validator); | 2110 &validator); |
| 2104 | 2111 |
| 2105 if (response_.headers->response_code() != 200 || truncated_ || | 2112 if (response_.headers->response_code() != 200 || truncated_ || |
| 2106 validator.empty() || validator != external_validation_.values[i]) { | 2113 validator.empty() || validator != external_validation_.values[i]) { |
| 2107 // The externally conditionalized request is not a validation request | 2114 // The externally conditionalized request is not a validation request |
| 2108 // for our existing cache entry. Proceed with caching disabled. | 2115 // for our existing cache entry. Proceed with caching disabled. |
| 2109 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 2116 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 2110 DoneWritingToEntry(true); | 2117 DoneWritingToEntry(true); |
| 2111 } | 2118 } |
| 2112 } | 2119 } |
| 2113 | 2120 |
| 2114 // TODO(ricea): This calculation is expensive to perform just to collect | 2121 // TODO(ricea): This calculation is expensive to perform just to collect |
| 2115 // statistics. Either remove it or use the result, depending on the result of | 2122 // statistics. Either remove it or use the result, depending on the result of |
| 2116 // the experiment. | 2123 // the experiment. |
| 2117 ExternallyConditionalizedType type = | 2124 ExternallyConditionalizedType type = |
| 2118 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE; | 2125 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE; |
| 2119 if (mode_ == NONE) | 2126 if (mode_ == NONE) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2358 // server is ok with the request, delete the entry, otherwise just ignore | 2365 // server is ok with the request, delete the entry, otherwise just ignore |
| 2359 // this request | 2366 // this request |
| 2360 DCHECK(!reading_); | 2367 DCHECK(!reading_); |
| 2361 if (partial_response || response_code == 200) { | 2368 if (partial_response || response_code == 200) { |
| 2362 DoomPartialEntry(true); | 2369 DoomPartialEntry(true); |
| 2363 mode_ = NONE; | 2370 mode_ = NONE; |
| 2364 } else { | 2371 } else { |
| 2365 if (response_code == 304) { | 2372 if (response_code == 304) { |
| 2366 // Change the response code of the request to be 416 (Requested range | 2373 // Change the response code of the request to be 416 (Requested range |
| 2367 // not satisfiable). | 2374 // not satisfiable). |
| 2368 response_ = *new_response_; | 2375 SetResponse(*new_response_); |
| 2369 partial_->FixResponseHeaders(response_.headers.get(), false); | 2376 partial_->FixResponseHeaders(response_.headers.get(), false); |
| 2370 } | 2377 } |
| 2371 IgnoreRangeRequest(); | 2378 IgnoreRangeRequest(); |
| 2372 } | 2379 } |
| 2373 return true; | 2380 return true; |
| 2374 } | 2381 } |
| 2375 | 2382 |
| 2376 if (!partial_) { | 2383 if (!partial_) { |
| 2377 // We are not expecting 206 but we may have one. | 2384 // We are not expecting 206 but we may have one. |
| 2378 if (partial_response) | 2385 if (partial_response) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 } | 2425 } |
| 2419 | 2426 |
| 2420 // 304 is not expected here, but we'll spare the entry (unless it was | 2427 // 304 is not expected here, but we'll spare the entry (unless it was |
| 2421 // truncated). | 2428 // truncated). |
| 2422 if (truncated_) | 2429 if (truncated_) |
| 2423 failure = true; | 2430 failure = true; |
| 2424 } | 2431 } |
| 2425 | 2432 |
| 2426 if (failure) { | 2433 if (failure) { |
| 2427 // We cannot truncate this entry, it has to be deleted. | 2434 // We cannot truncate this entry, it has to be deleted. |
| 2428 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 2435 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 2429 mode_ = NONE; | 2436 mode_ = NONE; |
| 2430 if (is_sparse_ || truncated_) { | 2437 if (is_sparse_ || truncated_) { |
| 2431 // There was something cached to start with, either sparsed data (206), or | 2438 // There was something cached to start with, either sparsed data (206), or |
| 2432 // a truncated 200, which means that we probably modified the request, | 2439 // a truncated 200, which means that we probably modified the request, |
| 2433 // adding a byte range or modifying the range requested by the caller. | 2440 // adding a byte range or modifying the range requested by the caller. |
| 2434 if (!reading_ && !partial_->IsLastRange()) { | 2441 if (!reading_ && !partial_->IsLastRange()) { |
| 2435 // We have not returned anything to the caller yet so it should be safe | 2442 // We have not returned anything to the caller yet so it should be safe |
| 2436 // to issue another network request, this time without us messing up the | 2443 // to issue another network request, this time without us messing up the |
| 2437 // headers. | 2444 // headers. |
| 2438 ResetPartialState(true); | 2445 ResetPartialState(true); |
| 2439 return false; | 2446 return false; |
| 2440 } | 2447 } |
| 2441 LOG(WARNING) << "Failed to revalidate partial entry"; | 2448 LOG(WARNING) << "Failed to revalidate partial entry"; |
| 2442 } | 2449 } |
| 2443 DoomPartialEntry(true); | 2450 DoomPartialEntry(true); |
| 2444 return true; | 2451 return true; |
| 2445 } | 2452 } |
| 2446 | 2453 |
| 2447 IgnoreRangeRequest(); | 2454 IgnoreRangeRequest(); |
| 2448 return true; | 2455 return true; |
| 2449 } | 2456 } |
| 2450 | 2457 |
| 2451 void HttpCache::Transaction::IgnoreRangeRequest() { | 2458 void HttpCache::Transaction::IgnoreRangeRequest() { |
| 2452 // We have a problem. We may or may not be reading already (in which case we | 2459 // We have a problem. We may or may not be reading already (in which case we |
| 2453 // returned the headers), but we'll just pretend that this request is not | 2460 // returned the headers), but we'll just pretend that this request is not |
| 2454 // using the cache and see what happens. Most likely this is the first | 2461 // using the cache and see what happens. Most likely this is the first |
| 2455 // response from the server (it's not changing its mind midway, right?). | 2462 // response from the server (it's not changing its mind midway, right?). |
| 2456 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 2463 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); |
| 2457 if (mode_ & WRITE) | 2464 if (mode_ & WRITE) |
| 2458 DoneWritingToEntry(mode_ != WRITE); | 2465 DoneWritingToEntry(mode_ != WRITE); |
| 2459 else if (mode_ & READ && entry_) | 2466 else if (mode_ & READ && entry_) |
| 2460 cache_->DoneReadingFromEntry(entry_, this); | 2467 cache_->DoneReadingFromEntry(entry_, this); |
| 2461 | 2468 |
| 2462 partial_.reset(NULL); | 2469 partial_.reset(NULL); |
| 2463 entry_ = NULL; | 2470 entry_ = NULL; |
| 2464 mode_ = NONE; | 2471 mode_ = NONE; |
| 2465 } | 2472 } |
| 2466 | 2473 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2720 // PartialData::ResponseHeadersOK(). | 2727 // PartialData::ResponseHeadersOK(). |
| 2721 if (response_.headers->GetContentLength() <= 0 || | 2728 if (response_.headers->GetContentLength() <= 0 || |
| 2722 response_.headers->HasHeaderValue("Accept-Ranges", "none") || | 2729 response_.headers->HasHeaderValue("Accept-Ranges", "none") || |
| 2723 !response_.headers->HasStrongValidators()) { | 2730 !response_.headers->HasStrongValidators()) { |
| 2724 return false; | 2731 return false; |
| 2725 } | 2732 } |
| 2726 | 2733 |
| 2727 return true; | 2734 return true; |
| 2728 } | 2735 } |
| 2729 | 2736 |
| 2730 void HttpCache::Transaction::UpdateTransactionPattern( | 2737 void HttpCache::Transaction::SetResponse(const HttpResponseInfo& response) { |
| 2731 TransactionPattern new_transaction_pattern) { | 2738 response_ = response; |
| 2732 if (transaction_pattern_ == PATTERN_NOT_COVERED) | 2739 SyncCacheEntryStatusToResponse(); |
| 2740 } |
| 2741 |
| 2742 void HttpCache::Transaction::SetAuthResponse( |
| 2743 const HttpResponseInfo& auth_response) { |
| 2744 auth_response_ = auth_response; |
| 2745 SyncCacheEntryStatusToResponse(); |
| 2746 } |
| 2747 |
| 2748 void HttpCache::Transaction::UpdateCacheEntryStatus( |
| 2749 CacheEntryStatus new_cache_entry_status) { |
| 2750 DCHECK_NE(CacheEntryStatus::ENTRY_UNDEFINED, new_cache_entry_status); |
| 2751 if (cache_entry_status_ == CacheEntryStatus::ENTRY_OTHER) |
| 2733 return; | 2752 return; |
| 2734 DCHECK(transaction_pattern_ == PATTERN_UNDEFINED || | 2753 DCHECK(cache_entry_status_ == CacheEntryStatus::ENTRY_UNDEFINED || |
| 2735 new_transaction_pattern == PATTERN_NOT_COVERED); | 2754 new_cache_entry_status == CacheEntryStatus::ENTRY_OTHER); |
| 2736 transaction_pattern_ = new_transaction_pattern; | 2755 cache_entry_status_ = new_cache_entry_status; |
| 2756 SyncCacheEntryStatusToResponse(); |
| 2757 } |
| 2758 |
| 2759 void HttpCache::Transaction::SyncCacheEntryStatusToResponse() { |
| 2760 if (cache_entry_status_ == CacheEntryStatus::ENTRY_UNDEFINED) |
| 2761 return; |
| 2762 response_.cache_entry_status = cache_entry_status_; |
| 2763 if (auth_response_.headers.get()) { |
| 2764 auth_response_.cache_entry_status = cache_entry_status_; |
| 2765 } |
| 2737 } | 2766 } |
| 2738 | 2767 |
| 2739 void HttpCache::Transaction::RecordHistograms() { | 2768 void HttpCache::Transaction::RecordHistograms() { |
| 2740 DCHECK_NE(PATTERN_UNDEFINED, transaction_pattern_); | 2769 DCHECK_NE(CacheEntryStatus::ENTRY_UNDEFINED, cache_entry_status_); |
| 2741 if (!cache_.get() || !cache_->GetCurrentBackend() || | 2770 if (!cache_.get() || !cache_->GetCurrentBackend() || |
| 2742 cache_->GetCurrentBackend()->GetCacheType() != DISK_CACHE || | 2771 cache_->GetCurrentBackend()->GetCacheType() != DISK_CACHE || |
| 2743 cache_->mode() != NORMAL || request_->method != "GET") { | 2772 cache_->mode() != NORMAL || request_->method != "GET") { |
| 2744 return; | 2773 return; |
| 2745 } | 2774 } |
| 2746 | 2775 |
| 2747 bool validation_request = transaction_pattern_ == PATTERN_ENTRY_VALIDATED || | 2776 bool validation_request = |
| 2748 transaction_pattern_ == PATTERN_ENTRY_UPDATED; | 2777 cache_entry_status_ == CacheEntryStatus::ENTRY_VALIDATED || |
| 2778 cache_entry_status_ == CacheEntryStatus::ENTRY_UPDATED; |
| 2749 | 2779 |
| 2750 bool stale_request = | 2780 bool stale_request = |
| 2751 validation_cause_ == VALIDATION_CAUSE_STALE && | 2781 validation_cause_ == VALIDATION_CAUSE_STALE && |
| 2752 (validation_request || | 2782 (validation_request || |
| 2753 transaction_pattern_ == PATTERN_ENTRY_CANT_CONDITIONALIZE); | 2783 cache_entry_status_ == CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE); |
| 2754 int64_t freshness_periods_since_last_used = 0; | 2784 int64_t freshness_periods_since_last_used = 0; |
| 2755 | 2785 |
| 2756 if (stale_request) { | 2786 if (stale_request) { |
| 2757 // For stale entries, record how many freshness periods have elapsed since | 2787 // For stale entries, record how many freshness periods have elapsed since |
| 2758 // the entry was last used. | 2788 // the entry was last used. |
| 2759 DCHECK(!open_entry_last_used_.is_null()); | 2789 DCHECK(!open_entry_last_used_.is_null()); |
| 2760 DCHECK(!stale_entry_freshness_.is_zero()); | 2790 DCHECK(!stale_entry_freshness_.is_zero()); |
| 2761 base::TimeDelta time_since_use = base::Time::Now() - open_entry_last_used_; | 2791 base::TimeDelta time_since_use = base::Time::Now() - open_entry_last_used_; |
| 2762 freshness_periods_since_last_used = | 2792 freshness_periods_since_last_used = |
| 2763 (time_since_use * 1000) / stale_entry_freshness_; | 2793 (time_since_use * 1000) / stale_entry_freshness_; |
| 2764 | 2794 |
| 2765 UMA_HISTOGRAM_COUNTS("HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed", | 2795 UMA_HISTOGRAM_COUNTS("HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed", |
| 2766 freshness_periods_since_last_used); | 2796 freshness_periods_since_last_used); |
| 2767 | 2797 |
| 2768 if (validation_request) { | 2798 if (validation_request) { |
| 2769 int64_t age_in_freshness_periods = | 2799 int64_t age_in_freshness_periods = |
| 2770 (stale_entry_age_ * 100) / stale_entry_freshness_; | 2800 (stale_entry_age_ * 100) / stale_entry_freshness_; |
| 2771 if (transaction_pattern_ == PATTERN_ENTRY_VALIDATED) { | 2801 if (cache_entry_status_ == CacheEntryStatus::ENTRY_VALIDATED) { |
| 2772 UMA_HISTOGRAM_COUNTS("HttpCache.StaleEntry.Validated.Age", | 2802 UMA_HISTOGRAM_COUNTS("HttpCache.StaleEntry.Validated.Age", |
| 2773 stale_entry_age_.InSeconds()); | 2803 stale_entry_age_.InSeconds()); |
| 2774 UMA_HISTOGRAM_COUNTS( | 2804 UMA_HISTOGRAM_COUNTS( |
| 2775 "HttpCache.StaleEntry.Validated.AgeInFreshnessPeriods", | 2805 "HttpCache.StaleEntry.Validated.AgeInFreshnessPeriods", |
| 2776 age_in_freshness_periods); | 2806 age_in_freshness_periods); |
| 2777 | 2807 |
| 2778 } else { | 2808 } else { |
| 2779 UMA_HISTOGRAM_COUNTS("HttpCache.StaleEntry.Updated.Age", | 2809 UMA_HISTOGRAM_COUNTS("HttpCache.StaleEntry.Updated.Age", |
| 2780 stale_entry_age_.InSeconds()); | 2810 stale_entry_age_.InSeconds()); |
| 2781 UMA_HISTOGRAM_COUNTS( | 2811 UMA_HISTOGRAM_COUNTS( |
| 2782 "HttpCache.StaleEntry.Updated.AgeInFreshnessPeriods", | 2812 "HttpCache.StaleEntry.Updated.AgeInFreshnessPeriods", |
| 2783 age_in_freshness_periods); | 2813 age_in_freshness_periods); |
| 2784 } | 2814 } |
| 2785 } | 2815 } |
| 2786 } | 2816 } |
| 2787 | 2817 |
| 2788 std::string mime_type; | 2818 std::string mime_type; |
| 2789 HttpResponseHeaders* response_headers = GetResponseInfo()->headers.get(); | 2819 HttpResponseHeaders* response_headers = GetResponseInfo()->headers.get(); |
| 2790 if (response_headers && response_headers->GetMimeType(&mime_type)) { | 2820 if (response_headers && response_headers->GetMimeType(&mime_type)) { |
| 2791 // Record the cache pattern by resource type. The type is inferred by | 2821 // Record the cache pattern by resource type. The type is inferred by |
| 2792 // response header mime type, which could be incorrect, so this is just an | 2822 // response header mime type, which could be incorrect, so this is just an |
| 2793 // estimate. | 2823 // estimate. |
| 2794 if (mime_type == "text/html" && (request_->load_flags & LOAD_MAIN_FRAME)) { | 2824 if (mime_type == "text/html" && (request_->load_flags & LOAD_MAIN_FRAME)) { |
| 2795 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.MainFrameHTML", | 2825 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.MainFrameHTML", |
| 2796 transaction_pattern_, PATTERN_MAX); | 2826 cache_entry_status_, |
| 2827 CacheEntryStatus::ENTRY_MAX); |
| 2797 if (validation_request) { | 2828 if (validation_request) { |
| 2798 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.MainFrameHTML", | 2829 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.MainFrameHTML", |
| 2799 validation_cause_, VALIDATION_CAUSE_MAX); | 2830 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2800 } | 2831 } |
| 2801 if (stale_request) { | 2832 if (stale_request) { |
| 2802 UMA_HISTOGRAM_COUNTS( | 2833 UMA_HISTOGRAM_COUNTS( |
| 2803 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.MainFrameHTML", | 2834 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.MainFrameHTML", |
| 2804 freshness_periods_since_last_used); | 2835 freshness_periods_since_last_used); |
| 2805 } | 2836 } |
| 2806 } else if (mime_type == "text/html") { | 2837 } else if (mime_type == "text/html") { |
| 2807 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.NonMainFrameHTML", | 2838 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.NonMainFrameHTML", |
| 2808 transaction_pattern_, PATTERN_MAX); | 2839 cache_entry_status_, |
| 2840 CacheEntryStatus::ENTRY_MAX); |
| 2809 if (validation_request) { | 2841 if (validation_request) { |
| 2810 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.NonMainFrameHTML", | 2842 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.NonMainFrameHTML", |
| 2811 validation_cause_, VALIDATION_CAUSE_MAX); | 2843 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2812 } | 2844 } |
| 2813 if (stale_request) { | 2845 if (stale_request) { |
| 2814 UMA_HISTOGRAM_COUNTS( | 2846 UMA_HISTOGRAM_COUNTS( |
| 2815 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed." | 2847 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed." |
| 2816 "NonMainFrameHTML", | 2848 "NonMainFrameHTML", |
| 2817 freshness_periods_since_last_used); | 2849 freshness_periods_since_last_used); |
| 2818 } | 2850 } |
| 2819 } else if (mime_type == "text/css") { | 2851 } else if (mime_type == "text/css") { |
| 2820 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.CSS", transaction_pattern_, | 2852 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.CSS", cache_entry_status_, |
| 2821 PATTERN_MAX); | 2853 CacheEntryStatus::ENTRY_MAX); |
| 2822 if (validation_request) { | 2854 if (validation_request) { |
| 2823 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.CSS", | 2855 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.CSS", |
| 2824 validation_cause_, VALIDATION_CAUSE_MAX); | 2856 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2825 } | 2857 } |
| 2826 if (stale_request) { | 2858 if (stale_request) { |
| 2827 UMA_HISTOGRAM_COUNTS( | 2859 UMA_HISTOGRAM_COUNTS( |
| 2828 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.CSS", | 2860 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.CSS", |
| 2829 freshness_periods_since_last_used); | 2861 freshness_periods_since_last_used); |
| 2830 } | 2862 } |
| 2831 } else if (base::StartsWith(mime_type, "image/", | 2863 } else if (base::StartsWith(mime_type, "image/", |
| 2832 base::CompareCase::SENSITIVE)) { | 2864 base::CompareCase::SENSITIVE)) { |
| 2833 int64_t content_length = response_headers->GetContentLength(); | 2865 int64_t content_length = response_headers->GetContentLength(); |
| 2834 if (content_length >= 0 && content_length < 100) { | 2866 if (content_length >= 0 && content_length < 100) { |
| 2835 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.TinyImage", | 2867 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.TinyImage", |
| 2836 transaction_pattern_, PATTERN_MAX); | 2868 cache_entry_status_, |
| 2869 CacheEntryStatus::ENTRY_MAX); |
| 2837 if (validation_request) { | 2870 if (validation_request) { |
| 2838 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.TinyImage", | 2871 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.TinyImage", |
| 2839 validation_cause_, VALIDATION_CAUSE_MAX); | 2872 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2840 } | 2873 } |
| 2841 if (stale_request) { | 2874 if (stale_request) { |
| 2842 UMA_HISTOGRAM_COUNTS( | 2875 UMA_HISTOGRAM_COUNTS( |
| 2843 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.TinyImage", | 2876 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.TinyImage", |
| 2844 freshness_periods_since_last_used); | 2877 freshness_periods_since_last_used); |
| 2845 } | 2878 } |
| 2846 } else if (content_length >= 100) { | 2879 } else if (content_length >= 100) { |
| 2847 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.NonTinyImage", | 2880 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.NonTinyImage", |
| 2848 transaction_pattern_, PATTERN_MAX); | 2881 cache_entry_status_, |
| 2882 CacheEntryStatus::ENTRY_MAX); |
| 2849 if (validation_request) { | 2883 if (validation_request) { |
| 2850 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.NonTinyImage", | 2884 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.NonTinyImage", |
| 2851 validation_cause_, VALIDATION_CAUSE_MAX); | 2885 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2852 } | 2886 } |
| 2853 if (stale_request) { | 2887 if (stale_request) { |
| 2854 UMA_HISTOGRAM_COUNTS( | 2888 UMA_HISTOGRAM_COUNTS( |
| 2855 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.NonTinyImage", | 2889 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.NonTinyImage", |
| 2856 freshness_periods_since_last_used); | 2890 freshness_periods_since_last_used); |
| 2857 } | 2891 } |
| 2858 } | 2892 } |
| 2859 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.Image", transaction_pattern_, | 2893 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.Image", cache_entry_status_, |
| 2860 PATTERN_MAX); | 2894 CacheEntryStatus::ENTRY_MAX); |
| 2861 if (validation_request) { | 2895 if (validation_request) { |
| 2862 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.Image", | 2896 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.Image", |
| 2863 validation_cause_, VALIDATION_CAUSE_MAX); | 2897 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2864 } | 2898 } |
| 2865 if (stale_request) { | 2899 if (stale_request) { |
| 2866 UMA_HISTOGRAM_COUNTS( | 2900 UMA_HISTOGRAM_COUNTS( |
| 2867 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.Image", | 2901 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.Image", |
| 2868 freshness_periods_since_last_used); | 2902 freshness_periods_since_last_used); |
| 2869 } | 2903 } |
| 2870 } else if (base::EndsWith(mime_type, "javascript", | 2904 } else if (base::EndsWith(mime_type, "javascript", |
| 2871 base::CompareCase::SENSITIVE) || | 2905 base::CompareCase::SENSITIVE) || |
| 2872 base::EndsWith(mime_type, "ecmascript", | 2906 base::EndsWith(mime_type, "ecmascript", |
| 2873 base::CompareCase::SENSITIVE)) { | 2907 base::CompareCase::SENSITIVE)) { |
| 2874 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.JavaScript", | 2908 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.JavaScript", |
| 2875 transaction_pattern_, PATTERN_MAX); | 2909 cache_entry_status_, |
| 2910 CacheEntryStatus::ENTRY_MAX); |
| 2876 if (validation_request) { | 2911 if (validation_request) { |
| 2877 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.JavaScript", | 2912 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.JavaScript", |
| 2878 validation_cause_, VALIDATION_CAUSE_MAX); | 2913 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2879 } | 2914 } |
| 2880 if (stale_request) { | 2915 if (stale_request) { |
| 2881 UMA_HISTOGRAM_COUNTS( | 2916 UMA_HISTOGRAM_COUNTS( |
| 2882 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.JavaScript", | 2917 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.JavaScript", |
| 2883 freshness_periods_since_last_used); | 2918 freshness_periods_since_last_used); |
| 2884 } | 2919 } |
| 2885 } else if (mime_type.find("font") != std::string::npos) { | 2920 } else if (mime_type.find("font") != std::string::npos) { |
| 2886 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.Font", transaction_pattern_, | 2921 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.Font", cache_entry_status_, |
| 2887 PATTERN_MAX); | 2922 CacheEntryStatus::ENTRY_MAX); |
| 2888 if (validation_request) { | 2923 if (validation_request) { |
| 2889 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.Font", | 2924 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.Font", |
| 2890 validation_cause_, VALIDATION_CAUSE_MAX); | 2925 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2891 } | 2926 } |
| 2892 if (stale_request) { | 2927 if (stale_request) { |
| 2893 UMA_HISTOGRAM_COUNTS( | 2928 UMA_HISTOGRAM_COUNTS( |
| 2894 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.Font", | 2929 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.Font", |
| 2895 freshness_periods_since_last_used); | 2930 freshness_periods_since_last_used); |
| 2896 } | 2931 } |
| 2897 } | 2932 } |
| 2898 } | 2933 } |
| 2899 | 2934 |
| 2900 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern", transaction_pattern_, | 2935 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern", cache_entry_status_, |
| 2901 PATTERN_MAX); | 2936 CacheEntryStatus::ENTRY_MAX); |
| 2902 | 2937 |
| 2903 if (validation_request) { | 2938 if (validation_request) { |
| 2904 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause", validation_cause_, | 2939 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause", validation_cause_, |
| 2905 VALIDATION_CAUSE_MAX); | 2940 VALIDATION_CAUSE_MAX); |
| 2906 } | 2941 } |
| 2907 | 2942 |
| 2908 if (transaction_pattern_ == PATTERN_ENTRY_CANT_CONDITIONALIZE) { | 2943 if (cache_entry_status_ == CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE) { |
| 2909 UMA_HISTOGRAM_ENUMERATION("HttpCache.CantConditionalizeCause", | 2944 UMA_HISTOGRAM_ENUMERATION("HttpCache.CantConditionalizeCause", |
| 2910 validation_cause_, VALIDATION_CAUSE_MAX); | 2945 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2911 } | 2946 } |
| 2912 | 2947 |
| 2913 if (transaction_pattern_ == PATTERN_NOT_COVERED) | 2948 if (cache_entry_status_ == CacheEntryStatus::ENTRY_OTHER) |
| 2914 return; | 2949 return; |
| 2915 DCHECK(!range_requested_); | 2950 DCHECK(!range_requested_); |
| 2916 DCHECK(!first_cache_access_since_.is_null()); | 2951 DCHECK(!first_cache_access_since_.is_null()); |
| 2917 | 2952 |
| 2918 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; | 2953 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; |
| 2919 | 2954 |
| 2920 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); | 2955 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); |
| 2921 | 2956 |
| 2922 bool did_send_request = !send_request_since_.is_null(); | 2957 bool did_send_request = !send_request_since_.is_null(); |
| 2923 DCHECK( | 2958 DCHECK( |
| 2924 (did_send_request && | 2959 (did_send_request && |
| 2925 (transaction_pattern_ == PATTERN_ENTRY_NOT_CACHED || | 2960 (cache_entry_status_ == CacheEntryStatus::ENTRY_NOT_IN_CACHE || |
| 2926 transaction_pattern_ == PATTERN_ENTRY_VALIDATED || | 2961 cache_entry_status_ == CacheEntryStatus::ENTRY_VALIDATED || |
| 2927 transaction_pattern_ == PATTERN_ENTRY_UPDATED || | 2962 cache_entry_status_ == CacheEntryStatus::ENTRY_UPDATED || |
| 2928 transaction_pattern_ == PATTERN_ENTRY_CANT_CONDITIONALIZE)) || | 2963 cache_entry_status_ == CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE)) || |
| 2929 (!did_send_request && transaction_pattern_ == PATTERN_ENTRY_USED)); | 2964 (!did_send_request && |
| 2965 cache_entry_status_ == CacheEntryStatus::ENTRY_USED)); |
| 2930 | 2966 |
| 2931 if (!did_send_request) { | 2967 if (!did_send_request) { |
| 2932 DCHECK(transaction_pattern_ == PATTERN_ENTRY_USED); | 2968 DCHECK(cache_entry_status_ == CacheEntryStatus::ENTRY_USED); |
| 2933 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone.Used", total_time); | 2969 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone.Used", total_time); |
| 2934 return; | 2970 return; |
| 2935 } | 2971 } |
| 2936 | 2972 |
| 2937 TimeDelta before_send_time = send_request_since_ - first_cache_access_since_; | 2973 TimeDelta before_send_time = send_request_since_ - first_cache_access_since_; |
| 2938 int64_t before_send_percent = (total_time.ToInternalValue() == 0) | 2974 int64_t before_send_percent = (total_time.ToInternalValue() == 0) |
| 2939 ? 0 | 2975 ? 0 |
| 2940 : before_send_time * 100 / total_time; | 2976 : before_send_time * 100 / total_time; |
| 2941 DCHECK_GE(before_send_percent, 0); | 2977 DCHECK_GE(before_send_percent, 0); |
| 2942 DCHECK_LE(before_send_percent, 100); | 2978 DCHECK_LE(before_send_percent, 100); |
| 2943 base::HistogramBase::Sample before_send_sample = | 2979 base::HistogramBase::Sample before_send_sample = |
| 2944 static_cast<base::HistogramBase::Sample>(before_send_percent); | 2980 static_cast<base::HistogramBase::Sample>(before_send_percent); |
| 2945 | 2981 |
| 2946 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone.SentRequest", total_time); | 2982 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone.SentRequest", total_time); |
| 2947 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend", before_send_time); | 2983 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend", before_send_time); |
| 2948 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend", before_send_sample); | 2984 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend", before_send_sample); |
| 2949 | 2985 |
| 2950 // TODO(gavinp): Remove or minimize these histograms, particularly the ones | 2986 // TODO(gavinp): Remove or minimize these histograms, particularly the ones |
| 2951 // below this comment after we have received initial data. | 2987 // below this comment after we have received initial data. |
| 2952 switch (transaction_pattern_) { | 2988 switch (cache_entry_status_) { |
| 2953 case PATTERN_ENTRY_CANT_CONDITIONALIZE: { | 2989 case CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE: { |
| 2954 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.CantConditionalize", | 2990 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.CantConditionalize", |
| 2955 before_send_time); | 2991 before_send_time); |
| 2956 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.CantConditionalize", | 2992 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.CantConditionalize", |
| 2957 before_send_sample); | 2993 before_send_sample); |
| 2958 break; | 2994 break; |
| 2959 } | 2995 } |
| 2960 case PATTERN_ENTRY_NOT_CACHED: { | 2996 case CacheEntryStatus::ENTRY_NOT_IN_CACHE: { |
| 2961 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.NotCached", before_send_time); | 2997 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.NotCached", before_send_time); |
| 2962 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.NotCached", | 2998 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.NotCached", |
| 2963 before_send_sample); | 2999 before_send_sample); |
| 2964 break; | 3000 break; |
| 2965 } | 3001 } |
| 2966 case PATTERN_ENTRY_VALIDATED: { | 3002 case CacheEntryStatus::ENTRY_VALIDATED: { |
| 2967 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Validated", before_send_time); | 3003 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Validated", before_send_time); |
| 2968 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Validated", | 3004 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Validated", |
| 2969 before_send_sample); | 3005 before_send_sample); |
| 2970 break; | 3006 break; |
| 2971 } | 3007 } |
| 2972 case PATTERN_ENTRY_UPDATED: { | 3008 case CacheEntryStatus::ENTRY_UPDATED: { |
| 2973 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Updated", before_send_time); | 3009 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Updated", before_send_time); |
| 2974 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Updated", | 3010 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Updated", |
| 2975 before_send_sample); | 3011 before_send_sample); |
| 2976 break; | 3012 break; |
| 2977 } | 3013 } |
| 2978 default: | 3014 default: |
| 2979 NOTREACHED(); | 3015 NOTREACHED(); |
| 2980 } | 3016 } |
| 2981 } | 3017 } |
| 2982 | 3018 |
| 2983 void HttpCache::Transaction::OnIOComplete(int result) { | 3019 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2984 DoLoop(result); | 3020 DoLoop(result); |
| 2985 } | 3021 } |
| 2986 | 3022 |
| 2987 } // namespace net | 3023 } // namespace net |
| OLD | NEW |