| Differences between
and this patch
- a/Source/WebCore/ChangeLog +52 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2014-04-30  Zan Dobersek  <zdobersek@igalia.com>
2
3
        Move Source/WebCore/workers/ code to std::unique_ptr
4
        https://bugs.webkit.org/show_bug.cgi?id=132401
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Replace uses of OwnPtr and PassOwnPtr in code under Source/WebCore/workers (and related places)
9
        with std::unique_ptr.
10
11
        * bindings/js/JSDOMWindowCustom.cpp:
12
        (WebCore::JSDOMWindow::setTimeout):
13
        (WebCore::JSDOMWindow::setInterval):
14
        * bindings/js/JSWorkerGlobalScopeCustom.cpp:
15
        (WebCore::JSWorkerGlobalScope::setTimeout):
16
        (WebCore::JSWorkerGlobalScope::setInterval):
17
        * bindings/js/ScheduledAction.cpp:
18
        (WebCore::ScheduledAction::create):
19
        * bindings/js/ScheduledAction.h:
20
        * page/DOMTimer.cpp:
21
        (WebCore::DOMTimer::DOMTimer):
22
        (WebCore::DOMTimer::install):
23
        (WebCore::DOMTimer::fired):
24
        (WebCore::DOMTimer::didStop):
25
        * page/DOMTimer.h:
26
        * page/DOMWindow.cpp:
27
        (WebCore::DOMWindow::setTimeout):
28
        (WebCore::DOMWindow::setInterval):
29
        * page/DOMWindow.h:
30
        * workers/WorkerEventQueue.h:
31
        * workers/WorkerGlobalScope.cpp:
32
        (WebCore::WorkerGlobalScope::WorkerGlobalScope):
33
        (WebCore::WorkerGlobalScope::setTimeout):
34
        (WebCore::WorkerGlobalScope::setInterval):
35
        * workers/WorkerGlobalScope.h:
36
        (WebCore::WorkerGlobalScope::clearScript):
37
        * workers/WorkerLoaderProxy.h:
38
        * workers/WorkerMessagingProxy.h:
39
        * workers/WorkerRunLoop.cpp:
40
        (WebCore::WorkerRunLoop::WorkerRunLoop):
41
        * workers/WorkerRunLoop.h:
42
        * workers/WorkerScriptLoader.cpp:
43
        (WebCore::WorkerScriptLoader::loadSynchronously):
44
        (WebCore::WorkerScriptLoader::loadAsynchronously):
45
        (WebCore::WorkerScriptLoader::createResourceRequest):
46
        * workers/WorkerScriptLoader.h:
47
        * workers/WorkerThread.cpp:
48
        (WebCore::WorkerThread::WorkerThread):
49
        (WebCore::WorkerThread::workerThread):
50
        (WebCore::WorkerThreadStartupData::create): Deleted.
51
        * workers/WorkerThread.h:
52
1
2014-04-30  Alexey Proskuryakov  <ap@apple.com>
53
2014-04-30  Alexey Proskuryakov  <ap@apple.com>
2
54
3
        https://bugs.webkit.org/show_bug.cgi?id=132363
55
        https://bugs.webkit.org/show_bug.cgi?id=132363
- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp -4 / +4 lines
Lines 587-593 JSValue JSDOMWindow::postMessage(ExecState* exec) a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp_sec1
587
JSValue JSDOMWindow::setTimeout(ExecState* exec)
587
JSValue JSDOMWindow::setTimeout(ExecState* exec)
588
{
588
{
589
    ContentSecurityPolicy* contentSecurityPolicy = impl().document() ? impl().document()->contentSecurityPolicy() : 0;
589
    ContentSecurityPolicy* contentSecurityPolicy = impl().document() ? impl().document()->contentSecurityPolicy() : 0;
590
    OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), contentSecurityPolicy);
590
    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), contentSecurityPolicy);
591
    if (exec->hadException())
591
    if (exec->hadException())
592
        return jsUndefined();
592
        return jsUndefined();
593
593
Lines 597-603 JSValue JSDOMWindow::setTimeout(ExecState* exec) a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp_sec2
597
    int delay = exec->argument(1).toInt32(exec);
597
    int delay = exec->argument(1).toInt32(exec);
598
598
599
    ExceptionCode ec = 0;
599
    ExceptionCode ec = 0;
600
    int result = impl().setTimeout(action.release(), delay, ec);
600
    int result = impl().setTimeout(std::move(action), delay, ec);
601
    setDOMException(exec, ec);
601
    setDOMException(exec, ec);
602
602
603
    return jsNumber(result);
603
    return jsNumber(result);
