Changeset 109319 in webkit


Ignore:
Timestamp:
Feb 29, 2012 11:46:27 PM (12 years ago)
Author:
abarth@webkit.org
Message:

ScriptExecutionContext has too many ifdef ENABLE(SQL_DATABASE)
https://bugs.webkit.org/show_bug.cgi?id=79633

Reviewed by Eric Seidel.

Source/WebCore:

This class creates a DatabaseContext object to supplement the
ScriptExecutionContext with database-specific information. This new
object lets us remove a bunch of database-specific (and ifdefed) logic
from ScriptExecutionContext.(cpp|h).

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.exp.in:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/ScriptExecutionContext.cpp:

(WebCore::ScriptExecutionContext::ScriptExecutionContext):
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
(WebCore):

  • dom/ScriptExecutionContext.h:

(WebCore):
(ScriptExecutionContext):

  • history/PageCache.cpp:

(WebCore::logCanCacheFrameDecision):
(WebCore::PageCache::canCachePageContainingThisFrame):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::stopLoading):

  • platform/Supplementable.h:

(WebCore::Supplementable::provideSupplement):
(WebCore::Supplementable::requireSupplement):
(Supplementable):

  • storage/AbstractDatabase.cpp:

(WebCore::AbstractDatabase::AbstractDatabase):

  • storage/AbstractDatabase.h:

(WebCore):
(WebCore::AbstractDatabase::databaseContext):
(AbstractDatabase):

  • storage/Database.cpp:

(WebCore::Database::openDatabase):
(WebCore::Database::Database):
(WebCore::Database::openAndVerifyVersion):
(WebCore::Database::markAsDeletedAndClose):
(WebCore::Database::close):
(WebCore::Database::closeImmediately):
(WebCore::Database::performOpenAndVerify):
(WebCore::Database::scheduleTransaction):
(WebCore::Database::scheduleTransactionStep):
(WebCore::Database::transactionClient):
(WebCore::Database::transactionCoordinator):
(WebCore::Database::tableNames):
(WebCore::Database::securityOrigin):

  • storage/DatabaseContext.cpp: Added.

(WebCore):
(WebCore::existingDatabaseContextFrom):
(WebCore::DatabaseContext::DatabaseContext):
(WebCore::DatabaseContext::~DatabaseContext):
(WebCore::DatabaseContext::from):
(WebCore::DatabaseContext::databaseThread):
(WebCore::DatabaseContext::hasOpenDatabases):
(WebCore::DatabaseContext::stopDatabases):

  • storage/DatabaseContext.h: Added.

(WebCore):
(DatabaseContext):
(WebCore::DatabaseContext::setHasOpenDatabases):

  • storage/SQLTransaction.cpp:

(WebCore::SQLTransaction::checkAndHandleClosedOrInterruptedDatabase):
(WebCore::SQLTransaction::notifyDatabaseThreadIsShuttingDown):

  • workers/WorkerThread.cpp:

(WebCore::WorkerThreadShutdownStartTask::performTask):

Source/WebKit/mac:

  • WebView/WebFrame.mm:

(-[WebFrame _cacheabilityDictionary]):

