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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 }; | 110 }; |
111 VaryType vary = VARY_NOT_PRESENT; | 111 VaryType vary = VARY_NOT_PRESENT; |
112 if (response->vary_data.is_valid()) { | 112 if (response->vary_data.is_valid()) { |
113 vary = VARY_OTHER; | 113 vary = VARY_OTHER; |
114 if (response->headers->HasHeaderValue("vary", "user-agent")) | 114 if (response->headers->HasHeaderValue("vary", "user-agent")) |
115 vary = VARY_UA; | 115 vary = VARY_UA; |
116 } | 116 } |
117 UMA_HISTOGRAM_ENUMERATION("HttpCache.Vary", vary, VARY_MAX); | 117 UMA_HISTOGRAM_ENUMERATION("HttpCache.Vary", vary, VARY_MAX); |
118 } | 118 } |
119 | 119 |
| 120 void RecordNoStoreHeaderHistogram(int load_flags, |
| 121 const net::HttpResponseInfo* response) { |
| 122 if (load_flags & net::LOAD_MAIN_FRAME) { |
| 123 UMA_HISTOGRAM_BOOLEAN( |
| 124 "Net.MainFrameNoStore", |
| 125 response->headers->HasHeaderValue("cache-control", "no-store")); |
| 126 } |
| 127 } |
| 128 |
120 } // namespace | 129 } // namespace |
121 | 130 |
122 namespace net { | 131 namespace net { |
123 | 132 |
124 struct HeaderNameAndValue { | 133 struct HeaderNameAndValue { |
125 const char* name; | 134 const char* name; |
126 const char* value; | 135 const char* value; |
127 }; | 136 }; |
128 | 137 |
129 // If the request includes one of these request headers, then avoid caching | 138 // If the request includes one of these request headers, then avoid caching |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 entry_ = NULL; | 1029 entry_ = NULL; |
1021 mode_ = NONE; | 1030 mode_ = NONE; |
1022 } | 1031 } |
1023 | 1032 |
1024 if (request_->method == "POST" && | 1033 if (request_->method == "POST" && |
1025 NonErrorResponse(new_response->headers->response_code())) { | 1034 NonErrorResponse(new_response->headers->response_code())) { |
1026 cache_->DoomMainEntryForUrl(request_->url); | 1035 cache_->DoomMainEntryForUrl(request_->url); |
1027 } | 1036 } |
1028 | 1037 |
1029 RecordVaryHeaderHistogram(new_response); | 1038 RecordVaryHeaderHistogram(new_response); |
| 1039 RecordNoStoreHeaderHistogram(request_->load_flags, new_response); |
1030 | 1040 |
1031 if (new_response_->headers->response_code() == 416 && | 1041 if (new_response_->headers->response_code() == 416 && |
1032 (request_->method == "GET" || request_->method == "POST")) { | 1042 (request_->method == "GET" || request_->method == "POST")) { |
1033 // If there is an ective entry it may be destroyed with this transaction. | 1043 // If there is an ective entry it may be destroyed with this transaction. |
1034 response_ = *new_response_; | 1044 response_ = *new_response_; |
1035 return OK; | 1045 return OK; |
1036 } | 1046 } |
1037 | 1047 |
1038 // Are we expecting a response to a conditional query? | 1048 // Are we expecting a response to a conditional query? |
1039 if (mode_ == READ_WRITE || mode_ == UPDATE) { | 1049 if (mode_ == READ_WRITE || mode_ == UPDATE) { |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 default: | 2530 default: |
2521 NOTREACHED(); | 2531 NOTREACHED(); |
2522 } | 2532 } |
2523 } | 2533 } |
2524 | 2534 |
2525 void HttpCache::Transaction::OnIOComplete(int result) { | 2535 void HttpCache::Transaction::OnIOComplete(int result) { |
2526 DoLoop(result); | 2536 DoLoop(result); |
2527 } | 2537 } |
2528 | 2538 |
2529 } // namespace net | 2539 } // namespace net |
OLD | NEW |