Lines 606-612 JSValue JSDOMWindow::setTimeout(ExecState* exec) a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp_sec3
606
JSValue JSDOMWindow::setInterval(ExecState* exec)
606
JSValue JSDOMWindow::setInterval(ExecState* exec)
607
{
607
{
608
    ContentSecurityPolicy* contentSecurityPolicy = impl().document() ? impl().document()->contentSecurityPolicy() : 0;
608
    ContentSecurityPolicy* contentSecurityPolicy = impl().document() ? impl().document()->contentSecurityPolicy() : 0;
609
    OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), contentSecurityPolicy);
609
    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), contentSecurityPolicy);
610
    if (exec->hadException())
610
    if (exec->hadException())
611
        return jsUndefined();
611
        return jsUndefined();
612
    int delay = exec->argument(1).toInt32(exec);
612
    int delay = exec->argument(1).toInt32(exec);
Lines 615-621 JSValue JSDOMWindow::setInterval(ExecState* exec) a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp_sec4
615
        return jsNumber(0);
615
        return jsNumber(0);
616
616
617
    ExceptionCode ec = 0;
617
    ExceptionCode ec = 0;
618
    int result = impl().setInterval(action.release(), delay, ec);
618
    int result = impl().setInterval(std::move(action), delay, ec);
619
    setDOMException(exec, ec);
619
    setDOMException(exec, ec);
620
620
621
    return jsNumber(result);
621
    return jsNumber(result);
- a/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp -4 / +4 lines
Lines 87-110 JSValue JSWorkerGlobalScope::importScripts(ExecState* exec) a/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp_sec1
87
87
88
JSValue JSWorkerGlobalScope::setTimeout(ExecState* exec)
88
JSValue JSWorkerGlobalScope::setTimeout(ExecState* exec)
89
{
89
{
90
    OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), impl().contentSecurityPolicy());
90
    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), impl().contentSecurityPolicy());
91
    if (exec->hadException())
91
    if (exec->hadException())
92
        return jsUndefined();
92
        return jsUndefined();
93
    if (!action)
93
    if (!action)
94
        return jsNumber(0);
94
        return jsNumber(0);
95
    int delay = exec->argument(1).toInt32(exec);
95
    int delay = exec->argument(1).toInt32(exec);
96
    return jsNumber(impl().setTimeout(action.release(), delay));
96
    return jsNumber(impl().setTimeout(std::move(action), delay));
97
}
97
}
98
98
99
JSValue JSWorkerGlobalScope::setInterval(ExecState* exec)
99
JSValue JSWorkerGlobalScope::setInterval(ExecState* exec)
100
{
100
{
101
    OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), impl().contentSecurityPolicy());
101
    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), impl().contentSecurityPolicy());
102
    if (exec->hadException())
102
    if (exec->hadException())
103
        return jsUndefined();
103
        return jsUndefined();
104
    if (!action)
104
    if (!action)
105
        return jsNumber(0);
105
        return jsNumber(0);
106
    int delay = exec->argument(1).toInt32(exec);
106
    int delay = exec->argument(1).toInt32(exec);
107
    return jsNumber(impl().setInterval(action.release(), delay));
107
    return jsNumber(impl().setInterval(std::move(action), delay));
108
}
108
}
109
109
110
} // namespace WebCore
110
} // namespace WebCore
- a/Source/WebCore/bindings/js/ScheduledAction.cpp -3 / +3 lines
Lines 46-52 using namespace JSC; a/Source/WebCore/bindings/js/ScheduledAction.cpp_sec1
46
46
47
namespace WebCore {
47
namespace WebCore {
48
48
49
PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy* policy)
49
std::unique_ptr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy* policy)
50
{
50
{
51
    JSValue v = exec->argument(0);
51
    JSValue v = exec->argument(0);
52
    CallData callData;
52
    CallData callData;
Lines 56-65 PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperW a/Source/WebCore/bindings/js/ScheduledAction.cpp_sec2
56
        String string = v.toString(exec)->value(exec);
56
        String string = v.toString(exec)->value(exec);
57
        if (exec->hadException())
57
        if (exec->hadException())
58
            return nullptr;
58
            return nullptr;
59
        return adoptPtr(new ScheduledAction(string, isolatedWorld));
59
        return std::unique_ptr<ScheduledAction>(new ScheduledAction(string, isolatedWorld));
60
    }
60
    }
61
61
62
    return adoptPtr(new ScheduledAction(exec, v, isolatedWorld));
62
    return std::unique_ptr<ScheduledAction>(new ScheduledAction(exec, v, isolatedWorld));
