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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
6 #define EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
7
8 #include <string>
9
10 #include "base/synchronization/lock.h"
11 #include "extensions/common/extension_set.h"
12
13 class GURL;
14
15 namespace extensions {
16
17 // Thread safe container for all loaded extensions in this process,
18 // essentially the renderer counterpart to ExtensionRegistry.
19 class RendererExtensionRegistry {
20 public:
21 RendererExtensionRegistry();
22 ~RendererExtensionRegistry();
23
24 static RendererExtensionRegistry* Get();
25
26 // Returns the ExtensionSet that underlies this RenderExtensionRegistry.
27 //
28 // This is not thread-safe and must only be called on the RenderThread, but
29 // even so, it's not thread safe because other threads may decide to
30 // modify this. Don't persist a reference to this.
31 //
32 // TODO(annekao): remove or make thread-safe and callback-based.
33 const ExtensionSet* GetMainThreadExtensionSet() const;
34
35 size_t size() const;
36 bool is_empty() const;
37
38 // Forwards to the ExtensionSet methods by the same name.
39 bool Contains(const std::string& id) const;
40 bool Insert(const scoped_refptr<const Extension>& extension);
41 bool Remove(const std::string& id);
42 std::string GetExtensionOrAppIDByURL(const GURL& url) const;
43 const Extension* GetExtensionOrAppByURL(const GURL& url) const;
44 const Extension* GetHostedAppByURL(const GURL& url) const;
45 const Extension* GetByID(const std::string& id) const;
46 ExtensionIdSet GetIDs() const;
47 bool ExtensionBindingsAllowed(const GURL& url) const;
48
49 private:
50 ExtensionSet extensions_;
51
52 mutable base::Lock lock_;
53
54 DISALLOW_COPY_AND_ASSIGN(RendererExtensionRegistry);
55 };
56
57 } // namespace extensions
58
59 #endif // EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
OLDNEW
« no previous file with comments | « extensions/renderer/gc_callback_unittest.cc ('k') | extensions/renderer/renderer_extension_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698