Title: [124962] trunk/Source/WebCore
Revision
124962
Author
[email protected]
Date
2012-08-07 18:18:04 -0700 (Tue, 07 Aug 2012)

Log Message

[V8] Move setIsolatedWorldSecurityOrigin() from V8Proxy to ScriptController
https://bugs.webkit.org/show_bug.cgi?id=93334

Reviewed by Adam Barth.

The goal is to move factor out V8Proxy methods to ScriptController.
As a starting point, this patch moves setIsolatedWorldSecurityOrigin().

isolatedWorlds() and isolatedWorldSecurityOrigins() are temporary methods.
They will be soon removed after moving all related methods
and m_isolatedWorlds and m_isolatedWorldSecurityOrigins.

No tests. No change in behavior.

* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::setIsolatedWorldSecurityOrigin):
* bindings/v8/V8Proxy.cpp:
* bindings/v8/V8Proxy.h:
(WebCore):
(V8Proxy):
(WebCore::V8Proxy::isolatedWorlds):
(WebCore::V8Proxy::isolatedWorldSecurityOrigins):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124961 => 124962)


--- trunk/Source/WebCore/ChangeLog	2012-08-08 01:17:14 UTC (rev 124961)
+++ trunk/Source/WebCore/ChangeLog	2012-08-08 01:18:04 UTC (rev 124962)
@@ -1,3 +1,28 @@
+2012-08-07  Kentaro Hara  <[email protected]>
+
+        [V8] Move setIsolatedWorldSecurityOrigin() from V8Proxy to ScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=93334
+
+        Reviewed by Adam Barth.
+
+        The goal is to move factor out V8Proxy methods to ScriptController.
+        As a starting point, this patch moves setIsolatedWorldSecurityOrigin().
+
+        isolatedWorlds() and isolatedWorldSecurityOrigins() are temporary methods.
+        They will be soon removed after moving all related methods
+        and m_isolatedWorlds and m_isolatedWorldSecurityOrigins.
+
+        No tests. No change in behavior.
+
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::setIsolatedWorldSecurityOrigin):
+        * bindings/v8/V8Proxy.cpp:
+        * bindings/v8/V8Proxy.h:
+        (WebCore):
+        (V8Proxy):
+        (WebCore::V8Proxy::isolatedWorlds):
+        (WebCore::V8Proxy::isolatedWorldSecurityOrigins):
+
 2012-08-07  Yoshifumi Inoue  <[email protected]>
 
         translateZ(0) shifts file name in file input

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (124961 => 124962)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-08 01:17:14 UTC (rev 124961)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-08 01:18:04 UTC (rev 124962)
@@ -181,7 +181,11 @@
 
 void ScriptController::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin> securityOrigin)
 {
-    m_proxy->setIsolatedWorldSecurityOrigin(worldID, securityOrigin);
+    ASSERT(worldID);
+    m_proxy->isolatedWorldSecurityOrigins().set(worldID, securityOrigin);
+    IsolatedWorldMap::iterator iter = m_proxy->isolatedWorlds().find(worldID);
+    if (iter != m_proxy->isolatedWorlds().end())
+        iter->second->setSecurityOrigin(securityOrigin);
 }
 
 // Evaluate a script file in the environment of this proxy.

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (124961 => 124962)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-08 01:17:14 UTC (rev 124961)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-08 01:18:04 UTC (rev 124962)
@@ -218,16 +218,6 @@
     return handleScope.Close(results);
 }
 
-void V8Proxy::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin> prpSecurityOriginIn)
-{
-    ASSERT(worldID);
-    RefPtr<SecurityOrigin> securityOrigin = prpSecurityOriginIn;
-    m_isolatedWorldSecurityOrigins.set(worldID, securityOrigin);
-    IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldID);
-    if (iter != m_isolatedWorlds.end())
-        iter->second->setSecurityOrigin(securityOrigin);
-}
-
 PassOwnPtr<v8::ScriptData> V8Proxy::precompileScript(v8::Handle<v8::String> code, CachedScript* cachedScript)
 {
     // A pseudo-randomly chosen ID used to store and retrieve V8 ScriptData from

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (124961 => 124962)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-08 01:17:14 UTC (rev 124961)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-08 01:18:04 UTC (rev 124962)
@@ -42,6 +42,7 @@
 #include "WrapperTypeInfo.h"
 #include <v8.h>
 #include <wtf/Forward.h>
+#include <wtf/HashMap.h>
 #include <wtf/PassRefPtr.h> // so generated bindings don't have to
 #include <wtf/Vector.h>
 #include <wtf/text/TextPosition.h>
@@ -71,6 +72,16 @@
     // The list of extensions that are registered for use with V8.
     typedef WTF::Vector<v8::Extension*> V8Extensions;
 
+    // Note: although the pointer is raw, the instance is kept alive by a strong
+    // reference to the v8 context it contains, which is not made weak until we
+    // call world->destroy().
+    //
+    // FIXME: We want to eventually be holding window shells instead of the
+    //        IsolatedContext directly.
+    typedef HashMap<int, V8IsolatedContext*> IsolatedWorldMap;
+
+    typedef HashMap<int, RefPtr<SecurityOrigin> > IsolatedWorldSecurityOriginMap;
+
     class V8Proxy {
     public:
         // The types of _javascript_ errors that can be thrown.
@@ -99,8 +110,6 @@
         // constructors.
         v8::Local<v8::Array> evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup);
 
-        void setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin>);
-
         // Evaluate a script file in the current execution environment.
         // The caller must hold an execution context.
         // If cannot evalute the script, it returns an error.
@@ -171,6 +180,12 @@
 
         static void reportUnsafeAccessTo(Document* targetDocument);
 
+        // FIXME: Move m_isolatedWorlds to ScriptController and remove this getter.
+        IsolatedWorldMap& isolatedWorlds() { return m_isolatedWorlds; }
+
+        // FIXME: Move m_isolatedWorldSecurityOrigins to ScriptController and remove this getter.
+        IsolatedWorldSecurityOriginMap& isolatedWorldSecurityOrigins() { return m_isolatedWorldSecurityOrigins; }
+
     private:
         void resetIsolatedWorlds();
 
@@ -189,17 +204,8 @@
         // The isolated worlds we are tracking for this frame. We hold them alive
         // here so that they can be used again by future calls to
         // evaluateInIsolatedWorld().
-        //
-        // Note: although the pointer is raw, the instance is kept alive by a strong
-        // reference to the v8 context it contains, which is not made weak until we
-        // call world->destroy().
-        //
-        // FIXME: We want to eventually be holding window shells instead of the
-        //        IsolatedContext directly.
-        typedef HashMap<int, V8IsolatedContext*> IsolatedWorldMap;
         IsolatedWorldMap m_isolatedWorlds;
         
-        typedef HashMap<int, RefPtr<SecurityOrigin> > IsolatedWorldSecurityOriginMap;
         IsolatedWorldSecurityOriginMap m_isolatedWorldSecurityOrigins;
     };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to