63
}
63
}
64
64
65
ScheduledAction::ScheduledAction(ExecState* exec, JSValue function, DOMWrapperWorld& isolatedWorld)
65
ScheduledAction::ScheduledAction(ExecState* exec, JSValue function, DOMWrapperWorld& isolatedWorld)
- a/Source/WebCore/bindings/js/ScheduledAction.h -2 / +2 lines
Lines 23-30 a/Source/WebCore/bindings/js/ScheduledAction.h_sec1
23
#include "JSDOMBinding.h"
23
#include "JSDOMBinding.h"
24
#include <heap/Strong.h>
24
#include <heap/Strong.h>
25
#include <heap/StrongInlines.h>
25
#include <heap/StrongInlines.h>
26
#include <memory>
26
#include <runtime/JSCell.h>
27
#include <runtime/JSCell.h>
27
#include <wtf/PassOwnPtr.h>
28
#include <wtf/Vector.h>
28
#include <wtf/Vector.h>
29
#include <wtf/text/WTFString.h>
29
#include <wtf/text/WTFString.h>
30
30
Lines 46-52 namespace WebCore { a/Source/WebCore/bindings/js/ScheduledAction.h_sec2
46
    class ScheduledAction {
46
    class ScheduledAction {
47
        WTF_MAKE_NONCOPYABLE(ScheduledAction); WTF_MAKE_FAST_ALLOCATED;
47
        WTF_MAKE_NONCOPYABLE(ScheduledAction); WTF_MAKE_FAST_ALLOCATED;
48
    public:
48
    public:
49
        static PassOwnPtr<ScheduledAction> create(JSC::ExecState*, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy*);
49
        static std::unique_ptr<ScheduledAction> create(JSC::ExecState*, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy*);
50
50
51
        void execute(ScriptExecutionContext*);
51
        void execute(ScriptExecutionContext*);
52
52
- a/Source/WebCore/page/DOMTimer.cpp -6 / +6 lines
Lines 58-67 static inline bool shouldForwardUserGesture(int interval, int nestingLevel) a/Source/WebCore/page/DOMTimer.cpp_sec1
58
        && nestingLevel == 1; // Gestures should not be forwarded to nested timers.
58
        && nestingLevel == 1; // Gestures should not be forwarded to nested timers.
59
}
59
}
60
60
61
DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int interval, bool singleShot)
61
DOMTimer::DOMTimer(ScriptExecutionContext* context, std::unique_ptr<ScheduledAction> action, int interval, bool singleShot)
62
    : SuspendableTimer(context)
62
    : SuspendableTimer(context)
63
    , m_nestingLevel(timerNestingLevel + 1)
63
    , m_nestingLevel(timerNestingLevel + 1)
64
    , m_action(action)
64
    , m_action(std::move(action))
65
    , m_originalInterval(interval)
65
    , m_originalInterval(interval)
66
    , m_shouldForwardUserGesture(shouldForwardUserGesture(interval, m_nestingLevel))
66
    , m_shouldForwardUserGesture(shouldForwardUserGesture(interval, m_nestingLevel))
