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" | 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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 result); | 717 result); |
718 cache_pending_ = false; | 718 cache_pending_ = false; |
719 | 719 |
720 if (!ShouldPassThrough()) { | 720 if (!ShouldPassThrough()) { |
721 cache_key_ = cache_->GenerateCacheKey(request_); | 721 cache_key_ = cache_->GenerateCacheKey(request_); |
722 | 722 |
723 // Requested cache access mode. | 723 // Requested cache access mode. |
724 if (effective_load_flags_ & LOAD_ONLY_FROM_CACHE) { | 724 if (effective_load_flags_ & LOAD_ONLY_FROM_CACHE) { |
725 mode_ = READ; | 725 mode_ = READ; |
726 } else if (effective_load_flags_ & LOAD_BYPASS_CACHE) { | 726 } else if (effective_load_flags_ & LOAD_BYPASS_CACHE) { |
| 727 UpdateTransactionPattern(PATTERN_NOT_COVERED); |
727 mode_ = WRITE; | 728 mode_ = WRITE; |
728 } else { | 729 } else { |
729 mode_ = READ_WRITE; | 730 mode_ = READ_WRITE; |
730 } | 731 } |
731 | 732 |
732 // Downgrade to UPDATE if the request has been externally conditionalized. | 733 // Downgrade to UPDATE if the request has been externally conditionalized. |
733 if (external_validation_.initialized) { | 734 if (external_validation_.initialized) { |
734 if (mode_ & WRITE) { | 735 if (mode_ & WRITE) { |
735 // Strip off the READ_DATA bit (and maybe add back a READ_META bit | 736 // Strip off the READ_DATA bit (and maybe add back a READ_META bit |
736 // in case READ was off). | 737 // in case READ was off). |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 } | 954 } |
954 | 955 |
955 if (request_->method == "PUT" || request_->method == "DELETE") { | 956 if (request_->method == "PUT" || request_->method == "DELETE") { |
956 DCHECK(mode_ == READ_WRITE || mode_ == WRITE); | 957 DCHECK(mode_ == READ_WRITE || mode_ == WRITE); |
957 mode_ = NONE; | 958 mode_ = NONE; |
958 next_state_ = STATE_SEND_REQUEST; | 959 next_state_ = STATE_SEND_REQUEST; |
959 return OK; | 960 return OK; |
960 } | 961 } |
961 | 962 |
962 if (mode_ == READ_WRITE) { | 963 if (mode_ == READ_WRITE) { |
| 964 miss_since_ = TimeTicks::Now(); |
963 mode_ = WRITE; | 965 mode_ = WRITE; |
964 next_state_ = STATE_CREATE_ENTRY; | 966 next_state_ = STATE_CREATE_ENTRY; |
965 return OK; | 967 return OK; |
966 } | 968 } |
967 if (mode_ == UPDATE) { | 969 if (mode_ == UPDATE) { |
968 // There is no cache entry to update; proceed without caching. | 970 // There is no cache entry to update; proceed without caching. |
969 mode_ = NONE; | 971 mode_ = NONE; |
970 next_state_ = STATE_SEND_REQUEST; | 972 next_state_ = STATE_SEND_REQUEST; |
971 return OK; | 973 return OK; |
972 } | 974 } |
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2484 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.CantConditionalize", | 2486 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.CantConditionalize", |
2485 before_send_time); | 2487 before_send_time); |
2486 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.CantConditionalize", | 2488 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.CantConditionalize", |
2487 before_send_percent); | 2489 before_send_percent); |
2488 break; | 2490 break; |
2489 } | 2491 } |
2490 case PATTERN_ENTRY_NOT_CACHED: { | 2492 case PATTERN_ENTRY_NOT_CACHED: { |
2491 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.NotCached", before_send_time); | 2493 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.NotCached", before_send_time); |
2492 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.NotCached", | 2494 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.NotCached", |
2493 before_send_percent); | 2495 before_send_percent); |
| 2496 DCHECK(!miss_since_.is_null()); |
| 2497 TimeDelta before_miss_time = miss_since_ - first_cache_access_since_; |
| 2498 UMA_HISTOGRAM_TIMES("HttpCache.BeforeCreate.NotCached", before_miss_time); |
2494 break; | 2499 break; |
2495 } | 2500 } |
2496 case PATTERN_ENTRY_VALIDATED: { | 2501 case PATTERN_ENTRY_VALIDATED: { |
2497 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Validated", before_send_time); | 2502 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Validated", before_send_time); |
2498 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Validated", | 2503 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Validated", |
2499 before_send_percent); | 2504 before_send_percent); |
2500 if (is_small_resource) { | 2505 if (is_small_resource) { |
2501 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Validated.SmallResource", | 2506 UMA_HISTOGRAM_TIMES("HttpCache.BeforeSend.Validated.SmallResource", |
2502 before_send_time); | 2507 before_send_time); |
2503 UMA_HISTOGRAM_PERCENTAGE( | 2508 UMA_HISTOGRAM_PERCENTAGE( |
(...skipping 21 matching lines...) Expand all Loading... |
2525 } | 2530 } |
2526 | 2531 |
2527 int HttpCache::Transaction::ResetCacheIOStart(int return_value) { | 2532 int HttpCache::Transaction::ResetCacheIOStart(int return_value) { |
2528 DCHECK(cache_io_start_.is_null()); | 2533 DCHECK(cache_io_start_.is_null()); |
2529 if (return_value == ERR_IO_PENDING) | 2534 if (return_value == ERR_IO_PENDING) |
2530 cache_io_start_ = base::TimeTicks::Now(); | 2535 cache_io_start_ = base::TimeTicks::Now(); |
2531 return return_value; | 2536 return return_value; |
2532 } | 2537 } |
2533 | 2538 |
2534 } // namespace net | 2539 } // namespace net |
OLD | NEW |