OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ | 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ |
6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ | 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // NULL if no such context exists. | 59 // NULL if no such context exists. |
60 ScriptContext* GetCalling() const; | 60 ScriptContext* GetCalling() const; |
61 | 61 |
62 // Gets the ScriptContext corresponding to the specified | 62 // Gets the ScriptContext corresponding to the specified |
63 // v8::Context or NULL if no such context exists. | 63 // v8::Context or NULL if no such context exists. |
64 ScriptContext* GetByV8Context(v8::Handle<v8::Context> context) const; | 64 ScriptContext* GetByV8Context(v8::Handle<v8::Context> context) const; |
65 | 65 |
66 // Synchronously runs |callback| with each ScriptContext that belongs to | 66 // Synchronously runs |callback| with each ScriptContext that belongs to |
67 // |extension_id| in |render_view|. | 67 // |extension_id| in |render_view|. |
68 // | 68 // |
69 // |extension_id| may be "" to match all extensions. | 69 // An empty |extension_id| will match all extensions, and a NULL |render_view| |
70 // |render_view| may be NULL to match all render views. | 70 // will match all render views, but try to use the inline variants of these |
| 71 // methods instead. |
71 void ForEach(const std::string& extension_id, | 72 void ForEach(const std::string& extension_id, |
72 content::RenderView* render_view, | 73 content::RenderView* render_view, |
73 const base::Callback<void(ScriptContext*)>& callback) const; | 74 const base::Callback<void(ScriptContext*)>& callback) const; |
| 75 // ForEach which matches all extensions. |
| 76 void ForEach(content::RenderView* render_view, |
| 77 const base::Callback<void(ScriptContext*)>& callback) const { |
| 78 ForEach("", render_view, callback); |
| 79 } |
| 80 // ForEach which matches all render views. |
| 81 void ForEach(const std::string& extension_id, |
| 82 const base::Callback<void(ScriptContext*)>& callback) const { |
| 83 ForEach(extension_id, NULL, callback); |
| 84 } |
74 | 85 |
75 // Cleans up contexts belonging to an unloaded extension. | 86 // Cleans up contexts belonging to an unloaded extension. |
76 // | 87 // |
77 // Returns the set of ScriptContexts that were removed as a result. These | 88 // Returns the set of ScriptContexts that were removed as a result. These |
78 // are safe to interact with until the end of the current event loop, since | 89 // are safe to interact with until the end of the current event loop, since |
79 // they're deleted asynchronously. | 90 // they're deleted asynchronously. |
80 ContextSet OnExtensionUnloaded(const std::string& extension_id); | 91 ContextSet OnExtensionUnloaded(const std::string& extension_id); |
81 | 92 |
82 private: | 93 private: |
83 ContextSet contexts_; | 94 ContextSet contexts_; |
84 | 95 |
85 DISALLOW_COPY_AND_ASSIGN(ScriptContextSet); | 96 DISALLOW_COPY_AND_ASSIGN(ScriptContextSet); |
86 }; | 97 }; |
87 | 98 |
88 } // namespace extensions | 99 } // namespace extensions |
89 | 100 |
90 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ | 101 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ |
OLD | NEW |