67
{
67
{
Lines 83-94 DOMTimer::~DOMTimer() a/Source/WebCore/page/DOMTimer.cpp_sec2
83
        scriptExecutionContext()->removeTimeout(m_timeoutId);
83
        scriptExecutionContext()->removeTimeout(m_timeoutId);
84
}
84
}
85
85
86
int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot)
86
int DOMTimer::install(ScriptExecutionContext* context, std::unique_ptr<ScheduledAction> action, int timeout, bool singleShot)
87
{
87
{
88
    // DOMTimer constructor links the new timer into a list of ActiveDOMObjects held by the 'context'.
88
    // DOMTimer constructor links the new timer into a list of ActiveDOMObjects held by the 'context'.
89
    // The timer is deleted when context is deleted (DOMTimer::contextDestroyed) or explicitly via DOMTimer::removeById(),
89
    // The timer is deleted when context is deleted (DOMTimer::contextDestroyed) or explicitly via DOMTimer::removeById(),
90
    // or if it is a one-time timer and it has fired (DOMTimer::fired).
90
    // or if it is a one-time timer and it has fired (DOMTimer::fired).
91
    DOMTimer* timer = new DOMTimer(context, action, timeout, singleShot);
91
    DOMTimer* timer = new DOMTimer(context, std::move(action), timeout, singleShot);
92
#if PLATFORM(IOS)
92
#if PLATFORM(IOS)
93
    if (context->isDocument()) {
93
    if (context->isDocument()) {
94
        Document& document = toDocument(*context);
94
        Document& document = toDocument(*context);
Lines 157-163 void DOMTimer::fired() a/Source/WebCore/page/DOMTimer.cpp_sec3
157
    }
157
    }
158
158
159
    // Delete timer before executing the action for one-shot timers.
159
    // Delete timer before executing the action for one-shot timers.
160
    OwnPtr<ScheduledAction> action = m_action.release();
160
    ScheduledAction* action = m_action.release();
161
161
162
    // No access to member variables after this point.
162
    // No access to member variables after this point.
163
    delete this;
163
    delete this;
Lines 207-213 void DOMTimer::didStop() a/Source/WebCore/page/DOMTimer.cpp_sec4
207
    // Need to release JS objects potentially protected by ScheduledAction
207
    // Need to release JS objects potentially protected by ScheduledAction
208
    // because they can form circular references back to the ScriptExecutionContext
208
    // because they can form circular references back to the ScriptExecutionContext
209
    // which will cause a memory leak.
209
    // which will cause a memory leak.
210
    m_action.clear();
210
    m_action = nullptr;
211
}
211
}
212
212
213
void DOMTimer::adjustMinimumTimerInterval(double oldMinimumTimerInterval)
213
void DOMTimer::adjustMinimumTimerInterval(double oldMinimumTimerInterval)
- a/Source/WebCore/page/DOMTimer.h -5 / +4 lines
Lines 28-35 a/Source/WebCore/page/DOMTimer.h_sec1
28
#define DOMTimer_h
28
#define DOMTimer_h
29
29
30
#include "SuspendableTimer.h"
30
#include "SuspendableTimer.h"
31
#include <wtf/OwnPtr.h>
31
#include <memory>
32
#include <wtf/PassOwnPtr.h>
33
32
34
namespace WebCore {
33
namespace WebCore {
35
34
Lines 40-46 namespace WebCore { a/Source/WebCore/page/DOMTimer.h_sec2
40
        virtual ~DOMTimer();
39
        virtual ~DOMTimer();
41
        // Creates a new timer owned by specified ScriptExecutionContext, starts it
40
        // Creates a new timer owned by specified ScriptExecutionContext, starts it
42
        // and returns its Id.
41
        // and returns its Id.
43
        static int install(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int timeout, bool singleShot);
42
        static int install(ScriptExecutionContext*, std::unique_ptr<ScheduledAction>, int timeout, bool singleShot);
44
        static void removeById(ScriptExecutionContext*, int timeoutId);
43
        static void removeById(ScriptExecutionContext*, int timeoutId);
45
44
46
        // Adjust to a change in the ScriptExecutionContext's minimum timer interval.
45
        // Adjust to a change in the ScriptExecutionContext's minimum timer interval.
Lines 49-55 namespace WebCore { a/Source/WebCore/page/DOMTimer.h_sec3
49
        void adjustMinimumTimerInterval(double oldMinimumTimerInterval);
48
        void adjustMinimumTimerInterval(double oldMinimumTimerInterval);
50
49
51
    private:
50
    private:
52
        DOMTimer(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int interval, bool singleShot);
51
        DOMTimer(ScriptExecutionContext*, std::unique_ptr<ScheduledAction>, int interval, bool singleShot);
53
        virtual void fired() override;
52
        virtual void fired() override;
54
53
55
        // ActiveDOMObject
54
        // ActiveDOMObject
Lines 65-71 namespace WebCore { a/Source/WebCore/page/DOMTimer.h_sec4
65
64
66
        int m_timeoutId;
65
        int m_timeoutId;
67
        int m_nestingLevel;
66
        int m_nestingLevel;
68
        OwnPtr<ScheduledAction> m_action;
67
        std::unique_ptr<ScheduledAction> m_action;
69
        int m_originalInterval;
68
        int m_originalInterval;
70
        bool m_shouldForwardUserGesture;
69
        bool m_shouldForwardUserGesture;
71
    };
70
    };
- a/Source/WebCore/page/DOMWindow.cpp -4 / +4 lines
Lines 1512-1525 void DOMWindow::resizeTo(float width, float height) const a/Source/WebCore/page/DOMWindow.cpp_sec1
1512
    page->chrome().setWindowRect(adjustWindowRect(page, update));
1512
    page->chrome().setWindowRect(adjustWindowRect(page, update));
1513
}
1513
}
1514
1514
1515
int DOMWindow::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1515
int DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1516
{
1516
{
1517
    ScriptExecutionContext* context = scriptExecutionContext();
1517
    ScriptExecutionContext* context = scriptExecutionContext();
1518
    if (!context) {
1518
    if (!context) {
1519
        ec = INVALID_ACCESS_ERR;
1519
        ec = INVALID_ACCESS_ERR;
1520
        return -1;
1520
        return -1;
1521
    }
1521
    }
1522
    return DOMTimer::install(context, action, timeout, true);
1522
    return DOMTimer::install(context, std::move(action), timeout, true);
1523
}
1523
}
1524
1524
1525
void DOMWindow::clearTimeout(int timeoutId)
1525
void DOMWindow::clearTimeout(int timeoutId)
Lines 1546-1559 void DOMWindow::clearTimeout(int timeoutId) a/Source/WebCore/page/DOMWindow.cpp_sec2
1546
    DOMTimer::removeById(context, timeoutId);
1546
    DOMTimer::removeById(context, timeoutId);
1547
}
1547
}
1548
1548
1549
int DOMWindow::setInterval(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1549
int DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1550
{
1550
{
1551
    ScriptExecutionContext* context = scriptExecutionContext();
1551
    ScriptExecutionContext* context = scriptExecutionContext();
1552
    if (!context) {
1552
    if (!context) {
1553
        ec = INVALID_ACCESS_ERR;
1553
        ec = INVALID_ACCESS_ERR;
1554
        return -1;
1554
        return -1;
1555
    }
1555
    }
1556
    return DOMTimer::install(context, action, timeout, false);
1556
    return DOMTimer::install(context, std::move(action), timeout, false);
1557
}
1557
}
1558
1558
1559
void DOMWindow::clearInterval(int timeoutId)
1559
void DOMWindow::clearInterval(int timeoutId)
- a/Source/WebCore/page/DOMWindow.h -2 / +3 lines
Lines 33-38 a/Source/WebCore/page/DOMWindow.h_sec1
33
#include "URL.h"
33
#include "URL.h"
34
#include "Supplementable.h"
34
#include "Supplementable.h"
35
#include <functional>
35
#include <functional>
36
#include <memory>
36
37
37
namespace Inspector {
38
namespace Inspector {
38
class ScriptCallStack;
39
class ScriptCallStack;
Lines 253-261 namespace WebCore { a/Source/WebCore/page/DOMWindow.h_sec2
253
        void resizeTo(float width, float height) const;
254
        void resizeTo(float width, float height) const;
254
255
255
        // Timers
256
        // Timers
256
        int setTimeout(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&);
257
        int setTimeout(std::unique_ptr<ScheduledAction>, int timeout, ExceptionCode&);
257
        void clearTimeout(int timeoutId);
258
        void clearTimeout(int timeoutId);
258
        int setInterval(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&);
259
        int setInterval(std::unique_ptr<ScheduledAction>, int timeout, ExceptionCode&);
259
        void clearInterval(int timeoutId);
260
        void clearInterval(int timeoutId);
260
261
261
        // WebKit animation extensions
262
        // WebKit animation extensions
- a/Source/WebCore/workers/WorkerEventQueue.h -1 lines
Lines 29-35 a/Source/WebCore/workers/WorkerEventQueue.h_sec1
29
29
30
#include "EventQueue.h"
30
#include "EventQueue.h"
31
#include <wtf/HashMap.h>
31
#include <wtf/HashMap.h>
32
#include <wtf/PassOwnPtr.h>
33
32
34
namespace WebCore {
33
namespace WebCore {
35
34
- a/Source/WebCore/workers/WorkerGlobalScope.cpp -5 / +5 lines
Lines 68-74 WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, st a/Source/WebCore/workers/WorkerGlobalScope.cpp_sec1
68
    : m_url(url)
68
    : m_url(url)
69
    , m_userAgent(userAgent)
69
    , m_userAgent(userAgent)
70
    , m_groupSettings(std::move(settings))
70
    , m_groupSettings(std::move(settings))
71
    , m_script(adoptPtr(new WorkerScriptController(this)))
71
    , m_script(std::make_unique<WorkerScriptController>(this))
72
    , m_thread(thread)
72
    , m_thread(thread)
73
#if ENABLE(INSPECTOR)
73
#if ENABLE(INSPECTOR)
74
    , m_workerInspectorController(std::make_unique<WorkerInspectorController>(*this))
74
    , m_workerInspectorController(std::make_unique<WorkerInspectorController>(*this))
Lines 153-161 void WorkerGlobalScope::postTask(Task task) a/Source/WebCore/workers/WorkerGlobalScope.cpp_sec2
153
    thread().runLoop().postTask(std::move(task));
153
    thread().runLoop().postTask(std::move(task));
154
}
154
}
155
155
156
int WorkerGlobalScope::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout)
156
int WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
157
{
157
{
158
    return DOMTimer::install(scriptExecutionContext(), action, timeout, true);
158
    return DOMTimer::install(scriptExecutionContext(), std::move(action), timeout, true);
159
}
159
}
160
160
161
void WorkerGlobalScope::clearTimeout(int timeoutId)
161
void WorkerGlobalScope::clearTimeout(int timeoutId)
Lines 163-171 void WorkerGlobalScope::clearTimeout(int timeoutId) a/Source/WebCore/workers/WorkerGlobalScope.cpp_sec3
163
    DOMTimer::removeById(scriptExecutionContext(), timeoutId);
163
    DOMTimer::removeById(scriptExecutionContext(), timeoutId);
164
}
164
}
165
165
166
int WorkerGlobalScope::setInterval(PassOwnPtr<ScheduledAction> action, int timeout)
166
int WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
167
{
167
{
168
    return DOMTimer::install(scriptExecutionContext(), action, timeout, false);
168
    return DOMTimer::install(scriptExecutionContext(), std::move(action), timeout, false);
169
}
169
}
170
170
171
void WorkerGlobalScope::clearInterval(int timeoutId)
171
void WorkerGlobalScope::clearInterval(int timeoutId)
- a/Source/WebCore/workers/WorkerGlobalScope.h -5 / +5 lines
Lines 35-43 a/Source/WebCore/workers/WorkerGlobalScope.h_sec1
35
#include "ScriptExecutionContext.h"
35
#include "ScriptExecutionContext.h"
36
#include "WorkerEventQueue.h"
36
#include "WorkerEventQueue.h"
37
#include "WorkerScriptController.h"
37
#include "WorkerScriptController.h"
38
#include <memory>
38
#include <wtf/Assertions.h>
39
#include <wtf/Assertions.h>
39
#include <wtf/HashMap.h>
40
#include <wtf/HashMap.h>
40
#include <wtf/OwnPtr.h>
41
#include <wtf/PassRefPtr.h>
41
#include <wtf/PassRefPtr.h>
42
#include <wtf/RefCounted.h>
42
#include <wtf/RefCounted.h>
43
#include <wtf/RefPtr.h>
43
#include <wtf/RefPtr.h>
Lines 72-78 namespace WebCore { a/Source/WebCore/workers/WorkerGlobalScope.h_sec2
72
        virtual void disableEval(const String& errorMessage) override;
72
        virtual void disableEval(const String& errorMessage) override;
73
73
74
        WorkerScriptController* script() { return m_script.get(); }
74
        WorkerScriptController* script() { return m_script.get(); }
75
        void clearScript() { m_script.clear(); }
75
        void clearScript() { m_script = nullptr; }
76
76
77
        WorkerThread& thread() const { return m_thread; }
77
        WorkerThread& thread() const { return m_thread; }
78
78
Lines 94-102 namespace WebCore { a/Source/WebCore/workers/WorkerGlobalScope.h_sec3
94
        WorkerNavigator* navigator() const;
94
        WorkerNavigator* navigator() const;
95
95
96
        // Timers
96
        // Timers
97
        int setTimeout(PassOwnPtr<ScheduledAction>, int timeout);
97
        int setTimeout(std::unique_ptr<ScheduledAction>, int timeout);
98
        void clearTimeout(int timeoutId);
98
        void clearTimeout(int timeoutId);
99
        int setInterval(PassOwnPtr<ScheduledAction>, int timeout);
99
        int setInterval(std::unique_ptr<ScheduledAction>, int timeout);
100
        void clearInterval(int timeoutId);
100
        void clearInterval(int timeoutId);
101
101
102
        virtual bool isContextThread() const override;
102
        virtual bool isContextThread() const override;
Lines 167-173 namespace WebCore { a/Source/WebCore/workers/WorkerGlobalScope.h_sec4
167
        mutable RefPtr<WorkerLocation> m_location;
167
        mutable RefPtr<WorkerLocation> m_location;
168
        mutable RefPtr<WorkerNavigator> m_navigator;
168
        mutable RefPtr<WorkerNavigator> m_navigator;
169
169
170
        OwnPtr<WorkerScriptController> m_script;
170
        std::unique_ptr<WorkerScriptController> m_script;
171
        WorkerThread& m_thread;
171
        WorkerThread& m_thread;
172
172
173
#if ENABLE(INSPECTOR)
173
#if ENABLE(INSPECTOR)
- a/Source/WebCore/workers/WorkerLoaderProxy.h -1 lines
Lines 33-39 a/Source/WebCore/workers/WorkerLoaderProxy.h_sec1
33
33
34
#include "ScriptExecutionContext.h"
34
#include "ScriptExecutionContext.h"
35
#include <wtf/Forward.h>
35
#include <wtf/Forward.h>
36
#include <wtf/PassOwnPtr.h>
37
36
38
namespace WebCore {
37
namespace WebCore {
39
38
- a/Source/WebCore/workers/WorkerMessagingProxy.h -1 lines
Lines 34-40 a/Source/WebCore/workers/WorkerMessagingProxy.h_sec1
34
#include <memory>
34
#include <memory>
35
#include <wtf/Forward.h>
35
#include <wtf/Forward.h>
36
#include <wtf/Noncopyable.h>
36
#include <wtf/Noncopyable.h>
37
#include <wtf/PassOwnPtr.h>
38
#include <wtf/PassRefPtr.h>
37
#include <wtf/PassRefPtr.h>
39
#include <wtf/RefPtr.h>
38
#include <wtf/RefPtr.h>
40
#include <wtf/Vector.h>
39
#include <wtf/Vector.h>
- a/Source/WebCore/workers/WorkerRunLoop.cpp -1 / +1 lines
Lines 87-93 private: a/Source/WebCore/workers/WorkerRunLoop.cpp_sec1
87
};
87
};
88
88
89
WorkerRunLoop::WorkerRunLoop()
89
WorkerRunLoop::WorkerRunLoop()
90
    : m_sharedTimer(adoptPtr(new WorkerSharedTimer))
90
    : m_sharedTimer(std::make_unique<WorkerSharedTimer>())
91
    , m_nestedCount(0)
91
    , m_nestedCount(0)
92
    , m_uniqueId(0)
92
    , m_uniqueId(0)
93
{
93
{
- a/Source/WebCore/workers/WorkerRunLoop.h -3 / +2 lines
Lines 32-40 a/Source/WebCore/workers/WorkerRunLoop.h_sec1
32
#define WorkerRunLoop_h
32
#define WorkerRunLoop_h
33
33
34
#include "ScriptExecutionContext.h"
34
#include "ScriptExecutionContext.h"
35
#include <memory>
35
#include <wtf/MessageQueue.h>
36
#include <wtf/MessageQueue.h>
36
#include <wtf/OwnPtr.h>
37
#include <wtf/PassOwnPtr.h>
38
37
39
namespace WebCore {
38
namespace WebCore {
40
39
Lines 90-96 namespace WebCore { a/Source/WebCore/workers/WorkerRunLoop.h_sec2
90
        void runCleanupTasks(WorkerGlobalScope*);
89
        void runCleanupTasks(WorkerGlobalScope*);
91
90
92
        MessageQueue<Task> m_messageQueue;
91
        MessageQueue<Task> m_messageQueue;
93
        OwnPtr<WorkerSharedTimer> m_sharedTimer;
92
        std::unique_ptr<WorkerSharedTimer> m_sharedTimer;
94
        int m_nestedCount;
93
        int m_nestedCount;
95
        unsigned long m_uniqueId;
94
        unsigned long m_uniqueId;
96
    };
95
    };
- a/Source/WebCore/workers/WorkerScriptLoader.cpp -6 / +5 lines
Lines 37-43 a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec1
37
#include "WorkerGlobalScope.h"
37
#include "WorkerGlobalScope.h"
38
#include "WorkerScriptLoaderClient.h"
38
#include "WorkerScriptLoaderClient.h"
39
#include "WorkerThreadableLoader.h"
39
#include "WorkerThreadableLoader.h"
40
#include <wtf/OwnPtr.h>
41
#include <wtf/Ref.h>
40
#include <wtf/Ref.h>
42
#include <wtf/RefPtr.h>
41
#include <wtf/RefPtr.h>
43
42
Lines 59-65 void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecuti a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec2
59
{
58
{
60
    m_url = url;
59
    m_url = url;
61
60
62
    OwnPtr<ResourceRequest> request(createResourceRequest());
61
    std::unique_ptr<ResourceRequest> request(createResourceRequest());
63
    if (!request)
62
    if (!request)
64
        return;
63
        return;
65
64
Lines 79-85 void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecut a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec3
79
    m_client = client;
78
    m_client = client;
80
    m_url = url;
79
    m_url = url;
81
80
82
    OwnPtr<ResourceRequest> request(createResourceRequest());
81
    std::unique_ptr<ResourceRequest> request(createResourceRequest());
83
    if (!request)
82
    if (!request)
84
        return;
83
        return;
85
84
Lines 99-109 const URL& WorkerScriptLoader::responseURL() const a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec4
99
    return m_responseURL;
98
    return m_responseURL;
100
}
99
}
101
100
102
PassOwnPtr<ResourceRequest> WorkerScriptLoader::createResourceRequest()
101
std::unique_ptr<ResourceRequest> WorkerScriptLoader::createResourceRequest()
103
{
102
{
104
    OwnPtr<ResourceRequest> request = adoptPtr(new ResourceRequest(m_url));
103
    auto request = std::make_unique<ResourceRequest>(m_url);
105
    request->setHTTPMethod("GET");
104
    request->setHTTPMethod("GET");
106
    return request.release();
105
    return std::move(request);
107
}
106
}
108
    
107
    
109
void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
108
void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
- a/Source/WebCore/workers/WorkerScriptLoader.h -2 / +2 lines
Lines 32-38 a/Source/WebCore/workers/WorkerScriptLoader.h_sec1
32
#include "ResourceRequest.h"
32
#include "ResourceRequest.h"
33
#include "ThreadableLoader.h"
33
#include "ThreadableLoader.h"
34
#include "ThreadableLoaderClient.h"
34
#include "ThreadableLoaderClient.h"
35
35
#include <memory>
36
#include <wtf/FastMalloc.h>
36
#include <wtf/FastMalloc.h>
37
#include <wtf/PassRefPtr.h>
37
#include <wtf/PassRefPtr.h>
38
#include <wtf/RefCounted.h>
38
#include <wtf/RefCounted.h>
Lines 77-83 namespace WebCore { a/Source/WebCore/workers/WorkerScriptLoader.h_sec2
77
        WorkerScriptLoader();
77
        WorkerScriptLoader();
78
        ~WorkerScriptLoader();
78
        ~WorkerScriptLoader();
79
79
80
        PassOwnPtr<ResourceRequest> createResourceRequest();
80
        std::unique_ptr<ResourceRequest> createResourceRequest();
81
        void notifyFinished();
81
        void notifyFinished();
82
82
83
        WorkerScriptLoaderClient* m_client;
83
        WorkerScriptLoaderClient* m_client;
- a/Source/WebCore/workers/WorkerThread.cpp -8 / +3 lines
Lines 79-88 unsigned WorkerThread::workerThreadCount() a/Source/WebCore/workers/WorkerThread.cpp_sec1
79
struct WorkerThreadStartupData {
79
struct WorkerThreadStartupData {
80
    WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED;
80
    WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED;
81
public:
81
public:
82
    static PassOwnPtr<WorkerThreadStartupData> create(const URL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
82
    WorkerThreadStartupData(const URL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin);
83
    {
84
        return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin));
85
    }
86
83
87
    URL m_scriptURL;
84
    URL m_scriptURL;
88
    String m_userAgent;
85
    String m_userAgent;
Lines 92-99 public: a/Source/WebCore/workers/WorkerThread.cpp_sec2
92
    String m_contentSecurityPolicy;
89
    String m_contentSecurityPolicy;
93
    ContentSecurityPolicy::HeaderType m_contentSecurityPolicyType;
90
    ContentSecurityPolicy::HeaderType m_contentSecurityPolicyType;
94
    RefPtr<SecurityOrigin> m_topOrigin;
91
    RefPtr<SecurityOrigin> m_topOrigin;
95
private:
96
    WorkerThreadStartupData(const URL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin);
97
};
92
};
98
93
99
WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
94
WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
Lines 118-124 WorkerThread::WorkerThread(const URL& scriptURL, const String& userAgent, const a/Source/WebCore/workers/WorkerThread.cpp_sec3
118
    : m_threadID(0)
113
    : m_threadID(0)
119
    , m_workerLoaderProxy(workerLoaderProxy)
114
    , m_workerLoaderProxy(workerLoaderProxy)
120
    , m_workerReportingProxy(workerReportingProxy)
115
    , m_workerReportingProxy(workerReportingProxy)
121
    , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin))
116
    , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin))
122
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
117
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
123
    , m_notificationClient(0)
118
    , m_notificationClient(0)
124
#endif
119
#endif
Lines 180-186 void WorkerThread::workerThread() a/Source/WebCore/workers/WorkerThread.cpp_sec4
180
    // Free the startup data to cause its member variable deref's happen on the worker's thread (since
175
    // Free the startup data to cause its member variable deref's happen on the worker's thread (since
181
    // all ref/derefs of these objects are happening on the thread at this point). Note that
176
    // all ref/derefs of these objects are happening on the thread at this point). Note that
182
    // WorkerThread::~WorkerThread happens on a different thread where it was created.
177
    // WorkerThread::~WorkerThread happens on a different thread where it was created.
183
    m_startupData.clear();
178
    m_startupData = nullptr;
184
179
185
    runEventLoop();
180
    runEventLoop();
186
181
- a/Source/WebCore/workers/WorkerThread.h -2 / +2 lines
Lines 30-37 a/Source/WebCore/workers/WorkerThread.h_sec1
30
#include "ContentSecurityPolicy.h"
30
#include "ContentSecurityPolicy.h"
31
#include "GroupSettings.h"
31
#include "GroupSettings.h"
32
#include "WorkerRunLoop.h"
32
#include "WorkerRunLoop.h"
33
#include <memory>
33
#include <wtf/Forward.h>
34
#include <wtf/Forward.h>
34
#include <wtf/OwnPtr.h>
35
#include <wtf/PassRefPtr.h>
35
#include <wtf/PassRefPtr.h>
36
#include <wtf/RefCounted.h>
36
#include <wtf/RefCounted.h>
37
37
Lines 92-98 namespace WebCore { a/Source/WebCore/workers/WorkerThread.h_sec2
92
        RefPtr<WorkerGlobalScope> m_workerGlobalScope;
92
        RefPtr<WorkerGlobalScope> m_workerGlobalScope;
93
        Mutex m_threadCreationMutex;
93
        Mutex m_threadCreationMutex;
94
94
95
        OwnPtr<WorkerThreadStartupData> m_startupData;
95
        std::unique_ptr<WorkerThreadStartupData> m_startupData;
96
96
97
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
97
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
98
        NotificationClient* m_notificationClient;
98
        NotificationClient* m_notificationClient;

Return to Bug 132401