Changeset 102894 in webkit


Ignore:
Timestamp:
Dec 14, 2011 10:51:20 PM (12 years ago)
Author:
levin@chromium.org
Message:

[chromium] DatabaseObserver needs threadsafe fixes and other clean-up.
https://bugs.webkit.org/show_bug.cgi?id=74558

Reviewed by Dmitry Titov.

Source/WebKit/chromium:

The important part of this fix is the removal of AllowCrossThreadAccess so
that ref counting happens appropriately.

Minor clean up throughout: Removed unnecessary WTF prefix in many
of these places and unnecessary String().

  • src/DatabaseObserver.cpp:

(WebKit::AllowDatabaseMainThreadBridge::create):
(WebKit::AllowDatabaseMainThreadBridge::signalCompleted): Get rid of
AllowCrossThreadAccess so that "this" get ref counted and remove mode from being
a member variable since a String in a ThreadSafeRefCounted class is bad.
(WebKit::AllowDatabaseMainThreadBridge::AllowDatabaseMainThreadBridge): Ditto.
(WebKit::AllowDatabaseMainThreadBridge::allowDatabaseTask): Pass through mode
and minor code cleaning to do only one call to signalCompleted.
(WebKit::allowDatabaseForWorker): Just removed unnecessary String()'s.

LayoutTests:

Added a test which would fail without some of these fixes.

  • http/tests/workers/interrupt-database-sync-open-crash.html: Added.
  • http/tests/workers/resources/open-database-sync.js: Added.

(onmessage):

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r102886 r102894  
     12011-12-14  David Levin  <levin@chromium.org>
     2
     3        [chromium] DatabaseObserver needs threadsafe fixes and other clean-up.
     4        https://bugs.webkit.org/show_bug.cgi?id=74558
     5
     6        Reviewed by Dmitry Titov.
     7
     8        Added a test which would fail without some of these fixes.
     9
     10        * http/tests/workers/interrupt-database-sync-open-crash.html: Added.
     11        * http/tests/workers/resources/open-database-sync.js: Added.
     12        (onmessage):
     13
    1142011-12-14  Kent Tamura  <tkent@chromium.org>
    215
  • trunk/Source/WebKit/chromium/ChangeLog

    r102891 r102894  
     12011-12-14  David Levin  <levin@chromium.org>
     2
     3        [chromium] DatabaseObserver needs threadsafe fixes and other clean-up.
     4        https://bugs.webkit.org/show_bug.cgi?id=74558
     5
     6        Reviewed by Dmitry Titov.
     7
     8        The important part of this fix is the removal of AllowCrossThreadAccess so
     9        that ref counting happens appropriately.
     10
     11        Minor clean up throughout: Removed unnecessary WTF prefix in many
     12        of these places and unnecessary String().
     13
     14        * src/DatabaseObserver.cpp:
     15        (WebKit::AllowDatabaseMainThreadBridge::create):
     16        (WebKit::AllowDatabaseMainThreadBridge::signalCompleted): Get rid of
     17        AllowCrossThreadAccess so that "this" get ref counted and remove mode from being
     18        a member variable since a String in a ThreadSafeRefCounted class is bad.
     19        (WebKit::AllowDatabaseMainThreadBridge::AllowDatabaseMainThreadBridge): Ditto.
     20        (WebKit::AllowDatabaseMainThreadBridge::allowDatabaseTask): Pass through mode
     21        and minor code cleaning to do only one call to signalCompleted.
     22        (WebKit::allowDatabaseForWorker): Just removed unnecessary String()'s.
     23
    1242011-12-14  Tony Chang  <tony@chromium.org>
    225
  • trunk/Source/WebKit/chromium/src/DatabaseObserver.cpp

    r101492 r102894  
    6565class AllowDatabaseMainThreadBridge : public ThreadSafeRefCounted<AllowDatabaseMainThreadBridge> {
    6666public:
    67     static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
     67    static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, const String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
    6868    {
    6969        return adoptRef(new AllowDatabaseMainThreadBridge(workerLoaderProxy, mode, commonClient, frame, name, displayName, estimatedSize));
     
    8383
    8484    // This method is invoked on the main thread.
    85     void signalCompleted(bool result)
     85    void signalCompleted(const String& mode, bool result)
    8686    {
    8787        MutexLocker locker(m_mutex);
    88         if (m_workerLoaderProxy)
    89             m_workerLoaderProxy->postTaskForModeToWorkerContext(
    90                 createCallbackTask(&didComplete, WebCore::AllowCrossThreadAccess(this), result),
    91                 m_mode);
     88        if (!m_workerLoaderProxy)
     89            return;
     90        m_workerLoaderProxy->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), mode);
    9291    }
    9392
    9493private:
    95     AllowDatabaseMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
     94    AllowDatabaseMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
    9695        : m_workerLoaderProxy(workerLoaderProxy)
    97         , m_mode(mode)
    9896    {
    9997        WebWorkerBase::dispatchTaskToMainThread(
    100             createCallbackTask(&allowDatabaseTask, WebCore::AllowCrossThreadAccess(commonClient),
     98            createCallbackTask(&allowDatabaseTask, mode, WebCore::AllowCrossThreadAccess(commonClient),
    10199                               WebCore::AllowCrossThreadAccess(frame),
    102                                String(name), String(displayName), estimatedSize,
    103                                WebCore::AllowCrossThreadAccess(this)));
    104     }
    105 
    106     static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String name, const WTF::String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
    107     {
    108         if (commonClient)
    109             bridge->signalCompleted(commonClient->allowDatabase(frame, name, displayName, estimatedSize));
    110         else
    111             bridge->signalCompleted(false);
     100                               name, displayName, estimatedSize,
     101                               this));
     102    }
     103
     104    static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, const String mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const String name, const String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
     105    {
     106        bool allowDatabase = commonClient ? commonClient->allowDatabase(frame, name, displayName, estimatedSize) : false;
     107        bridge->signalCompleted(mode, allowDatabase);
    112108    }
    113109
     
    120116    Mutex m_mutex;
    121117    WebCore::WorkerLoaderProxy* m_workerLoaderProxy;
    122     WTF::String m_mode;
    123118};
    124119
     
    135130    mode.append(String::number(runLoop.createUniqueId()));
    136131
    137     RefPtr<AllowDatabaseMainThreadBridge> bridge = AllowDatabaseMainThreadBridge::create(workerLoaderProxy, mode, commonClient, frame, String(name), String(displayName), estimatedSize);
     132    RefPtr<AllowDatabaseMainThreadBridge> bridge = AllowDatabaseMainThreadBridge::create(workerLoaderProxy, mode, commonClient, frame, name, displayName, estimatedSize);
    138133
    139134    // Either the bridge returns, or the queue gets terminated.
Note: See TracChangeset for help on using the changeset viewer.