| 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 18 matching lines...) Expand all Loading... |
| 29 #include "net/base/ssl_config_service.h" | 29 #include "net/base/ssl_config_service.h" |
| 30 #include "net/disk_cache/disk_cache.h" | 30 #include "net/disk_cache/disk_cache.h" |
| 31 #include "net/http/http_network_session.h" | 31 #include "net/http/http_network_session.h" |
| 32 #include "net/http/http_request_info.h" | 32 #include "net/http/http_request_info.h" |
| 33 #include "net/http/http_response_headers.h" | 33 #include "net/http/http_response_headers.h" |
| 34 #include "net/http/http_transaction.h" | 34 #include "net/http/http_transaction.h" |
| 35 #include "net/http/http_util.h" | 35 #include "net/http/http_util.h" |
| 36 #include "net/http/partial_data.h" | 36 #include "net/http/partial_data.h" |
| 37 | 37 |
| 38 using base::Time; | 38 using base::Time; |
| 39 using base::TimeDelta; |
| 40 using base::TimeTicks; |
| 39 | 41 |
| 40 namespace net { | 42 namespace net { |
| 41 | 43 |
| 42 struct HeaderNameAndValue { | 44 struct HeaderNameAndValue { |
| 43 const char* name; | 45 const char* name; |
| 44 const char* value; | 46 const char* value; |
| 45 }; | 47 }; |
| 46 | 48 |
| 47 // If the request includes one of these request headers, then avoid caching | 49 // If the request includes one of these request headers, then avoid caching |
| 48 // to avoid getting confused. | 50 // to avoid getting confused. |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 | 944 |
| 943 return OK; | 945 return OK; |
| 944 } | 946 } |
| 945 | 947 |
| 946 int HttpCache::Transaction::DoAddToEntry() { | 948 int HttpCache::Transaction::DoAddToEntry() { |
| 947 DCHECK(new_entry_); | 949 DCHECK(new_entry_); |
| 948 cache_pending_ = true; | 950 cache_pending_ = true; |
| 949 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; | 951 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; |
| 950 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); | 952 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); |
| 951 DCHECK(entry_lock_waiting_since_.is_null()); | 953 DCHECK(entry_lock_waiting_since_.is_null()); |
| 952 entry_lock_waiting_since_ = base::TimeTicks::Now(); | 954 entry_lock_waiting_since_ = TimeTicks::Now(); |
| 953 return cache_->AddTransactionToEntry(new_entry_, this); | 955 return cache_->AddTransactionToEntry(new_entry_, this); |
| 954 } | 956 } |
| 955 | 957 |
| 956 int HttpCache::Transaction::DoAddToEntryComplete(int result) { | 958 int HttpCache::Transaction::DoAddToEntryComplete(int result) { |
| 957 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, | 959 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, |
| 958 result); | 960 result); |
| 959 | 961 |
| 960 const base::TimeDelta entry_lock_wait = | 962 const TimeDelta entry_lock_wait = |
| 961 base::TimeTicks::Now() - entry_lock_waiting_since_; | 963 TimeTicks::Now() - entry_lock_waiting_since_; |
| 962 UMA_HISTOGRAM_TIMES("HttpCache.EntryLockWait", entry_lock_wait); | 964 UMA_HISTOGRAM_TIMES("HttpCache.EntryLockWait", entry_lock_wait); |
| 963 static const bool prefetching_fieldtrial = | 965 static const bool prefetching_fieldtrial = |
| 964 base::FieldTrialList::TrialExists("Prefetch"); | 966 base::FieldTrialList::TrialExists("Prefetch"); |
| 965 if (prefetching_fieldtrial) { | 967 if (prefetching_fieldtrial) { |
| 966 UMA_HISTOGRAM_TIMES( | 968 UMA_HISTOGRAM_TIMES( |
| 967 base::FieldTrial::MakeName("HttpCache.EntryLockWait", "Prefetch"), | 969 base::FieldTrial::MakeName("HttpCache.EntryLockWait", "Prefetch"), |
| 968 entry_lock_wait); | 970 entry_lock_wait); |
| 969 } | 971 } |
| 970 static const bool prerendering_fieldtrial = | 972 static const bool prerendering_fieldtrial = |
| 971 base::FieldTrialList::TrialExists("Prerender"); | 973 base::FieldTrialList::TrialExists("Prerender"); |
| 972 if (prerendering_fieldtrial) { | 974 if (prerendering_fieldtrial) { |
| 973 UMA_HISTOGRAM_TIMES( | 975 UMA_HISTOGRAM_TIMES( |
| 974 base::FieldTrial::MakeName("HttpCache.EntryLockWait", "Prerender"), | 976 base::FieldTrial::MakeName("HttpCache.EntryLockWait", "Prerender"), |
| 975 entry_lock_wait); | 977 entry_lock_wait); |
| 976 } | 978 } |
| 977 | 979 |
| 978 entry_lock_waiting_since_ = base::TimeTicks(); | 980 entry_lock_waiting_since_ = TimeTicks(); |
| 979 DCHECK(new_entry_); | 981 DCHECK(new_entry_); |
| 980 cache_pending_ = false; | 982 cache_pending_ = false; |
| 981 | 983 |
| 982 if (result == ERR_CACHE_RACE) { | 984 if (result == ERR_CACHE_RACE) { |
| 983 new_entry_ = NULL; | 985 new_entry_ = NULL; |
| 984 next_state_ = STATE_INIT_ENTRY; | 986 next_state_ = STATE_INIT_ENTRY; |
| 985 return OK; | 987 return OK; |
| 986 } | 988 } |
| 987 | 989 |
| 988 if (result != OK) { | 990 if (result != OK) { |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 return false; | 2106 return false; |
| 2105 | 2107 |
| 2106 return true; | 2108 return true; |
| 2107 } | 2109 } |
| 2108 | 2110 |
| 2109 void HttpCache::Transaction::OnIOComplete(int result) { | 2111 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2110 DoLoop(result); | 2112 DoLoop(result); |
| 2111 } | 2113 } |
| 2112 | 2114 |
| 2113 } // namespace net | 2115 } // namespace net |
| OLD | NEW |