Changeset 125884 in webkit


Ignore:
Timestamp:
Aug 17, 2012 5:22:37 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Refactor away IsolatedWorld
https://bugs.webkit.org/show_bug.cgi?id=93971

Patch by Dan Carney <dcarney@google.com> on 2012-08-17
Reviewed by Kentaro Hara.

Remove IsolatedWorld class as it was 1:1 with DOMWrapperWorld.
This update fixes a bad assertion which caused the previous
version to be rolled back.

No tests. No change in functionality.

  • UseV8.cmake:
  • WebCore.gypi:
  • bindings/v8/DOMWrapperWorld.cpp:

(WebCore):
(WebCore::mainThreadNormalWorld):

  • bindings/v8/DOMWrapperWorld.h:

(WebCore):
(DOMWrapperWorld):
(WebCore::DOMWrapperWorld::create):
(WebCore::DOMWrapperWorld::~DOMWrapperWorld):
(WebCore::DOMWrapperWorld::count):
(WebCore::DOMWrapperWorld::worldId):
(WebCore::DOMWrapperWorld::domDataStore):
(WebCore::DOMWrapperWorld::DOMWrapperWorld):

  • bindings/v8/IsolatedWorld.cpp: Removed.
  • bindings/v8/IsolatedWorld.h: Removed.
  • bindings/v8/V8DOMWrapper.h:

(WebCore::V8DOMWrapper::getCachedWrapper):

  • bindings/v8/V8IsolatedContext.cpp:

(WebCore::V8IsolatedContext::V8IsolatedContext):
(WebCore::V8IsolatedContext::destroy):

  • bindings/v8/V8IsolatedContext.h:

(WebCore::V8IsolatedContext::getEntered):
(WebCore::V8IsolatedContext::world):
(V8IsolatedContext):

  • bindings/v8/V8PerIsolateData.h:

(WebCore::V8PerIsolateData::registerDOMDataStore):
(WebCore::V8PerIsolateData::unregisterDOMDataStore):

