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

Side by Side Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc

Issue 2875033004: [subresource_filter] Add debugging trace events around activation (Closed)
Patch Set: quick fix Created 3 years, 7 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 | components/subresource_filter/core/browser/subresource_filter_features.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/content_subresource_filt er_driver_factory.h" 5 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h"
6 6
7 #include "base/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/trace_event/trace_event.h"
13 #include "base/trace_event/trace_event_argument.h"
12 #include "components/subresource_filter/content/browser/content_activation_list_ utils.h" 14 #include "components/subresource_filter/content/browser/content_activation_list_ utils.h"
13 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h" 15 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h"
14 #include "components/subresource_filter/core/browser/subresource_filter_features .h" 16 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
15 #include "components/subresource_filter/core/common/activation_list.h" 17 #include "components/subresource_filter/core/common/activation_list.h"
16 #include "components/subresource_filter/core/common/activation_state.h" 18 #include "components/subresource_filter/core/common/activation_state.h"
17 #include "content/public/browser/navigation_handle.h" 19 #include "content/public/browser/navigation_handle.h"
18 #include "content/public/browser/navigation_throttle.h" 20 #include "content/public/browser/navigation_throttle.h"
19 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
20 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 114
113 const auto config_list = GetEnabledConfigurations(); 115 const auto config_list = GetEnabledConfigurations();
114 const auto highest_priority_activated_config = 116 const auto highest_priority_activated_config =
115 std::find_if(config_list->configs_by_decreasing_priority().begin(), 117 std::find_if(config_list->configs_by_decreasing_priority().begin(),
116 config_list->configs_by_decreasing_priority().end(), 118 config_list->configs_by_decreasing_priority().end(),
117 [&url, this](const Configuration& config) { 119 [&url, this](const Configuration& config) {
118 return DoesMainFrameURLSatisfyActivationConditions( 120 return DoesMainFrameURLSatisfyActivationConditions(
119 url, config.activation_conditions); 121 url, config.activation_conditions);
120 }); 122 });
121 123
122 if (highest_priority_activated_config == 124 bool has_activated_config =
123 config_list->configs_by_decreasing_priority().end()) { 125 highest_priority_activated_config !=
126 config_list->configs_by_decreasing_priority().end();
127 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("loading"),
128 "ContentSubresourceFilterDriverFactory::"
129 "ComputeActivationForMainFrameNavigation",
130 "highest_priority_activated_config",
131 has_activated_config
132 ? highest_priority_activated_config->ToTracedValue()
133 : base::MakeUnique<base::trace_event::TracedValue>());
134 if (!has_activated_config) {
124 activation_decision_ = ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET; 135 activation_decision_ = ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET;
125 activation_options_ = Configuration::ActivationOptions(); 136 activation_options_ = Configuration::ActivationOptions();
126 return; 137 return;
127 } 138 }
128 139
129 activation_options_ = highest_priority_activated_config->activation_options; 140 activation_options_ = highest_priority_activated_config->activation_options;
130 activation_decision_ = 141 activation_decision_ =
131 activation_options_.activation_level == ActivationLevel::DISABLED 142 activation_options_.activation_level == ActivationLevel::DISABLED
132 ? ActivationDecision::ACTIVATION_DISABLED 143 ? ActivationDecision::ACTIVATION_DISABLED
133 : ActivationDecision::ACTIVATED; 144 : ActivationDecision::ACTIVATED;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN); 209 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN);
199 210
200 // Check for whitelisted status last, so that the client gets an accurate 211 // Check for whitelisted status last, so that the client gets an accurate
201 // indication of whether there would be activation otherwise. 212 // indication of whether there would be activation otherwise.
202 bool whitelisted = client_->OnPageActivationComputed( 213 bool whitelisted = client_->OnPageActivationComputed(
203 navigation_handle, 214 navigation_handle,
204 activation_options_.activation_level == ActivationLevel::ENABLED); 215 activation_options_.activation_level == ActivationLevel::ENABLED);
205 216
206 // Only reset the activation decision reason if we would have activated. 217 // Only reset the activation decision reason if we would have activated.
207 if (whitelisted && activation_decision_ == ActivationDecision::ACTIVATED) { 218 if (whitelisted && activation_decision_ == ActivationDecision::ACTIVATED) {
219 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("loading"), "ActivationWhitelisted");
208 activation_decision_ = ActivationDecision::URL_WHITELISTED; 220 activation_decision_ = ActivationDecision::URL_WHITELISTED;
209 activation_options_ = Configuration::ActivationOptions(); 221 activation_options_ = Configuration::ActivationOptions();
210 } 222 }
211 223
212 if (activation_decision_ != ActivationDecision::ACTIVATED) { 224 if (activation_decision_ != ActivationDecision::ACTIVATED) {
213 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED); 225 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED);
214 return; 226 return;
215 } 227 }
216 228
217 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED); 229 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, 347 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern,
336 chain_size); 348 chain_size);
337 break; 349 break;
338 default: 350 default:
339 NOTREACHED(); 351 NOTREACHED();
340 break; 352 break;
341 } 353 }
342 } 354 }
343 355
344 } // namespace subresource_filter 356 } // namespace subresource_filter
OLDNEW
« no previous file with comments | « no previous file | components/subresource_filter/core/browser/subresource_filter_features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698