Changeset 126465 in webkit


Ignore:
Timestamp:
Aug 23, 2012 12:16:46 PM (12 years ago)
Author:
abarth@webkit.org
Message:

[V8] V8ScriptInstance is much more complicated than necessary
https://bugs.webkit.org/show_bug.cgi?id=94785

Reviewed by Kentaro Hara.

V8ScriptInstance just needs to be a one-line wrapper around OwnHandle.

  • bindings/v8/OwnHandle.h:

(WebCore::OwnHandle::get):

  • bindings/v8/ScriptInstance.cpp:

(WebCore::V8ScriptInstance::V8ScriptInstance):
(WebCore::V8ScriptInstance::~V8ScriptInstance):
(WebCore::V8ScriptInstance::instance):

  • bindings/v8/ScriptInstance.h:

(WebCore::V8ScriptInstance::create):
(V8ScriptInstance):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126464 r126465  
     12012-08-23  Adam Barth  <abarth@webkit.org>
     2
     3        [V8] V8ScriptInstance is much more complicated than necessary
     4        https://bugs.webkit.org/show_bug.cgi?id=94785
     5
     6        Reviewed by Kentaro Hara.
     7
     8        V8ScriptInstance just needs to be a one-line wrapper around OwnHandle.
     9
     10        * bindings/v8/OwnHandle.h:
     11        (WebCore::OwnHandle::get):
     12        * bindings/v8/ScriptInstance.cpp:
     13        (WebCore::V8ScriptInstance::V8ScriptInstance):
     14        (WebCore::V8ScriptInstance::~V8ScriptInstance):
     15        (WebCore::V8ScriptInstance::instance):
     16        * bindings/v8/ScriptInstance.h:
     17        (WebCore::V8ScriptInstance::create):
     18        (V8ScriptInstance):
     19
    1202012-08-23  Christophe Dumez  <christophe.dumez@intel.com>
    221
  • trunk/Source/WebCore/bindings/v8/OwnHandle.h

    r126446 r126465  
    5353    }
    5454
    55     v8::Handle<T> get() const { return m_handle; }
     55    v8::Persistent<T> get() const { return m_handle; }
    5656
    5757    void set(v8::Handle<T> handle)
  • trunk/Source/WebCore/bindings/v8/ScriptInstance.cpp

    r126407 r126465  
    3232#include "ScriptInstance.h"
    3333
    34 #include "V8GCController.h"
    35 #include <wtf/Assertions.h>
    36 
    3734namespace WebCore {
    3835
    39 V8ScriptInstance::V8ScriptInstance()
     36V8ScriptInstance::V8ScriptInstance(v8::Handle<v8::Object> instance)
     37    : m_instance(instance)
    4038{
    4139}
    4240
    43 V8ScriptInstance::V8ScriptInstance(v8::Handle<v8::Object> instance)
    44 {
    45     set(instance);
    46 }
    47 
    48 V8ScriptInstance::~V8ScriptInstance()
    49 {
    50     clear();
    51 }
    52 
    53 v8::Persistent<v8::Object> V8ScriptInstance::instance()
    54 {
    55     return m_instance;
    56 }
    57 
    58 void V8ScriptInstance::clear()
    59 {
    60     if (m_instance.IsEmpty())
    61         return;
    62 #ifndef NDEBUG
    63     V8GCController::unregisterGlobalHandle(this, m_instance);
    64 #endif
    65     m_instance.Dispose();
    66     m_instance.Clear();
    67 }
    68 
    69 void V8ScriptInstance::set(v8::Handle<v8::Object> instance)
    70 {
    71     clear();
    72     if (instance.IsEmpty())
    73         return;
    74 
    75     m_instance = v8::Persistent<v8::Object>::New(instance);
    76 #ifndef NDEBUG
    77     V8GCController::registerGlobalHandle(SCRIPTINSTANCE, this, m_instance);
    78 #endif
    79 }
    80 
    8141} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/ScriptInstance.h

    r95901 r126465  
    3232#define ScriptInstance_h
    3333
     34#include "OwnHandle.h"
    3435#include <v8.h>
    35 
    3636#include <wtf/PassRefPtr.h>
    3737#include <wtf/RefCounted.h>
     
    4242class V8ScriptInstance : public RefCounted<V8ScriptInstance> {
    4343public:
    44     static PassRefPtr<V8ScriptInstance> create(v8::Handle<v8::Object> instance)
    45     {
    46         return adoptRef(new V8ScriptInstance(instance));
    47     }
    48     V8ScriptInstance();
    49     V8ScriptInstance(v8::Handle<v8::Object>);
    50     ~V8ScriptInstance();
    51     v8::Persistent<v8::Object> instance();
     44    static PassRefPtr<V8ScriptInstance> create(v8::Handle<v8::Object> instance) { return adoptRef(new V8ScriptInstance(instance)); }
     45
     46    v8::Persistent<v8::Object> instance() { return m_instance.get(); }
    5247
    5348private:
    54     void clear();
    55     void set(v8::Handle<v8::Object>);
    56     mutable v8::Persistent<v8::Object> m_instance;
     49    explicit V8ScriptInstance(v8::Handle<v8::Object>);
     50
     51    OwnHandle<v8::Object> m_instance;
    5752};
    5853
Note: See TracChangeset for help on using the changeset viewer.