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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 ~ScriptContextSet(); | 51 ~ScriptContextSet(); |
52 | 52 |
53 // Returns the number of contexts being tracked by this set. | 53 // Returns the number of contexts being tracked by this set. |
54 // This may also include invalid contexts. TODO(kalman): Useful? | 54 // This may also include invalid contexts. TODO(kalman): Useful? |
55 size_t size() const { return contexts_.size(); } | 55 size_t size() const { return contexts_.size(); } |
56 | 56 |
57 // Creates and starts managing a new ScriptContext. Ownership is held. | 57 // Creates and starts managing a new ScriptContext. Ownership is held. |
58 // Returns a weak reference to the new ScriptContext. | 58 // Returns a weak reference to the new ScriptContext. |
59 ScriptContext* Register(blink::WebLocalFrame* frame, | 59 ScriptContext* Register(blink::WebLocalFrame* frame, |
60 const v8::Handle<v8::Context>& v8_context, | 60 const v8::Local<v8::Context>& v8_context, |
61 int extension_group, | 61 int extension_group, |
62 int world_id); | 62 int world_id); |
63 | 63 |
64 // If the specified context is contained in this set, remove it, then delete | 64 // If the specified context is contained in this set, remove it, then delete |
65 // it asynchronously. After this call returns the context object will still | 65 // it asynchronously. After this call returns the context object will still |
66 // be valid, but its frame() pointer will be cleared. | 66 // be valid, but its frame() pointer will be cleared. |
67 void Remove(ScriptContext* context); | 67 void Remove(ScriptContext* context); |
68 | 68 |
69 // Gets the ScriptContext corresponding to v8::Context::GetCurrent(), or | 69 // Gets the ScriptContext corresponding to v8::Context::GetCurrent(), or |
70 // NULL if no such context exists. | 70 // NULL if no such context exists. |
71 ScriptContext* GetCurrent() const; | 71 ScriptContext* GetCurrent() const; |
72 | 72 |
73 // Gets the ScriptContext corresponding to v8::Context::GetCalling(), or | 73 // Gets the ScriptContext corresponding to v8::Context::GetCalling(), or |
74 // NULL if no such context exists. | 74 // NULL if no such context exists. |
75 ScriptContext* GetCalling() const; | 75 ScriptContext* GetCalling() const; |
76 | 76 |
77 // Gets the ScriptContext corresponding to the specified | 77 // Gets the ScriptContext corresponding to the specified |
78 // v8::Context or NULL if no such context exists. | 78 // v8::Context or NULL if no such context exists. |
79 ScriptContext* GetByV8Context(const v8::Handle<v8::Context>& context) const; | 79 ScriptContext* GetByV8Context(const v8::Local<v8::Context>& context) const; |
80 | 80 |
81 // Synchronously runs |callback| with each ScriptContext that belongs to | 81 // Synchronously runs |callback| with each ScriptContext that belongs to |
82 // |extension_id| in |render_view|. | 82 // |extension_id| in |render_view|. |
83 // | 83 // |
84 // An empty |extension_id| will match all extensions, and a NULL |render_view| | 84 // An empty |extension_id| will match all extensions, and a NULL |render_view| |
85 // will match all render views, but try to use the inline variants of these | 85 // will match all render views, but try to use the inline variants of these |
86 // methods instead. | 86 // methods instead. |
87 void ForEach(const std::string& extension_id, | 87 void ForEach(const std::string& extension_id, |
88 content::RenderView* render_view, | 88 content::RenderView* render_view, |
89 const base::Callback<void(ScriptContext*)>& callback) const; | 89 const base::Callback<void(ScriptContext*)>& callback) const; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 // The set of all ScriptContexts we own. | 137 // The set of all ScriptContexts we own. |
138 std::set<ScriptContext*> contexts_; | 138 std::set<ScriptContext*> contexts_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(ScriptContextSet); | 140 DISALLOW_COPY_AND_ASSIGN(ScriptContextSet); |
141 }; | 141 }; |
142 | 142 |
143 } // namespace extensions | 143 } // namespace extensions |
144 | 144 |
145 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ | 145 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ |
OLD | NEW |