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

Unified Diff: extensions/browser/api/declarative_net_request/matcher_util.h

Issue 2881453002: DNR Prototype: With flatbuffers
Patch Set: -- Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/declarative_net_request/matcher_util.h
diff --git a/extensions/browser/api/declarative_net_request/matcher_util.h b/extensions/browser/api/declarative_net_request/matcher_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..f3137b32878ab047041422928702dd789143eba9
--- /dev/null
+++ b/extensions/browser/api/declarative_net_request/matcher_util.h
@@ -0,0 +1,83 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_MATCHER_UTIL_H_
+#define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_MATCHER_UTIL_H_
+
+#include <memory>
+#include "components/subresource_filter/core/common/url_pattern_index.h"
+#include "content/public/browser/browser_thread.h"
+#include "extensions/common/api/declarative_net_request/constants.h"
+
+namespace net {
+class URLRequest;
+}
+
+namespace base {
+class MemoryMappedFile;
+class FilePath;
+}
+
+class GURL;
+
+namespace url {
+class Origin;
+}
+
+namespace extensions {
+class InfoMap;
+
+namespace declarative_net_request {
+
+namespace flat {
+struct ExtensionIndexedRuleset;
+struct ExtensionRuleMetadata;
+}
+
+// This is created on the file thread and used on the IO thread. However,
+// there are no thread safety issues since this is only accessed on a single
+// thread at a time.
+class ExtensionIndexedRulesetMatcher {
+ public:
+ // We should ensure that the buffer passed has been verified.
+ explicit ExtensionIndexedRulesetMatcher(
+ std::unique_ptr<base::MemoryMappedFile,
+ content::BrowserThread::DeleteOnFileThread> ruleset_file);
+
+ bool ShouldBlockRequest(const GURL& url,
+ const url::Origin& first_party_origin,
+ ElementType element_type,
+ bool is_third_party);
+
+ private:
+ using UrlPatternIndexMatcher = subresource_filter::UrlPatternIndexMatcher;
+ using ExtensionRuleMetadataList =
+ flatbuffers::Vector<flatbuffers::Offset<flat::ExtensionRuleMetadata>>;
+
+ // This owns the actual buffer. Are there any potential issues of using
+ // DeleteOnFileThread.
+ std::unique_ptr<base::MemoryMappedFile,
+ content::BrowserThread::DeleteOnFileThread>
+ ruleset_file_;
+ const flat::ExtensionIndexedRuleset* root_;
+ const UrlPatternIndexMatcher blacklist_matcher_;
+ const UrlPatternIndexMatcher whitelist_matcher_;
+ const UrlPatternIndexMatcher redirect_matcher_;
+ const ExtensionRuleMetadataList* extension_metdata_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionIndexedRulesetMatcher);
+};
+
+std::unique_ptr<ExtensionIndexedRulesetMatcher>
+CreateVerifiedExtensionIndexedRulesetMatcher(
+ const base::FilePath& indexed_ruleset_path);
+
+bool ShouldBlockRequest(void* BrowserContext,
+ const InfoMap* info_map,
+ net::URLRequest* request);
+
+} // namespace declarative_net_request
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_MATCHER_UTIL_H_
« no previous file with comments | « extensions/browser/api/declarative_net_request/DEPS ('k') | extensions/browser/api/declarative_net_request/matcher_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698