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

Unified Diff: extensions/renderer/renderer_extension_registry.h

Issue 1293673002: Create thread-safe RendererExtensionRegistry from ExtensionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/renderer/renderer_extension_registry.h
diff --git a/extensions/renderer/renderer_extension_registry.h b/extensions/renderer/renderer_extension_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..86bcb6f2fb46af81ac2c7001f50327e58040da25
--- /dev/null
+++ b/extensions/renderer/renderer_extension_registry.h
@@ -0,0 +1,64 @@
+// Copyright 2015 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_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
+#define EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
+
+#include <iterator>
+#include <string>
+
+#include "base/synchronization/lock.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_set.h"
+#include "url/gurl.h"
+
+namespace extensions {
+
+// Thread safe container for all loaded extensions in this process,
+// essentially the renderer counterpart to ExtensionRegistry.
+class RendererExtensionRegistry {
+ public:
+ RendererExtensionRegistry();
+ ~RendererExtensionRegistry();
+
+ static RendererExtensionRegistry* Get();
+
+ // Should only be used if using the RendererExtensionRegistry is not
+ // an option.
+ // TODO: Remove.
not at google - send to devlin 2015/08/18 18:42:50 I'd reword this: // Returns the ExtensionSet that
annekao 2015/08/18 20:21:12 Done.
+ const ExtensionSet* GetMainThreadExtensionSet() const;
not at google - send to devlin 2015/08/18 18:42:50 All my comments relating to thread safety aside, I
+
+ size_t size() const;
+ bool is_empty() const;
+
+ // Forwards to the ExtensionSet methods by the same name.
+ bool Contains(const std::string& id) const;
+
+ bool Insert(const scoped_refptr<const Extension>& extension);
+
+ bool Remove(const std::string& id);
+
+ std::string GetExtensionOrAppIDByURL(const GURL& url) const;
+
+ const Extension* GetExtensionOrAppByURL(const GURL& url) const;
+
+ const Extension* GetHostedAppByURL(const GURL& url) const;
+
+ const Extension* GetByID(const std::string& id) const;
+
+ ExtensionIdSet GetIDs() const;
+
+ bool ExtensionBindingsAllowed(const GURL& url) const;
+
+ private:
+ ExtensionSet extensions_;
+
+ mutable base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(RendererExtensionRegistry);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_

Powered by Google App Engine
This is Rietveld 408576698