| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/subresource_filter/content/browser/subresource_filter_safe_
browsing_activation_throttle.h" | 5 #include "components/subresource_filter/content/browser/subresource_filter_safe_
browsing_activation_throttle.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 base::OnTaskRunnerDeleter(io_task_runner_)) {} | 37 base::OnTaskRunnerDeleter(io_task_runner_)) {} |
| 38 | 38 |
| 39 SubresourceFilterSafeBrowsingActivationThrottle:: | 39 SubresourceFilterSafeBrowsingActivationThrottle:: |
| 40 ~SubresourceFilterSafeBrowsingActivationThrottle() { | 40 ~SubresourceFilterSafeBrowsingActivationThrottle() { |
| 41 // TODO(csharrison): Log metrics based on check_results_. | 41 // TODO(csharrison): Log metrics based on check_results_. |
| 42 } | 42 } |
| 43 | 43 |
| 44 content::NavigationThrottle::ThrottleCheckResult | 44 content::NavigationThrottle::ThrottleCheckResult |
| 45 SubresourceFilterSafeBrowsingActivationThrottle::WillStartRequest() { | 45 SubresourceFilterSafeBrowsingActivationThrottle::WillStartRequest() { |
| 46 CheckCurrentUrl(); | 46 CheckCurrentUrl(); |
| 47 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; | 47 return content::NavigationThrottle::PROCEED; |
| 48 } | 48 } |
| 49 | 49 |
| 50 content::NavigationThrottle::ThrottleCheckResult | 50 content::NavigationThrottle::ThrottleCheckResult |
| 51 SubresourceFilterSafeBrowsingActivationThrottle::WillRedirectRequest() { | 51 SubresourceFilterSafeBrowsingActivationThrottle::WillRedirectRequest() { |
| 52 CheckCurrentUrl(); | 52 CheckCurrentUrl(); |
| 53 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; | 53 return content::NavigationThrottle::PROCEED; |
| 54 } | 54 } |
| 55 | 55 |
| 56 content::NavigationThrottle::ThrottleCheckResult | 56 content::NavigationThrottle::ThrottleCheckResult |
| 57 SubresourceFilterSafeBrowsingActivationThrottle::WillProcessResponse() { | 57 SubresourceFilterSafeBrowsingActivationThrottle::WillProcessResponse() { |
| 58 if (!database_client_) | 58 if (!database_client_) |
| 59 return content::NavigationThrottle::PROCEED; | 59 return content::NavigationThrottle::PROCEED; |
| 60 | 60 |
| 61 // No need to defer the navigation if the check already happened. | 61 // No need to defer the navigation if the check already happened. |
| 62 if (check_results_.back().finished) { | 62 if (check_results_.back().finished) { |
| 63 NotifyResult(); | 63 NotifyResult(); |
| 64 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; | 64 return content::NavigationThrottle::PROCEED; |
| 65 } | 65 } |
| 66 defer_time_ = base::TimeTicks::Now(); | 66 defer_time_ = base::TimeTicks::Now(); |
| 67 return content::NavigationThrottle::ThrottleCheckResult::DEFER; | 67 return content::NavigationThrottle::DEFER; |
| 68 } | 68 } |
| 69 | 69 |
| 70 const char* | 70 const char* |
| 71 SubresourceFilterSafeBrowsingActivationThrottle::GetNameForLogging() { | 71 SubresourceFilterSafeBrowsingActivationThrottle::GetNameForLogging() { |
| 72 return "SubresourceFilterSafeBrowsingActivationThrottle"; | 72 return "SubresourceFilterSafeBrowsingActivationThrottle"; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void SubresourceFilterSafeBrowsingActivationThrottle::OnCheckUrlResultOnUI( | 75 void SubresourceFilterSafeBrowsingActivationThrottle::OnCheckUrlResultOnUI( |
| 76 const SubresourceFilterSafeBrowsingClient::CheckResult& result) { | 76 const SubresourceFilterSafeBrowsingClient::CheckResult& result) { |
| 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // speculatively checks URLs on WillStartRequest. This is only different from | 124 // speculatively checks URLs on WillStartRequest. This is only different from |
| 125 // the actual delay if there was at least one redirect. | 125 // the actual delay if there was at least one redirect. |
| 126 base::TimeDelta no_redirect_speculation_delay = | 126 base::TimeDelta no_redirect_speculation_delay = |
| 127 check_results_.size() > 1 ? result.check_time : delay; | 127 check_results_.size() > 1 ? result.check_time : delay; |
| 128 UMA_HISTOGRAM_TIMES( | 128 UMA_HISTOGRAM_TIMES( |
| 129 "SubresourceFilter.PageLoad.SafeBrowsingDelay.NoRedirectSpeculation", | 129 "SubresourceFilter.PageLoad.SafeBrowsingDelay.NoRedirectSpeculation", |
| 130 no_redirect_speculation_delay); | 130 no_redirect_speculation_delay); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace subresource_filter | 133 } // namespace subresource_filter |
| OLD | NEW |