Changeset 109392 in webkit


Ignore:
Timestamp:
Mar 1, 2012 12:29:55 PM (12 years ago)
Author:
abarth@webkit.org
Message:

DOMWindow shouldn't have any INDEXED_DATABASE ifdefs
https://bugs.webkit.org/show_bug.cgi?id=80013

Reviewed by Kentaro Hara.

Before this patch, DOMWindow still knew about IDB because of the
database factory. This patch moves the factory to
DOMWindowIndexedDatabase.

  • Modules/indexeddb/DOMWindowIndexedDatabase.cpp:

(WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase):
(WebCore::DOMWindowIndexedDatabase::from):
(WebCore):
(WebCore::DOMWindowIndexedDatabase::disconnectFrame):
(WebCore::DOMWindowIndexedDatabase::webkitIndexedDB):

  • Modules/indexeddb/DOMWindowIndexedDatabase.h:

(DOMWindowIndexedDatabase):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::~DOMWindow):
(WebCore::DOMWindow::clear):
(WebCore):

  • page/DOMWindow.h:

(DOMWindow):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109386 r109392  
     12012-03-01  Adam Barth  <abarth@webkit.org>
     2
     3        DOMWindow shouldn't have any INDEXED_DATABASE ifdefs
     4        https://bugs.webkit.org/show_bug.cgi?id=80013
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Before this patch, DOMWindow still knew about IDB because of the
     9        database factory.  This patch moves the factory to
     10        DOMWindowIndexedDatabase.
     11
     12        * Modules/indexeddb/DOMWindowIndexedDatabase.cpp:
     13        (WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase):
     14        (WebCore::DOMWindowIndexedDatabase::from):
     15        (WebCore):
     16        (WebCore::DOMWindowIndexedDatabase::disconnectFrame):
     17        (WebCore::DOMWindowIndexedDatabase::webkitIndexedDB):
     18        * Modules/indexeddb/DOMWindowIndexedDatabase.h:
     19        (DOMWindowIndexedDatabase):
     20        * page/DOMWindow.cpp:
     21        (WebCore::DOMWindow::~DOMWindow):
     22        (WebCore::DOMWindow::clear):
     23        (WebCore):
     24        * page/DOMWindow.h:
     25        (DOMWindow):
     26
    1272012-03-01  Anders Carlsson  <andersca@apple.com>
    228
  • trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp

    r109370 r109392  
    3838namespace WebCore {
    3939
    40 DOMWindowIndexedDatabase::DOMWindowIndexedDatabase()
     40DOMWindowIndexedDatabase::DOMWindowIndexedDatabase(DOMWindow* window)
     41    : DOMWindowProperty(window->frame())
     42    , m_window(window)
    4143{
    4244}
     
    4648}
    4749
     50DOMWindowIndexedDatabase* DOMWindowIndexedDatabase::from(DOMWindow* window)
     51{
     52    DEFINE_STATIC_LOCAL(AtomicString, name, ("DOMWindowIndexedDatabase"));
     53    DOMWindowIndexedDatabase* supplement = static_cast<DOMWindowIndexedDatabase*>(Supplement<DOMWindow>::from(window, name));
     54    if (!supplement) {
     55        supplement = new DOMWindowIndexedDatabase(window);
     56        provideTo(window, name, adoptPtr(supplement));
     57    }
     58    return supplement;
     59}
     60
     61void DOMWindowIndexedDatabase::disconnectFrame()
     62{
     63    m_idbFactory = 0;
     64    DOMWindowProperty::disconnectFrame();
     65}
     66
    4867IDBFactory* DOMWindowIndexedDatabase::webkitIndexedDB(DOMWindow* window)
    4968{
    50     Document* document = window->document();
     69    return from(window)->webkitIndexedDB();
     70}
     71
     72IDBFactory* DOMWindowIndexedDatabase::webkitIndexedDB()
     73{
     74    Document* document = m_window->document();
    5175    if (!document)
    5276        return 0;
     
    5983        return 0;
    6084
    61     if (!window->idbFactory() && window->isCurrentlyDisplayedInFrame())
    62         window->setIDBFactory(IDBFactory::create(page->group().idbFactory()));
    63     return window->idbFactory();
     85    if (!m_idbFactory && m_window->isCurrentlyDisplayedInFrame())
     86        m_idbFactory = IDBFactory::create(page->group().idbFactory());
     87    return m_idbFactory.get();
    6488}
    6589
  • trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h

    r109370 r109392  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
     31#include "DOMWindowProperty.h"
     32#include "Supplementable.h"
     33
    3134namespace WebCore {
    3235
     
    3437class DOMWindow;
    3538
    36 class DOMWindowIndexedDatabase {
     39class DOMWindowIndexedDatabase : public DOMWindowProperty, public Supplement<DOMWindow> {
    3740public:
     41    virtual ~DOMWindowIndexedDatabase();
     42    static DOMWindowIndexedDatabase* from(DOMWindow*);
     43
    3844    static IDBFactory* webkitIndexedDB(DOMWindow*);
    3945
     46    virtual void disconnectFrame() OVERRIDE;
     47
    4048private:
    41     DOMWindowIndexedDatabase();
    42     ~DOMWindowIndexedDatabase();
     49    explicit DOMWindowIndexedDatabase(DOMWindow*);
     50
     51    IDBFactory* webkitIndexedDB();
     52
     53    DOMWindow* m_window;
     54    RefPtr<IDBFactory> m_idbFactory;
    4355};
    4456
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r109370 r109392  
    421421    ASSERT(!m_notifications);
    422422#endif
    423 #if ENABLE(INDEXED_DATABASE)
    424     ASSERT(!m_idbFactory);
    425 #endif
    426423#if ENABLE(BLOB)
    427424    ASSERT(!m_domURL);
     
    532529    resetNotifications();
    533530#endif
    534 #if ENABLE(INDEXED_DATABASE)
    535     m_idbFactory = 0;
    536 #endif
    537531#if ENABLE(BLOB)
    538532    m_domURL = 0;
     
    738732    m_notifications->disconnectFrame();
    739733    m_notifications = 0;
    740 }
    741 #endif
    742 
    743 #if ENABLE(INDEXED_DATABASE)
    744 void DOMWindow::setIDBFactory(PassRefPtr<IDBFactory> idbFactory)
    745 {
    746     m_idbFactory = idbFactory;
    747734}
    748735#endif
  • trunk/Source/WebCore/page/DOMWindow.h

    r109370 r109392  
    3131#include "FrameDestructionObserver.h"
    3232#include "KURL.h"
     33#include "Supplementable.h"
    3334
    3435namespace WebCore {
     
    8182    enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
    8283
    83     class DOMWindow : public RefCounted<DOMWindow>, public EventTarget, public FrameDestructionObserver {
     84    class DOMWindow : public RefCounted<DOMWindow>, public EventTarget, public FrameDestructionObserver, public Supplementable<DOMWindow> {
    8485    public:
    8586        static PassRefPtr<DOMWindow> create(Frame* frame) { return adoptRef(new DOMWindow(frame)); }
     
    394395        bool isCurrentlyDisplayedInFrame() const;
    395396
    396 #if ENABLE(INDEXED_DATABASE)
    397         IDBFactory* idbFactory() { return m_idbFactory.get(); }
    398         void setIDBFactory(PassRefPtr<IDBFactory>);
    399 #endif
    400 
    401397    private:
    402398        explicit DOMWindow(Frame*);
     
    446442        mutable RefPtr<Storage> m_sessionStorage;
    447443        mutable RefPtr<Storage> m_localStorage;
    448 
    449 #if ENABLE(INDEXED_DATABASE)
    450         mutable RefPtr<IDBFactory> m_idbFactory;
    451 #endif
    452 
    453444        mutable RefPtr<DOMApplicationCache> m_applicationCache;
    454445
Note: See TracChangeset for help on using the changeset viewer.