Location:
trunk/Source
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r109192 r109319  
    13881388    storage/Database.cpp
    13891389    storage/DatabaseAuthorizer.cpp
     1390    storage/DatabaseContext.cpp
    13901391    storage/DatabaseSync.cpp
    13911392    storage/DatabaseTask.cpp
  • trunk/Source/WebCore/ChangeLog

    r109313 r109319  
     12012-02-29  Adam Barth  <abarth@webkit.org>
     2
     3        ScriptExecutionContext has too many ifdef ENABLE(SQL_DATABASE)
     4        https://bugs.webkit.org/show_bug.cgi?id=79633
     5
     6        Reviewed by Eric Seidel.
     7
     8        This class creates a DatabaseContext object to supplement the
     9        ScriptExecutionContext with database-specific information.  This new
     10        object lets us remove a bunch of database-specific (and ifdefed) logic
     11        from ScriptExecutionContext.(cpp|h).
     12
     13        * CMakeLists.txt:
     14        * GNUmakefile.list.am:
     15        * Target.pri:
     16        * WebCore.exp.in:
     17        * WebCore.gypi:
     18        * WebCore.vcproj/WebCore.vcproj:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * dom/ScriptExecutionContext.cpp:
     21        (WebCore::ScriptExecutionContext::ScriptExecutionContext):
     22        (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
     23        (WebCore):
     24        * dom/ScriptExecutionContext.h:
     25        (WebCore):
     26        (ScriptExecutionContext):
     27        * history/PageCache.cpp:
     28        (WebCore::logCanCacheFrameDecision):
     29        (WebCore::PageCache::canCachePageContainingThisFrame):
     30        * loader/FrameLoader.cpp:
     31        (WebCore::FrameLoader::stopLoading):
     32        * platform/Supplementable.h:
     33        (WebCore::Supplementable::provideSupplement):
     34        (WebCore::Supplementable::requireSupplement):
     35        (Supplementable):
     36        * storage/AbstractDatabase.cpp:
     37        (WebCore::AbstractDatabase::AbstractDatabase):
     38        * storage/AbstractDatabase.h:
     39        (WebCore):
     40        (WebCore::AbstractDatabase::databaseContext):
     41        (AbstractDatabase):
     42        * storage/Database.cpp:
     43        (WebCore::Database::openDatabase):
     44        (WebCore::Database::Database):
     45        (WebCore::Database::openAndVerifyVersion):
     46        (WebCore::Database::markAsDeletedAndClose):
     47        (WebCore::Database::close):
     48        (WebCore::Database::closeImmediately):
     49        (WebCore::Database::performOpenAndVerify):
     50        (WebCore::Database::scheduleTransaction):
     51        (WebCore::Database::scheduleTransactionStep):
     52        (WebCore::Database::transactionClient):
     53        (WebCore::Database::transactionCoordinator):
     54        (WebCore::Database::tableNames):
     55        (WebCore::Database::securityOrigin):
     56        * storage/DatabaseContext.cpp: Added.
     57        (WebCore):
     58        (WebCore::existingDatabaseContextFrom):
     59        (WebCore::DatabaseContext::DatabaseContext):
     60        (WebCore::DatabaseContext::~DatabaseContext):
     61        (WebCore::DatabaseContext::from):
     62        (WebCore::DatabaseContext::databaseThread):
     63        (WebCore::DatabaseContext::hasOpenDatabases):
     64        (WebCore::DatabaseContext::stopDatabases):
     65        * storage/DatabaseContext.h: Added.
     66        (WebCore):
     67        (DatabaseContext):
     68        (WebCore::DatabaseContext::setHasOpenDatabases):
     69        * storage/SQLTransaction.cpp:
     70        (WebCore::SQLTransaction::checkAndHandleClosedOrInterruptedDatabase):
     71        (WebCore::SQLTransaction::notifyDatabaseThreadIsShuttingDown):
     72        * workers/WorkerThread.cpp:
     73        (WebCore::WorkerThreadShutdownStartTask::performTask):
     74
    1752012-02-29  Shinya Kawanaka  <shinyak@chromium.org>
    276
  • trunk/Source/WebCore/GNUmakefile.list.am

    r109192 r109319  
    38623862        Source/WebCore/storage/DOMWindowSQLDatabase.cpp \
    38633863        Source/WebCore/storage/DOMWindowSQLDatabase.h \
     3864        Source/WebCore/storage/Database.cpp \
     3865        Source/WebCore/storage/Database.h \
    38643866        Source/WebCore/storage/DatabaseAuthorizer.cpp \
    38653867        Source/WebCore/storage/DatabaseAuthorizer.h \
    38663868        Source/WebCore/storage/DatabaseCallback.h \
    3867         Source/WebCore/storage/Database.cpp \
     3869        Source/WebCore/storage/DatabaseContext.cpp \
     3870        Source/WebCore/storage/DatabaseContext.h \
    38683871        Source/WebCore/storage/DatabaseDetails.h \
    3869         Source/WebCore/storage/Database.h \
    38703872        Source/WebCore/storage/DatabaseSync.cpp \
    38713873        Source/WebCore/storage/DatabaseSync.h \
  • trunk/Source/WebCore/Target.pri

    r109192 r109319  
    13051305    storage/Database.cpp \
    13061306    storage/DatabaseAuthorizer.cpp \
     1307    storage/DatabaseContext.cpp \
    13071308    storage/DatabaseSync.cpp \
    13081309    storage/StorageTask.cpp \
  • trunk/Source/WebCore/WebCore.exp.in

    r109255 r109319  
    420420__ZN7WebCore15DOMWrapperWorld13clearWrappersEv
    421421__ZN7WebCore15DOMWrapperWorldD1Ev
     422__ZN7WebCore15DatabaseContext16hasOpenDatabasesEPNS_22ScriptExecutionContextE
    422423__ZN7WebCore15DatabaseTracker12deleteOriginEPNS_14SecurityOriginE
    423424__ZN7WebCore15DatabaseTracker14deleteDatabaseEPNS_14SecurityOriginERKN3WTF6StringE
  • trunk/Source/WebCore/WebCore.gypi

    r109297 r109319  
    46414641            'storage/DatabaseAuthorizer.h',
    46424642            'storage/DatabaseCallback.h',
     4643            'storage/DatabaseContext.cpp',
     4644            'storage/DatabaseContext.h',
    46434645            'storage/DatabaseSync.cpp',
    46444646            'storage/DatabaseSync.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r109192 r109319  
    7068370683                        </File>
    7068470684                        <File
     70685                                RelativePath="..\storage\DatabaseContext.cpp"
     70686                                >
     70687                        </File>
     70688                        <File
     70689                                RelativePath="..\storage\DatabaseContext.h"
     70690                                >
     70691                        </File>
     70692                        <File
    7068570693                                RelativePath="..\storage\DatabaseSync.cpp"
    7068670694                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r109192 r109319  
    33143314                97205ABB1239292700B17380 /* PluginDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97205AB91239292700B17380 /* PluginDocument.cpp */; };
    33153315                97205ABC1239292700B17380 /* PluginDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 97205ABA1239292700B17380 /* PluginDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3316                9724585214FB724800CA8746 /* DatabaseContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9724585014FB724800CA8746 /* DatabaseContext.cpp */; };
     3317                9724585314FB724800CA8746 /* DatabaseContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 9724585114FB724800CA8746 /* DatabaseContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    33163318                9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9728C3111268E4390041E89B /* MarkupAccumulator.cpp */; };
    33173319                9728C3141268E4390041E89B /* MarkupAccumulator.h in Headers */ = {isa = PBXBuildFile; fileRef = 9728C3121268E4390041E89B /* MarkupAccumulator.h */; };
     
    1018110183                97205AB91239292700B17380 /* PluginDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginDocument.cpp; sourceTree = "<group>"; };
    1018210184                97205ABA1239292700B17380 /* PluginDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginDocument.h; sourceTree = "<group>"; };
     10185                9724585014FB724800CA8746 /* DatabaseContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseContext.cpp; sourceTree = "<group>"; };
     10186                9724585114FB724800CA8746 /* DatabaseContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseContext.h; sourceTree = "<group>"; };
    1018310187                9728C3111268E4390041E89B /* MarkupAccumulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkupAccumulator.cpp; sourceTree = "<group>"; };
    1018410188                9728C3121268E4390041E89B /* MarkupAccumulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkupAccumulator.h; sourceTree = "<group>"; };
     
    1389513899                                B5D36019112F8B560048DEA8 /* DatabaseCallback.h */,
    1389613900                                B59DD68D1190298E007E9684 /* DatabaseCallback.idl */,
     13901                                9724585014FB724800CA8746 /* DatabaseContext.cpp */,
     13902                                9724585114FB724800CA8746 /* DatabaseContext.h */,
    1389713903                                5116D9750CF177BD00C2B84D /* DatabaseDetails.h */,
    1389813904                                B523CF031182675400EBB29C /* DatabaseSync.cpp */,
     
    2066520671                                BC60D6E80D28D83400B9918F /* DOMCoreException.h */,
    2066620672                                BC60D6EB0D28D99900B9918F /* DOMCoreException.idl */,
    20667                                 BC9A6142146859D9006057FD /* EventNames.in */,
    2066820673                                BC9A6141146859D9006057FD /* DOMExceptions.in */,
    2066920674                                A8185F3609765765005826D9 /* DOMImplementation.cpp */,
     
    2071420719                                939885C108B7E3D100E707C4 /* EventNames.cpp */,
    2071520720                                939885C208B7E3D100E707C4 /* EventNames.h */,
     20721                                BC9A6142146859D9006057FD /* EventNames.in */,
    2071620722                                8F6756191288B17B0047ACA3 /* EventQueue.h */,
    2071720723                                CE5CB1B314EDAB6F00BB2795 /* EventSender.h */,
     
    2155121557                                51A45B560CAD7FD7000D2BE9 /* DatabaseAuthorizer.h in Headers */,
    2155221558                                B5D3601A112F8B560048DEA8 /* DatabaseCallback.h in Headers */,
     21559                                9724585314FB724800CA8746 /* DatabaseContext.h in Headers */,
    2155321560                                5116D9770CF177BD00C2B84D /* DatabaseDetails.h in Headers */,
    2155421561                                B523CF0B1182675400EBB29C /* DatabaseSync.h in Headers */,
     
    2385323860                                BC2272BD0E82EAAE00E7F975 /* StyleRareNonInheritedData.h in Headers */,
    2385423861                                BC2272870E82E70700E7F975 /* StyleReflection.h in Headers */,
     23862                                E4BBED4D14FCDBA1003F0B98 /* StyleRule.h in Headers */,
    2385523863                                3138A9E51474434600B0ED12 /* StyleShader.h in Headers */,
    2385623864                                A8EA800C0A19516E00A8EF5F /* StyleSheet.h in Headers */,
     
    2435724365                                977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
    2435824366                                FD537353137B651800008DCE /* ZeroPole.h in Headers */,
    24359                                 E4BBED4D14FCDBA1003F0B98 /* StyleRule.h in Headers */,
    2436024367                        );
    2436124368                        runOnlyForDeploymentPostprocessing = 0;
     
    2496524972                                5196116A0CAC56570010A80C /* Database.cpp in Sources */,
    2496624973                                51A45B570CAD7FD7000D2BE9 /* DatabaseAuthorizer.cpp in Sources */,
     24974                                9724585214FB724800CA8746 /* DatabaseContext.cpp in Sources */,
    2496724975                                B523CF0A1182675400EBB29C /* DatabaseSync.cpp in Sources */,
    2496824976                                519611EB0CAC749C0010A80C /* DatabaseTask.cpp in Sources */,
     
    2691826926                                BC2272E30E82EE9B00E7F975 /* StyleRareInheritedData.cpp in Sources */,
    2691926927                                BC2272BC0E82EAAE00E7F975 /* StyleRareNonInheritedData.cpp in Sources */,
     26928                                E4BBED4C14FCDBA1003F0B98 /* StyleRule.cpp in Sources */,
    2692026929                                A8EA800D0A19516E00A8EF5F /* StyleSheet.cpp in Sources */,
    2692126930                                A8EA800B0A19516E00A8EF5F /* StyleSheetList.cpp in Sources */,
     
    2731027319                                977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
    2731127320                                FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
    27312                                 E4BBED4C14FCDBA1003F0B98 /* StyleRule.cpp in Sources */,
    2731327321                        );
    2731427322                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r107239 r109319  
    3131#include "ContentSecurityPolicy.h"
    3232#include "DOMTimer.h"
    33 #include "Database.h"
    34 #include "DatabaseTask.h"
    35 #include "DatabaseThread.h"
    3633#include "ErrorEvent.h"
    3734#include "EventListener.h"
     
    9592    , m_inDispatchErrorEvent(false)
    9693    , m_activeDOMObjectsAreSuspended(false)
    97 #if ENABLE(SQL_DATABASE)
    98     , m_hasOpenDatabases(false)
    99 #endif
    10094{
    10195}
     
    116110        (*iter)->contextDestroyed();
    117111    }
    118 #if ENABLE(SQL_DATABASE)
    119     if (m_databaseThread) {
    120         ASSERT(m_databaseThread->terminationRequested());
    121         m_databaseThread = 0;
    122     }
    123 #endif
    124112#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
    125113    if (m_fileThread) {
     
    133121#endif
    134122}
    135 
    136 #if ENABLE(SQL_DATABASE)
    137 
    138 DatabaseThread* ScriptExecutionContext::databaseThread()
    139 {
    140     if (!m_databaseThread && !m_hasOpenDatabases) {
    141         // Create the database thread on first request - but not if at least one database was already opened,
    142         // because in that case we already had a database thread and terminated it and should not create another.
    143         m_databaseThread = DatabaseThread::create();
    144         if (!m_databaseThread->start())
    145             m_databaseThread = 0;
    146     }
    147 
    148     return m_databaseThread.get();
    149 }
    150 
    151 void ScriptExecutionContext::stopDatabases(DatabaseTaskSynchronizer* cleanupSync)
    152 {
    153     ASSERT(isContextThread());
    154     if (m_databaseThread)
    155         m_databaseThread->requestTermination(cleanupSync);
    156     else if (cleanupSync)
    157         cleanupSync->taskCompleted();
    158 }
    159 
    160 #endif
    161123
    162124void ScriptExecutionContext::processMessagePortMessagesSoon()
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r107239 r109319  
    3333#include "ScriptCallStack.h"
    3434#include "SecurityContext.h"
     35#include "Supplementable.h"
    3536#include <wtf/Forward.h>
    3637#include <wtf/HashMap.h>
     
    5758class PublicURLManager;
    5859#endif
    59 #if ENABLE(SQL_DATABASE)
    60 class Database;
    61 class DatabaseTaskSynchronizer;
    62 class DatabaseThread;
    63 #endif
    6460
    6561#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
     
    6763#endif
    6864
    69 class ScriptExecutionContext : public SecurityContext {
     65class ScriptExecutionContext : public SecurityContext, public Supplementable<ScriptExecutionContext> {
    7066public:
    7167    ScriptExecutionContext();
     
    7874    virtual bool allowDatabaseAccess() const = 0;
    7975    virtual void databaseExceededQuota(const String& name) = 0;
    80     DatabaseThread* databaseThread();
    81     void setHasOpenDatabases() { m_hasOpenDatabases = true; }
    82     bool hasOpenDatabases() const { return m_hasOpenDatabases; }
    83     // When the database cleanup is done, cleanupSync will be signalled.
    84     void stopDatabases(DatabaseTaskSynchronizer*);
    8576#endif
    8677    virtual bool isContextThread() const { return true; }
     
    225216    ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects;
    226217
    227 #if ENABLE(SQL_DATABASE)
    228     RefPtr<DatabaseThread> m_databaseThread;
    229     bool m_hasOpenDatabases; // This never changes back to false, even after the database thread is closed.
    230 #endif
    231 
    232218#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
    233219    RefPtr<FileThread> m_fileThread;
  • trunk/Source/WebCore/history/PageCache.cpp

    r107607 r109319  
    3232#include "CachedPage.h"
    3333#include "DOMWindow.h"
     34#include "DatabaseContext.h"
    3435#include "DeviceMotionController.h"
    3536#include "DeviceOrientationController.h"
     
    121122        }
    122123#if ENABLE(SQL_DATABASE)
    123         if (frame->document()->hasOpenDatabases()) {
     124        if (DatabaseContext::hasOpenDatabases(frame->document())) {
    124125            PCLOG("   -Frame has open database handles");
    125126            cannotCache = true;
     
    264265        && (!frame->domWindow() || !frame->domWindow()->hasEventListeners(eventNames().unloadEvent))
    265266#if ENABLE(SQL_DATABASE)
    266         && !document->hasOpenDatabases()
     267        && !DatabaseContext::hasOpenDatabases(document)
    267268#endif
    268269#if ENABLE(SHARED_WORKERS)
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r108465 r109319  
    4747#include "Console.h"
    4848#include "ContentSecurityPolicy.h"
     49#include "DatabaseContext.h"
    4950#include "DOMImplementation.h"
    5051#include "DOMWindow.h"
     
    419420
    420421#if ENABLE(SQL_DATABASE)
    421         doc->stopDatabases(0);
     422        // FIXME: Should the DatabaseContext watch for something like ActiveDOMObject::stop() rather than being special-cased here?
     423        DatabaseContext::stopDatabases(doc, 0);
    422424#endif
    423425    }
  • trunk/Source/WebCore/platform/Supplementable.h

    r108958 r109319  
    3030#include <wtf/PassOwnPtr.h>
    3131#include <wtf/text/AtomicString.h>
     32#include <wtf/text/AtomicStringHash.h>
    3233
    3334namespace WebCore {
     
    5859    {
    5960        ASSERT(!m_supplements.get(key.impl()));
    60         m_supplements.set(key.impl(), supplement);
     61        m_supplements.set(key, supplement);
    6162    }
    6263
    6364    Supplement<T>* requireSupplement(const AtomicString& key)
    6465    {
    65         return m_supplements.get(key.impl());
     66        return m_supplements.get(key);
    6667    }
    6768
    6869private:
    69     typedef HashMap<AtomicStringImpl*, OwnPtr<Supplement<T> > > SupplementMap;
     70    typedef HashMap<AtomicString, OwnPtr<Supplement<T> > > SupplementMap;
    7071    SupplementMap m_supplements;
    7172};
  • trunk/Source/WebCore/storage/AbstractDatabase.cpp

    r104803 r109319  
    3333
    3434#include "DatabaseAuthorizer.h"
     35#include "DatabaseContext.h"
    3536#include "DatabaseTracker.h"
    3637#include "ExceptionCode.h"
     
    189190                                   const String& displayName, unsigned long estimatedSize, DatabaseType databaseType)
    190191    : m_scriptExecutionContext(context)
     192    , m_databaseContext(DatabaseContext::from(context))
    191193    , m_name(name.isolatedCopy())
    192194    , m_expectedVersion(expectedVersion.isolatedCopy())
  • trunk/Source/WebCore/storage/AbstractDatabase.h

    r101492 r109319  
    4343
    4444class DatabaseAuthorizer;
     45class DatabaseContext;
    4546class ScriptExecutionContext;
    4647class SecurityOrigin;
     
    8788    virtual void closeImmediately() = 0;
    8889
     90    DatabaseContext* databaseContext() const { return m_databaseContext; }
     91
    8992protected:
    9093    friend class ChangeVersionWrapper;
     
    125128    static const char* databaseInfoTableName();
    126129
     130    RefPtr<SecurityOrigin> m_contextThreadSecurityOrigin;
    127131    RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
    128     RefPtr<SecurityOrigin> m_contextThreadSecurityOrigin;
     132    DatabaseContext* m_databaseContext; // Owned by m_scriptExecutionContext.
    129133
    130134    String m_name;
  • trunk/Source/WebCore/storage/Database.cpp

    r108015 r109319  
    3535#include "CrossThreadTask.h"
    3636#include "DatabaseCallback.h"
     37#include "DatabaseContext.h"
    3738#include "DatabaseTask.h"
    3839#include "DatabaseThread.h"
     
    110111    DatabaseTracker::tracker().setDatabaseDetails(context->securityOrigin(), name, displayName, estimatedSize);
    111112
    112     context->setHasOpenDatabases();
     113    DatabaseContext::from(context)->setHasOpenDatabases();
    113114
    114115    InspectorInstrumentation::didOpenDatabase(context, database, context->securityOrigin()->host(), name, expectedVersion);
     
    131132
    132133    ScriptController::initializeThreading();
    133     ASSERT(m_scriptExecutionContext->databaseThread());
     134    ASSERT(databaseContext()->databaseThread());
    134135}
    135136
     
    180181{
    181182    DatabaseTaskSynchronizer synchronizer;
    182     if (!m_scriptExecutionContext->databaseThread() || m_scriptExecutionContext->databaseThread()->terminationRequested(&synchronizer))
     183    if (!databaseContext()->databaseThread() || databaseContext()->databaseThread()->terminationRequested(&synchronizer))
    183184        return false;
    184185
    185186    bool success = false;
    186187    OwnPtr<DatabaseOpenTask> task = DatabaseOpenTask::create(this, setVersionInNewDatabase, &synchronizer, e, errorMessage, success);
    187     m_scriptExecutionContext->databaseThread()->scheduleImmediateTask(task.release());
     188    databaseContext()->databaseThread()->scheduleImmediateTask(task.release());
    188189    synchronizer.waitForTaskCompletion();
    189190
     
    193194void Database::markAsDeletedAndClose()
    194195{
    195     if (m_deleted || !m_scriptExecutionContext->databaseThread())
     196    if (m_deleted || !databaseContext()->databaseThread())
    196197        return;
    197198
     
    200201
    201202    DatabaseTaskSynchronizer synchronizer;
    202     if (m_scriptExecutionContext->databaseThread()->terminationRequested(&synchronizer)) {
     203    if (databaseContext()->databaseThread()->terminationRequested(&synchronizer)) {
    203204        LOG(StorageAPI, "Database handle %p is on a terminated DatabaseThread, cannot be marked for normal closure\n", this);
    204205        return;
     
    206207
    207208    OwnPtr<DatabaseCloseTask> task = DatabaseCloseTask::create(this, &synchronizer);
    208     m_scriptExecutionContext->databaseThread()->scheduleImmediateTask(task.release());
     209    databaseContext()->databaseThread()->scheduleImmediateTask(task.release());
    209210    synchronizer.waitForTaskCompletion();
    210211}
     
    212213void Database::close()
    213214{
    214     ASSERT(m_scriptExecutionContext->databaseThread());
    215     ASSERT(currentThread() == m_scriptExecutionContext->databaseThread()->getThreadID());
     215    ASSERT(databaseContext()->databaseThread());
     216    ASSERT(currentThread() == databaseContext()->databaseThread()->getThreadID());
    216217
    217218    {
     
    226227    // Must ref() before calling databaseThread()->recordDatabaseClosed().
    227228    RefPtr<Database> protect = this;
    228     m_scriptExecutionContext->databaseThread()->recordDatabaseClosed(this);
    229     m_scriptExecutionContext->databaseThread()->unscheduleDatabaseTasks(this);
     229    databaseContext()->databaseThread()->recordDatabaseClosed(this);
     230    databaseContext()->databaseThread()->unscheduleDatabaseTasks(this);
    230231    DatabaseTracker::tracker().removeOpenDatabase(this);
    231232}
     
    234235{
    235236    ASSERT(m_scriptExecutionContext->isContextThread());
    236     DatabaseThread* databaseThread = scriptExecutionContext()->databaseThread();
     237    DatabaseThread* databaseThread = databaseContext()->databaseThread();
    237238    if (databaseThread && !databaseThread->terminationRequested() && opened()) {
    238239        logErrorMessage("forcibly closing database");
     
    249250{
    250251    if (AbstractDatabase::performOpenAndVerify(setVersionInNewDatabase, e, errorMessage)) {
    251         if (m_scriptExecutionContext->databaseThread())
    252             m_scriptExecutionContext->databaseThread()->recordDatabaseOpen(this);
     252        if (databaseContext()->databaseThread())
     253            databaseContext()->databaseThread()->recordDatabaseOpen(this);
    253254
    254255        return true;
     
    312313        transaction = m_transactionQueue.takeFirst();
    313314
    314     if (transaction && m_scriptExecutionContext->databaseThread()) {
     315    if (transaction && databaseContext()->databaseThread()) {
    315316        OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(transaction);
    316317        LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for transaction %p\n", task.get(), task->transaction());
    317318        m_transactionInProgress = true;
    318         m_scriptExecutionContext->databaseThread()->scheduleTask(task.release());
     319        databaseContext()->databaseThread()->scheduleTask(task.release());
    319320    } else
    320321        m_transactionInProgress = false;
     
    323324void Database::scheduleTransactionStep(SQLTransaction* transaction, bool immediately)
    324325{
    325     if (!m_scriptExecutionContext->databaseThread())
     326    if (!databaseContext()->databaseThread())
    326327        return;
    327328
     
    329330    LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for the transaction step\n", task.get());
    330331    if (immediately)
    331         m_scriptExecutionContext->databaseThread()->scheduleImmediateTask(task.release());
     332        databaseContext()->databaseThread()->scheduleImmediateTask(task.release());
    332333    else
    333         m_scriptExecutionContext->databaseThread()->scheduleTask(task.release());
     334        databaseContext()->databaseThread()->scheduleTask(task.release());
    334335}
    335336
     
    391392SQLTransactionClient* Database::transactionClient() const
    392393{
    393     return m_scriptExecutionContext->databaseThread()->transactionClient();
     394    return databaseContext()->databaseThread()->transactionClient();
    394395}
    395396
    396397SQLTransactionCoordinator* Database::transactionCoordinator() const
    397398{
    398     return m_scriptExecutionContext->databaseThread()->transactionCoordinator();
     399    return databaseContext()->databaseThread()->transactionCoordinator();
    399400}
    400401
     
    405406    Vector<String> result;
    406407    DatabaseTaskSynchronizer synchronizer;
    407     if (!m_scriptExecutionContext->databaseThread() || m_scriptExecutionContext->databaseThread()->terminationRequested(&synchronizer))
     408    if (!databaseContext()->databaseThread() || databaseContext()->databaseThread()->terminationRequested(&synchronizer))
    408409        return result;
    409410
    410411    OwnPtr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::create(this, &synchronizer, result);
    411     m_scriptExecutionContext->databaseThread()->scheduleImmediateTask(task.release());
     412    databaseContext()->databaseThread()->scheduleImmediateTask(task.release());
    412413    synchronizer.waitForTaskCompletion();
    413414
     
    419420    if (m_scriptExecutionContext->isContextThread())
    420421        return m_contextThreadSecurityOrigin.get();
    421     if (currentThread() == m_scriptExecutionContext->databaseThread()->getThreadID())
     422    if (currentThread() == databaseContext()->databaseThread()->getThreadID())
    422423        return m_databaseThreadSecurityOrigin.get();
    423424    return 0;
  • trunk/Source/WebCore/storage/SQLTransaction.cpp

    r105657 r109319  
    3434#include "Database.h"
    3535#include "DatabaseAuthorizer.h"
     36#include "DatabaseContext.h"
    3637#include "DatabaseThread.h"
    3738#include "ExceptionCode.h"
     
    164165
    165166    // The next steps should be executed only if we're on the DB thread.
    166     if (currentThread() != database()->scriptExecutionContext()->databaseThread()->getThreadID())
     167    if (currentThread() != database()->databaseContext()->databaseThread()->getThreadID())
    167168        return;
    168169
     
    216217void SQLTransaction::notifyDatabaseThreadIsShuttingDown()
    217218{
    218     ASSERT(currentThread() == database()->scriptExecutionContext()->databaseThread()->getThreadID());
     219    ASSERT(currentThread() == database()->databaseContext()->databaseThread()->getThreadID());
    219220
    220221    // If the transaction is in progress, we should roll it back here, since this is our last
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r108119 r109319  
    3131#include "WorkerThread.h"
    3232
     33#include "DatabaseContext.h"
    3334#include "DedicatedWorkerContext.h"
    3435#include "InspectorInstrumentation.h"
     
    216217
    217218#if ENABLE(SQL_DATABASE)
     219        // FIXME: Should we stop the databases as part of stopActiveDOMObjects() below?
    218220        DatabaseTaskSynchronizer cleanupSync;
    219         workerContext->stopDatabases(&cleanupSync);
     221        DatabaseContext::stopDatabases(workerContext, &cleanupSync);
    220222#endif
    221223
  • trunk/Source/WebKit/mac/ChangeLog

    r109255 r109319  
     12012-02-29  Adam Barth  <abarth@webkit.org>
     2
     3        ScriptExecutionContext has too many ifdef ENABLE(SQL_DATABASE)
     4        https://bugs.webkit.org/show_bug.cgi?id=79633
     5
     6        Reviewed by Eric Seidel.
     7
     8        * WebView/WebFrame.mm:
     9        (-[WebFrame _cacheabilityDictionary]):
     10
    1112012-02-29  Tim Horton  <timothy_horton@apple.com>
    212
  • trunk/Source/WebKit/mac/WebView/WebFrame.mm

    r109254 r109319  
    6161#import <WebCore/ColorMac.h>
    6262#import <WebCore/DOMImplementation.h>
     63#import <WebCore/DatabaseContext.h>
    6364#import <WebCore/DocumentFragment.h>
    6465#import <WebCore/DocumentLoader.h>
     
    11211122    if (Document* document = _private->coreFrame->document()) {
    11221123#if ENABLE(SQL_DATABASE)
    1123         if (document->hasOpenDatabases())
     1124        if (DatabaseContext::hasOpenDatabases(document))
    11241125            [result setObject:[NSNumber numberWithBool:YES] forKey:WebFrameUsesDatabases];
    11251126#endif
Note: See TracChangeset for help on using the changeset viewer.