OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 // If the specified context is contained in this set, remove it, then delete | 45 // If the specified context is contained in this set, remove it, then delete |
46 // it asynchronously. After this call returns the context object will still | 46 // it asynchronously. After this call returns the context object will still |
47 // be valid, but its frame() pointer will be cleared. | 47 // be valid, but its frame() pointer will be cleared. |
48 void Remove(ChromeV8Context* context); | 48 void Remove(ChromeV8Context* context); |
49 | 49 |
50 // Returns a copy to protect against changes. | 50 // Returns a copy to protect against changes. |
51 typedef std::set<ChromeV8Context*> ContextSet; | 51 typedef std::set<ChromeV8Context*> ContextSet; |
52 ContextSet GetAll() const; | 52 ContextSet GetAll() const; |
53 | 53 |
54 // Gets the ChromeV8Context corresponding to the v8::Context that is | 54 // Gets the ChromeV8Context corresponding to v8::Context::GetCurrent(), or |
55 // on the top of the stack, or NULL if no such context exists. | 55 // NULL if no such context exists. |
56 ChromeV8Context* GetCurrent() const; | 56 ChromeV8Context* GetCurrent() const; |
57 | 57 |
| 58 // Gets the ChromeV8Context corresponding to v8::Context::GetCalling(), or |
| 59 // NULL if no such context exists. |
| 60 ChromeV8Context* GetCalling() const; |
| 61 |
58 // Gets the ChromeV8Context corresponding to the specified | 62 // Gets the ChromeV8Context corresponding to the specified |
59 // v8::Context or NULL if no such context exists. | 63 // v8::Context or NULL if no such context exists. |
60 ChromeV8Context* GetByV8Context(v8::Handle<v8::Context> context) const; | 64 ChromeV8Context* GetByV8Context(v8::Handle<v8::Context> context) const; |
61 | 65 |
62 // Synchronously runs |callback| with each ChromeV8Context that belongs to | 66 // Synchronously runs |callback| with each ChromeV8Context that belongs to |
63 // |extension_id| in |render_view|. | 67 // |extension_id| in |render_view|. |
64 // | 68 // |
65 // |extension_id| may be "" to match all extensions. | 69 // |extension_id| may be "" to match all extensions. |
66 // |render_view| may be NULL to match all render views. | 70 // |render_view| may be NULL to match all render views. |
67 void ForEach(const std::string& extension_id, | 71 void ForEach(const std::string& extension_id, |
68 content::RenderView* render_view, | 72 content::RenderView* render_view, |
69 const base::Callback<void(ChromeV8Context*)>& callback) const; | 73 const base::Callback<void(ChromeV8Context*)>& callback) const; |
70 | 74 |
71 // Cleans up contexts belonging to an unloaded extension. | 75 // Cleans up contexts belonging to an unloaded extension. |
72 // | 76 // |
73 // Returns the set of ChromeV8Contexts that were removed as a result. These | 77 // Returns the set of ChromeV8Contexts that were removed as a result. These |
74 // are safe to interact with until the end of the current event loop, since | 78 // are safe to interact with until the end of the current event loop, since |
75 // they're deleted asynchronously. | 79 // they're deleted asynchronously. |
76 ContextSet OnExtensionUnloaded(const std::string& extension_id); | 80 ContextSet OnExtensionUnloaded(const std::string& extension_id); |
77 | 81 |
78 private: | 82 private: |
79 ContextSet contexts_; | 83 ContextSet contexts_; |
80 | 84 |
81 DISALLOW_COPY_AND_ASSIGN(ChromeV8ContextSet); | 85 DISALLOW_COPY_AND_ASSIGN(ChromeV8ContextSet); |
82 }; | 86 }; |
83 | 87 |
84 } // namespace extensions | 88 } // namespace extensions |
85 | 89 |
86 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ | 90 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ |
OLD | NEW |