OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef EXTENSIONS_COMMON_API_DECLARATIVE_NET_REQUEST_RULESET_INDEXER_H_ |
| 6 #define EXTENSIONS_COMMON_API_DECLARATIVE_NET_REQUEST_RULESET_INDEXER_H_ |
| 7 |
| 8 #include <utility> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "components/subresource_filter/core/common/flat/extension_metadata_gene
rated.h" |
| 13 #include "components/subresource_filter/core/common/url_pattern_index.h" |
| 14 #include "extensions/common/api/declarative_net_request.h" |
| 15 #include "third_party/flatbuffers/src/include/flatbuffers/flatbuffers.h" |
| 16 |
| 17 namespace extensions { |
| 18 namespace declarative_net_request { |
| 19 |
| 20 enum class ParseResult; |
| 21 struct IndexedRule; |
| 22 enum class RuleActionType; |
| 23 |
| 24 class RulesetIndexer { |
| 25 public: |
| 26 using SerializedData = std::pair<uint8_t*, size_t>; |
| 27 using UrlPatternIndexBuilder = subresource_filter::UrlPatternIndexBuilder; |
| 28 |
| 29 RulesetIndexer(); |
| 30 ~RulesetIndexer(); |
| 31 |
| 32 ParseResult AddUrlRule(const IndexedRule& indexed_rule); |
| 33 |
| 34 SerializedData FinishAndGetData(); |
| 35 |
| 36 private: |
| 37 using MetadataOffset = flatbuffers::Offset<flat::ExtensionRuleMetadata>; |
| 38 |
| 39 UrlPatternIndexBuilder* GetBuilder( |
| 40 api::declarative_net_request::RuleActionType type); |
| 41 |
| 42 flatbuffers::FlatBufferBuilder builder_; |
| 43 |
| 44 UrlPatternIndexBuilder blacklist_index_builder_; |
| 45 UrlPatternIndexBuilder whitelist_index_builder_; |
| 46 UrlPatternIndexBuilder redirect_index_builder_; |
| 47 std::vector<MetadataOffset> metadata_; |
| 48 size_t cnt_ = 0; // TODO remove. |
| 49 |
| 50 bool finished_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(RulesetIndexer); |
| 53 }; |
| 54 |
| 55 bool VerifyRuleset(const RulesetIndexer::SerializedData& data); |
| 56 |
| 57 } // namespace declarative_net_request |
| 58 } // namespace extensions |
| 59 |
| 60 #endif // EXTENSIONS_COMMON_API_DECLARATIVE_NET_REQUEST_RULESET_INDEXER_H_ |
OLD | NEW |