summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/V8IsolatedWorld.h
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-10-08 17:19:54 +0100
committerSteve Block <steveblock@google.com>2009-10-20 00:41:58 +0100
commit231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch)
treea6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebCore/bindings/v8/V8IsolatedWorld.h
parente196732677050bd463301566a68a643b6d14b907 (diff)
downloadexternal_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebCore/bindings/v8/V8IsolatedWorld.h')
-rw-r--r--WebCore/bindings/v8/V8IsolatedWorld.h42
1 files changed, 31 insertions, 11 deletions
diff --git a/WebCore/bindings/v8/V8IsolatedWorld.h b/WebCore/bindings/v8/V8IsolatedWorld.h
index 2036e65..15d8711 100644
--- a/WebCore/bindings/v8/V8IsolatedWorld.h
+++ b/WebCore/bindings/v8/V8IsolatedWorld.h
@@ -35,6 +35,7 @@
#include "V8DOMMap.h"
#include "V8Index.h"
+#include "V8Proxy.h"
#include "V8Utilities.h"
#include "ScriptSourceCode.h" // for WebCore::ScriptSourceCode
@@ -57,11 +58,14 @@ namespace WebCore {
//
class V8IsolatedWorld {
public:
- ~V8IsolatedWorld();
+ // Creates an isolated world. To destroy it, call destroy().
+ // This will delete the isolated world when the context it owns is GC'd.
+ V8IsolatedWorld(V8Proxy* proxy, int extensionGroup);
- // Evaluate JavaScript in a new isolated world. The script has access
- // to the DOM of the document associated with |proxy|.
- static void evaluate(const Vector<ScriptSourceCode>& sources, V8Proxy* proxy, int extensionGroup);
+ // Call this to destroy the isolated world. It will be deleted sometime
+ // after this call, once all script references to the world's context
+ // have been dropped.
+ void destroy();
// Returns the isolated world associated with
// v8::Context::GetEntered(). Because worlds are isolated, the entire
@@ -71,26 +75,42 @@ namespace WebCore {
// FIXME: Consider edge cases with DOM mutation events that might
// violate this invariant.
//
- static V8IsolatedWorld* getEntered();
+ static V8IsolatedWorld* getEntered()
+ {
+ // This is a temporary performance optimization. Essentially,
+ // GetHiddenValue is too slow for this code path. We need to get the
+ // V8 team to add a real property to v8::Context for isolated worlds.
+ // Until then, we optimize the common case of not having any isolated
+ // worlds at all.
+ if (!isolatedWorldCount)
+ return 0;
+ return getEnteredImpl();
+ }
- v8::Handle<v8::Context> context() { return m_context; }
+ v8::Handle<v8::Context> context() { return m_context->get(); }
+ PassRefPtr<SharedPersistent<v8::Context> > shared_context() { return m_context; }
DOMDataStore* getDOMDataStore() const { return m_domDataStore.getStore(); }
private:
- // The lifetime of an isolated world is managed by the V8 garbage
- // collector. In particular, the object created by this constructor is
- // freed when |context| is garbage collected.
- explicit V8IsolatedWorld(v8::Handle<v8::Context> context);
+ ~V8IsolatedWorld();
+
+ static V8IsolatedWorld* getEnteredImpl();
+
+ // Called by the garbage collector when our JavaScript context is about
+ // to be destroyed.
+ static void contextWeakReferenceCallback(v8::Persistent<v8::Value> object, void* isolated_world);
// The v8::Context for the isolated world. This object is keep on the
// heap as long as |m_context| has not been garbage collected.
- v8::Persistent<v8::Context> m_context;
+ RefPtr<SharedPersistent<v8::Context> > m_context;
// The backing store for the isolated world's DOM wrappers. This class
// doesn't have visibility into the wrappers. This handle simply helps
// manage their lifetime.
DOMDataStoreHandle m_domDataStore;
+
+ static int isolatedWorldCount;
};
} // namespace WebCore