Location:
trunk/Source/WebCore
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r125883 r125884  
     12012-08-17  Dan Carney  <dcarney@google.com>
     2
     3        Refactor away IsolatedWorld
     4        https://bugs.webkit.org/show_bug.cgi?id=93971
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Remove IsolatedWorld class as it was 1:1 with DOMWrapperWorld.
     9        This update fixes a bad assertion which caused the previous
     10        version to be rolled back.
     11
     12        No tests.  No change in functionality.
     13
     14        * UseV8.cmake:
     15        * WebCore.gypi:
     16        * bindings/v8/DOMWrapperWorld.cpp:
     17        (WebCore):
     18        (WebCore::mainThreadNormalWorld):
     19        * bindings/v8/DOMWrapperWorld.h:
     20        (WebCore):
     21        (DOMWrapperWorld):
     22        (WebCore::DOMWrapperWorld::create):
     23        (WebCore::DOMWrapperWorld::~DOMWrapperWorld):
     24        (WebCore::DOMWrapperWorld::count):
     25        (WebCore::DOMWrapperWorld::worldId):
     26        (WebCore::DOMWrapperWorld::domDataStore):
     27        (WebCore::DOMWrapperWorld::DOMWrapperWorld):
     28        * bindings/v8/IsolatedWorld.cpp: Removed.
     29        * bindings/v8/IsolatedWorld.h: Removed.
     30        * bindings/v8/V8DOMWrapper.h:
     31        (WebCore::V8DOMWrapper::getCachedWrapper):
     32        * bindings/v8/V8IsolatedContext.cpp:
     33        (WebCore::V8IsolatedContext::V8IsolatedContext):
     34        (WebCore::V8IsolatedContext::destroy):
     35        * bindings/v8/V8IsolatedContext.h:
     36        (WebCore::V8IsolatedContext::getEntered):
     37        (WebCore::V8IsolatedContext::world):
     38        (V8IsolatedContext):
     39        * bindings/v8/V8PerIsolateData.h:
     40        (WebCore::V8PerIsolateData::registerDOMDataStore):
     41        (WebCore::V8PerIsolateData::unregisterDOMDataStore):
     42
    1432012-08-17  Kangil Han  <kangil.han@samsung.com>
    244
  • trunk/Source/WebCore/UseV8.cmake

    r125865 r125884  
    2626    bindings/v8/IDBBindingUtilities.cpp
    2727    bindings/v8/IDBCustomBindings.cpp
    28     bindings/v8/IsolatedWorld.cpp
    2928    bindings/v8/Dictionary.cpp
    3029    bindings/v8/PageScriptDebugServer.cpp
  • trunk/Source/WebCore/WebCore.gypi

    r125866 r125884  
    21832183            'bindings/v8/IDBCustomBindings.cpp',
    21842184            'bindings/v8/IntrusiveDOMWrapperMap.h',
    2185             'bindings/v8/IsolatedWorld.cpp',
    2186             'bindings/v8/IsolatedWorld.h',
    21872185            'bindings/v8/JavaScriptCallFrame.cpp',
    21882186            'bindings/v8/JavaScriptCallFrame.h',
  • trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp

    r125831 r125884  
    3737namespace WebCore {
    3838
    39 DOMWrapperWorld::DOMWrapperWorld()
    40 {
    41     // This class is pretty boring, huh?
    42 }
     39int DOMWrapperWorld::isolatedWorldCount = 0;
    4340
    4441DOMWrapperWorld* mainThreadNormalWorld()
    4542{
    4643    ASSERT(isMainThread());
    47     DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedNormalWorld, (DOMWrapperWorld::create()));
     44    DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedNormalWorld, (DOMWrapperWorld::create(DOMWrapperWorld::mainWorldId)));
    4845    return cachedNormalWorld.get();
    4946}
  • trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h

    r125831 r125884  
    3232#define DOMWrapperWorld_h
    3333
     34#include "DOMDataStore.h"
    3435#include <wtf/PassRefPtr.h>
    3536#include <wtf/RefCounted.h>
     
    3940
    4041// This class represent a collection of DOM wrappers for a specific world.
    41 // The base class is pretty boring because the wrappers are actually stored
    42 // statically in V8DOMMap and garbage collected by V8 itself.
    4342class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
    4443public:
    45     static PassRefPtr<DOMWrapperWorld> create() { return adoptRef(new DOMWrapperWorld()); }
    46     virtual ~DOMWrapperWorld() {}
     44    static const int mainWorldId = -1;
     45    static PassRefPtr<DOMWrapperWorld> create(int worldId = mainWorldId) { return adoptRef(new DOMWrapperWorld(worldId)); }
     46    ~DOMWrapperWorld()
     47    {
     48        if (m_worldId != mainWorldId)
     49            isolatedWorldCount--;
     50    }
     51    static int count() { return isolatedWorldCount; }
    4752
    48 protected:
    49     DOMWrapperWorld();
     53    int worldId() const { return m_worldId; }
     54    DOMDataStore* domDataStore() const { return m_domDataStore.getStore(); }
     55
     56private:
     57    DOMWrapperWorld(int worldId)
     58        : m_worldId(worldId)
     59    {
     60        if (m_worldId != mainWorldId)
     61            isolatedWorldCount++;
     62    }
     63
     64    // The backing store for the isolated world's DOM wrappers. This class
     65    // doesn't have visibility into the wrappers. This handle simply helps
     66    // manage their lifetime.
     67    DOMDataStoreHandle m_domDataStore;
     68
     69    const int m_worldId;
     70    static int isolatedWorldCount;
    5071};
    5172
  • trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h

    r125831 r125884  
    3434#include "DOMDataStore.h"
    3535#include "Event.h"
    36 #include "IsolatedWorld.h"
    3736#include "Node.h"
    3837#include "NodeFilter.h"
     
    131130        {
    132131            ASSERT(isMainThread());
    133             if (LIKELY(!IsolatedWorld::count())) {
     132            if (LIKELY(!DOMWrapperWorld::count())) {
    134133                v8::Persistent<v8::Object>* wrapper = node->wrapper();
    135134                if (LIKELY(!!wrapper))
  • trunk/Source/WebCore/bindings/v8/V8IsolatedContext.cpp

    r125831 r125884  
    6767
    6868V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int worldId)
    69     : m_world(IsolatedWorld::create(worldId)),
     69    : m_world(DOMWrapperWorld::create(worldId)),
    7070      m_frame(proxy->frame())
    7171{
     
    7676
    7777    // FIXME: We should be creating a new V8DOMWindowShell here instead of riping out the context.
    78     m_context = SharedPersistent<v8::Context>::create(proxy->windowShell()->createNewContext(v8::Handle<v8::Object>(), extensionGroup, m_world->id()));
     78    m_context = SharedPersistent<v8::Context>::create(proxy->windowShell()->createNewContext(v8::Handle<v8::Object>(), extensionGroup, m_world->worldId()));
    7979    if (m_context->get().IsEmpty())
    8080        return;
     
    102102    m_context->get()->UseDefaultSecurityToken();
    103103
    104     m_frame->loader()->client()->didCreateScriptContext(context(), extensionGroup, m_world->id());
     104    m_frame->loader()->client()->didCreateScriptContext(context(), extensionGroup, m_world->worldId());
    105105}
    106106
     
    108108{
    109109    m_perContextData.clear();
    110     m_frame->loader()->client()->willReleaseScriptContext(context(), m_world->id());
     110    m_frame->loader()->client()->willReleaseScriptContext(context(), m_world->worldId());
    111111    m_context->get().MakeWeak(this, &contextWeakReferenceCallback);
    112112    m_frame = 0;
  • trunk/Source/WebCore/bindings/v8/V8IsolatedContext.h

    r125831 r125884  
    3232#define V8IsolatedContext_h
    3333
    34 #include "IsolatedWorld.h"
     34#include "DOMWrapperWorld.h"
    3535#include "ScriptSourceCode.h" // for WebCore::ScriptSourceCode
    3636#include "SharedPersistent.h"
     
    8383        // Until then, we optimize the common case of not having any isolated
    8484        // worlds at all.
    85         if (!IsolatedWorld::count())
     85        if (!DOMWrapperWorld::count())
    8686            return 0;
    8787        if (!v8::Context::InContext())
     
    9393    PassRefPtr<SharedPersistent<v8::Context> > sharedContext() { return m_context; }
    9494
    95     IsolatedWorld* world() const { return m_world.get(); }
     95    DOMWrapperWorld* world() const { return m_world.get(); }
    9696
    9797    SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
     
    116116    RefPtr<SharedPersistent<v8::Context> > m_context;
    117117
    118     RefPtr<IsolatedWorld> m_world;
     118    RefPtr<DOMWrapperWorld> m_world;
    119119
    120120    RefPtr<SecurityOrigin> m_securityOrigin;
  • trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h

    r125216 r125884  
    9191    void registerDOMDataStore(DOMDataStore* domDataStore)
    9292    {
     93        ASSERT(m_domDataList.find(domDataStore) == notFound);
    9394        m_domDataList.append(domDataStore);
    9495    }
     
    9697    void unregisterDOMDataStore(DOMDataStore* domDataStore)
    9798    {
    98         ASSERT(m_domDataList.find(domDataStore));
     99        ASSERT(m_domDataList.find(domDataStore) != notFound);
    99100        m_domDataList.remove(m_domDataList.find(domDataStore));
    100101    }
Note: See TracChangeset for help on using the changeset viewer.