| 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 "chrome/renderer/page_load_histograms.h" | 5 #include "chrome/renderer/page_load_histograms.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // dump page load histograms. Otherwise returns NULL. | 135 // dump page load histograms. Otherwise returns NULL. |
| 136 URLPattern::SchemeMasks GetSupportedSchemeType(const GURL& url) { | 136 URLPattern::SchemeMasks GetSupportedSchemeType(const GURL& url) { |
| 137 if (url.SchemeIs("http")) | 137 if (url.SchemeIs("http")) |
| 138 return URLPattern::SCHEME_HTTP; | 138 return URLPattern::SCHEME_HTTP; |
| 139 else if (url.SchemeIs("https")) | 139 else if (url.SchemeIs("https")) |
| 140 return URLPattern::SCHEME_HTTPS; | 140 return URLPattern::SCHEME_HTTPS; |
| 141 return static_cast<URLPattern::SchemeMasks>(0); | 141 return static_cast<URLPattern::SchemeMasks>(0); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Helper function to check for string in 'via' header. Returns true if | 144 // Helper function to check for string in 'via' header. Returns true if |
| 145 // |via_value| is one of the values listed in the Via header and the response | 145 // |via_value| is one of the values listed in the Via header. |
| 146 // was fetched via a proxy. | |
| 147 bool ViaHeaderContains(WebFrame* frame, const std::string& via_value) { | 146 bool ViaHeaderContains(WebFrame* frame, const std::string& via_value) { |
| 148 const char kViaHeaderName[] = "Via"; | 147 const char kViaHeaderName[] = "Via"; |
| 149 | |
| 150 DocumentState* document_state = | |
| 151 DocumentState::FromDataSource(frame->dataSource()); | |
| 152 if (!document_state->was_fetched_via_proxy()) | |
| 153 return false; | |
| 154 | |
| 155 std::vector<std::string> values; | 148 std::vector<std::string> values; |
| 156 // Multiple via headers have already been coalesced and hence each value | 149 // Multiple via headers have already been coalesced and hence each value |
| 157 // separated by a comma corresponds to a proxy. The value added by a proxy is | 150 // separated by a comma corresponds to a proxy. The value added by a proxy is |
| 158 // not expected to contain any commas. | 151 // not expected to contain any commas. |
| 159 // Example., Via: 1.0 Compression proxy, 1.1 Google Instant Proxy Preview | 152 // Example., Via: 1.0 Compression proxy, 1.1 Google Instant Proxy Preview |
| 160 base::SplitString( | 153 base::SplitString( |
| 161 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(), | 154 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(), |
| 162 ',', &values); | 155 ',', &values); |
| 163 return std::find(values.begin(), values.end(), via_value) != values.end(); | 156 return std::find(values.begin(), values.end(), via_value) != values.end(); |
| 164 } | 157 } |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 | 834 |
| 842 DCHECK(document_state); | 835 DCHECK(document_state); |
| 843 DCHECK(ds); | 836 DCHECK(ds); |
| 844 GURL url(ds->request().url()); | 837 GURL url(ds->request().url()); |
| 845 Time start = document_state->start_load_time(); | 838 Time start = document_state->start_load_time(); |
| 846 Time finish = document_state->finish_load_time(); | 839 Time finish = document_state->finish_load_time(); |
| 847 // TODO(mbelshe): should we log more stats? | 840 // TODO(mbelshe): should we log more stats? |
| 848 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 841 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 849 << url.spec(); | 842 << url.spec(); |
| 850 } | 843 } |
| OLD | NEW |