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

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

Issue 531693003: Add HttpCache.ExternallyConditionalized histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 void RecordNoStoreHeaderHistogram(int load_flags, 232 void RecordNoStoreHeaderHistogram(int load_flags,
233 const net::HttpResponseInfo* response) { 233 const net::HttpResponseInfo* response) {
234 if (load_flags & net::LOAD_MAIN_FRAME) { 234 if (load_flags & net::LOAD_MAIN_FRAME) {
235 UMA_HISTOGRAM_BOOLEAN( 235 UMA_HISTOGRAM_BOOLEAN(
236 "Net.MainFrameNoStore", 236 "Net.MainFrameNoStore",
237 response->headers->HasHeaderValue("cache-control", "no-store")); 237 response->headers->HasHeaderValue("cache-control", "no-store"));
238 } 238 }
239 } 239 }
240 240
241 // TODO(ricea): Add CACHE_USABLE_STALE once stale-while-revalidate CL landed.
242 // TODO(ricea): Either remove this histogram or make it permanent by M40.
243 void RecordExternallyConditionalizedHistogram(bool requires_validation) {
244 enum ExternallyConditionalizedType {
245 EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION,
246 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE,
247 EXTERNALLY_CONDITIONALIZED_MAX
248 };
249 ExternallyConditionalizedType type =
250 requires_validation ? EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION
251 : EXTERNALLY_CONDITIONALIZED_CACHE_USABLE;
252 UMA_HISTOGRAM_ENUMERATION("HttpCache.ExternallyConditionalized",
253 type,
254 EXTERNALLY_CONDITIONALIZED_MAX);
255 }
256
241 } // namespace 257 } // namespace
242 258
243 namespace net { 259 namespace net {
244 260
245 struct HeaderNameAndValue { 261 struct HeaderNameAndValue {
246 const char* name; 262 const char* name;
247 const char* value; 263 const char* value;
248 }; 264 };
249 265
250 // If the request includes one of these request headers, then avoid caching 266 // If the request includes one of these request headers, then avoid caching
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 std::string validator; 2230 std::string validator;
2215 response_.headers->EnumerateHeader( 2231 response_.headers->EnumerateHeader(
2216 NULL, 2232 NULL,
2217 kValidationHeaders[i].related_response_header_name, 2233 kValidationHeaders[i].related_response_header_name,
2218 &validator); 2234 &validator);
2219 2235
2220 if (response_.headers->response_code() != 200 || truncated_ || 2236 if (response_.headers->response_code() != 200 || truncated_ ||
2221 validator.empty() || validator != external_validation_.values[i]) { 2237 validator.empty() || validator != external_validation_.values[i]) {
2222 // The externally conditionalized request is not a validation request 2238 // The externally conditionalized request is not a validation request
2223 // for our existing cache entry. Proceed with caching disabled. 2239 // for our existing cache entry. Proceed with caching disabled.
2224 UpdateTransactionPattern(PATTERN_NOT_COVERED); 2240 UpdateTransactionPattern(PATTERN_NOT_COVERED);
rvargas (doing something else) 2014/09/04 01:45:12 The description says that it tells whether the res
Adam Rice 2014/09/04 15:19:41 Sorry, I had some kind of tunnel vision and was co
2225 DoneWritingToEntry(true); 2241 DoneWritingToEntry(true);
2226 } 2242 }
2227 } 2243 }
2228 2244
2245 // TODO(ricea): This calculation is expensive to perform just to collect
2246 // statistics. Either remove it or use the result, depending on the result of
2247 // the experiment.
2248 RecordExternallyConditionalizedHistogram(RequiresValidation());
2249
2229 next_state_ = STATE_SEND_REQUEST; 2250 next_state_ = STATE_SEND_REQUEST;
2230 return OK; 2251 return OK;
2231 } 2252 }
2232 2253
2233 int HttpCache::Transaction::RestartNetworkRequest() { 2254 int HttpCache::Transaction::RestartNetworkRequest() {
2234 DCHECK(mode_ & WRITE || mode_ == NONE); 2255 DCHECK(mode_ & WRITE || mode_ == NONE);
2235 DCHECK(network_trans_.get()); 2256 DCHECK(network_trans_.get());
2236 DCHECK_EQ(STATE_NONE, next_state_); 2257 DCHECK_EQ(STATE_NONE, next_state_);
2237 2258
2238 next_state_ = STATE_SEND_REQUEST_COMPLETE; 2259 next_state_ = STATE_SEND_REQUEST_COMPLETE;
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2869 default: 2890 default:
2870 NOTREACHED(); 2891 NOTREACHED();
2871 } 2892 }
2872 } 2893 }
2873 2894
2874 void HttpCache::Transaction::OnIOComplete(int result) { 2895 void HttpCache::Transaction::OnIOComplete(int result) {
2875 DoLoop(result); 2896 DoLoop(result);
2876 } 2897 }
2877 2898
2878 } // namespace net 2899 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698