| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/child/site_isolation_stats_gatherer.h" | 5 #include "content/child/site_isolation_stats_gatherer.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "content/public/common/resource_response_info.h" | 10 #include "content/public/common/resource_response_info.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // text; 2) then, this blocking only breaks the renderer behavior | 61 // text; 2) then, this blocking only breaks the renderer behavior |
| 62 // only if it is either JavaScript or CSS. However, the renderer | 62 // only if it is either JavaScript or CSS. However, the renderer |
| 63 // doesn't use the contents of JS/CSS with unaffected status code | 63 // doesn't use the contents of JS/CSS with unaffected status code |
| 64 // (e.g, 404). 3) the renderer is expected not to use the cross-site | 64 // (e.g, 404). 3) the renderer is expected not to use the cross-site |
| 65 // document content for purposes other than JS/CSS (e.g, XHR). | 65 // document content for purposes other than JS/CSS (e.g, XHR). |
| 66 bool renderable_status_code = | 66 bool renderable_status_code = |
| 67 IsRenderableStatusCode(resp_data->http_status_code); | 67 IsRenderableStatusCode(resp_data->http_status_code); |
| 68 | 68 |
| 69 if (renderable_status_code) { | 69 if (renderable_status_code) { |
| 70 IncrementHistogramEnum( | 70 IncrementHistogramEnum( |
| 71 bucket_prefix + block_label + ".RenderableStatusCode", | 71 bucket_prefix + block_label + ".RenderableStatusCode2", |
| 72 resp_data->resource_type, RESOURCE_TYPE_LAST_TYPE); | 72 resp_data->resource_type, RESOURCE_TYPE_LAST_TYPE); |
| 73 } else { | 73 } else { |
| 74 IncrementHistogramCount(bucket_prefix + block_label + | 74 IncrementHistogramCount(bucket_prefix + block_label + |
| 75 ".NonRenderableStatusCode"); | 75 ".NonRenderableStatusCode"); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 void HistogramCountNotBlockedResponse(const std::string& bucket_prefix, | 79 void HistogramCountNotBlockedResponse(const std::string& bucket_prefix, |
| 80 bool sniffed_as_js) { | 80 bool sniffed_as_js) { |
| 81 IncrementHistogramCount(bucket_prefix + ".NotBlocked"); | 81 IncrementHistogramCount(bucket_prefix + ".NotBlocked"); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 | 249 |
| 250 bool SiteIsolationStatsGatherer::SniffForJS(base::StringPiece data) { | 250 bool SiteIsolationStatsGatherer::SniffForJS(base::StringPiece data) { |
| 251 // The purpose of this function is to try to see if there's any possibility | 251 // The purpose of this function is to try to see if there's any possibility |
| 252 // that this data can be JavaScript (superset of JS). Search for "var " for JS | 252 // that this data can be JavaScript (superset of JS). Search for "var " for JS |
| 253 // detection. This is a real hack and should only be used for stats gathering. | 253 // detection. This is a real hack and should only be used for stats gathering. |
| 254 return data.find("var ") != base::StringPiece::npos; | 254 return data.find("var ") != base::StringPiece::npos; |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace content | 257 } // namespace content |
| OLD | NEW |