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

Unified Diff: extensions/browser/api/declarative_net_request/ruleset_manager.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/ruleset_manager.h
diff --git a/extensions/browser/api/declarative_net_request/ruleset_manager.h b/extensions/browser/api/declarative_net_request/ruleset_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..625c9ac7f13290d42b0a90f569fec42a629164db
--- /dev/null
+++ b/extensions/browser/api/declarative_net_request/ruleset_manager.h
@@ -0,0 +1,68 @@
+// 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_RULESET_MANAGER_H_
+#define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULESET_MANAGER_H_
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <base/macros.h>
+#include "base/files/memory_mapped_file.h"
+#include "base/time/time.h"
+#include "extensions/browser/api/declarative_net_request/matcher_util.h"
+#include "extensions/common/extension_id.h"
+
+namespace base {
+class Time;
+}
+
+namespace extensions {
+class InfoMap;
+
+namespace declarative_net_request {
+class ExtensionIndexedRulesetMatcher;
+
+// Owned by InfoMap. Like InfoMap, it can be created/destroyed on any thread,
+// but all the other methods must be called on the IO thread. Also, since it's
+// owned by InfoMap, it's implicitly associated with a BrowserContext.
+class RulesetManager {
+ public:
+ struct ExtensionKey {
+ ExtensionKey(ExtensionId, base::Time);
+ ~ExtensionKey();
+ const ExtensionId id;
+ const base::Time install_time;
+ };
+
+ struct ExtensionKeyComparator {
+ bool operator()(const ExtensionKey& lhs, const ExtensionKey& rhs) const;
+ };
+
+ using RulesMap = std::map<ExtensionKey,
+ std::unique_ptr<ExtensionIndexedRulesetMatcher>,
+ ExtensionKeyComparator>;
+
+ RulesetManager(InfoMap* info_map);
+ ~RulesetManager();
+ void AddRuleset(
+ ExtensionId extension_id,
+ std::unique_ptr<ExtensionIndexedRulesetMatcher> ruleset_matcher);
+ void RemoveRuleset(ExtensionId extension_id);
+
+ const RulesMap* rules_map() const { return &rules_; }
+
+ private:
+ InfoMap* info_map_; // Weak. Owns us.
+ RulesMap rules_;
+
+ DISALLOW_COPY_AND_ASSIGN(RulesetManager);
+};
+
+} // namespace declarative_net_request
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULESET_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698