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

Side by Side Diff: components/subresource_filter/core/common/indexed_ruleset.cc

Issue 2683413003: Introduce AsyncDocumentSubresourceFilter. (Closed)
Patch Set: Rebase. Created 3 years, 10 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 | « components/subresource_filter/content/browser/verified_ruleset_dealer.h ('k') | no next file » | 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/core/common/indexed_ruleset.h" 5 #include "components/subresource_filter/core/common/indexed_ruleset.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 463 }
464 } 464 }
465 465
466 const FlatUrlRuleList* rules = index->fallback_rules(); 466 const FlatUrlRuleList* rules = index->fallback_rules();
467 return MatchesAny(rules, url, initiator, element_type, activation_type, 467 return MatchesAny(rules, url, initiator, element_type, activation_type,
468 is_third_party, disable_generic_rules); 468 is_third_party, disable_generic_rules);
469 } 469 }
470 470
471 } // namespace 471 } // namespace
472 472
473 // static
473 bool IndexedRulesetMatcher::Verify(const uint8_t* buffer, size_t size) { 474 bool IndexedRulesetMatcher::Verify(const uint8_t* buffer, size_t size) {
474 const auto* indexed_ruleset = flat::GetIndexedRuleset(buffer);
475 flatbuffers::Verifier verifier(buffer, size); 475 flatbuffers::Verifier verifier(buffer, size);
476 return indexed_ruleset->Verify(verifier); 476 return flat::VerifyIndexedRulesetBuffer(verifier);
477 } 477 }
478 478
479 IndexedRulesetMatcher::IndexedRulesetMatcher(const uint8_t* buffer, size_t size) 479 IndexedRulesetMatcher::IndexedRulesetMatcher(const uint8_t* buffer, size_t size)
480 : root_(flat::GetIndexedRuleset(buffer)) { 480 : root_(flat::GetIndexedRuleset(buffer)) {
481 const flat::UrlPatternIndex* index = root_->blacklist_index(); 481 const flat::UrlPatternIndex* index = root_->blacklist_index();
482 DCHECK(!index || index->n() == kNGramSize); 482 DCHECK(!index || index->n() == kNGramSize);
483 index = root_->whitelist_index(); 483 index = root_->whitelist_index();
484 DCHECK(!index || index->n() == kNGramSize); 484 DCHECK(!index || index->n() == kNGramSize);
485 } 485 }
486 486
(...skipping 22 matching lines...) Expand all
509 const bool is_third_party = first_party.IsThirdParty(url); 509 const bool is_third_party = first_party.IsThirdParty(url);
510 return IsMatch(root_->blacklist_index(), url, first_party.origin(), 510 return IsMatch(root_->blacklist_index(), url, first_party.origin(),
511 element_type, proto::ACTIVATION_TYPE_UNSPECIFIED, 511 element_type, proto::ACTIVATION_TYPE_UNSPECIFIED,
512 is_third_party, disable_generic_rules) && 512 is_third_party, disable_generic_rules) &&
513 !IsMatch(root_->whitelist_index(), url, first_party.origin(), 513 !IsMatch(root_->whitelist_index(), url, first_party.origin(),
514 element_type, proto::ACTIVATION_TYPE_UNSPECIFIED, 514 element_type, proto::ACTIVATION_TYPE_UNSPECIFIED,
515 is_third_party, disable_generic_rules); 515 is_third_party, disable_generic_rules);
516 } 516 }
517 517
518 } // namespace subresource_filter 518 } // namespace subresource_filter
OLDNEW
« no previous file with comments | « components/subresource_filter/content/browser/verified_ruleset_dealer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698