Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.h

Issue 2124693002: Worker: Fix broken GC logic on Dedicated Worker while DOMTimer is set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef InProcessWorkerObjectProxy_h 31 #ifndef InProcessWorkerObjectProxy_h
32 #define InProcessWorkerObjectProxy_h 32 #define InProcessWorkerObjectProxy_h
33 33
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "core/dom/MessagePort.h" 35 #include "core/dom/MessagePort.h"
36 #include "core/workers/WorkerReportingProxy.h" 36 #include "core/workers/WorkerReportingProxy.h"
37 #include "platform/Timer.h"
37 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
38 #include "wtf/PassRefPtr.h" 39 #include "wtf/PassRefPtr.h"
39 #include <memory> 40 #include <memory>
40 41
41 namespace blink { 42 namespace blink {
42 43
43 class ConsoleMessage; 44 class ConsoleMessage;
44 class ExecutionContext; 45 class ExecutionContext;
45 class ExecutionContextTask; 46 class ExecutionContextTask;
46 class InProcessWorkerMessagingProxy; 47 class InProcessWorkerMessagingProxy;
47 class ParentFrameTaskRunners; 48 class ParentFrameTaskRunners;
49 class WorkerGlobalScope;
48 class WorkerOrWorkletGlobalScope; 50 class WorkerOrWorkletGlobalScope;
49 51
50 // A proxy to talk to the worker object. This object is created on the 52 // A proxy to talk to the worker object. This object is created on the
51 // parent context thread (i.e. usually the main thread), passed on to 53 // parent context thread (i.e. usually the main thread), passed on to
52 // the worker thread, and used just to proxy messages to the 54 // the worker thread, and used to proxy messages to the
53 // InProcessWorkerMessagingProxy on the parent context thread. 55 // InProcessWorkerMessagingProxy on the parent context thread.
54 // 56 //
57 // This also checks pending activities on WorkerGlobalScope and reports a result
58 // to the message proxy when an exponential backoff timer is fired.
59 //
55 // Used only by in-process workers (DedicatedWorker and CompositorWorker.) 60 // Used only by in-process workers (DedicatedWorker and CompositorWorker.)
56 class CORE_EXPORT InProcessWorkerObjectProxy : public WorkerReportingProxy { 61 class CORE_EXPORT InProcessWorkerObjectProxy : public WorkerReportingProxy {
57 USING_FAST_MALLOC(InProcessWorkerObjectProxy); 62 USING_FAST_MALLOC(InProcessWorkerObjectProxy);
58 WTF_MAKE_NONCOPYABLE(InProcessWorkerObjectProxy); 63 WTF_MAKE_NONCOPYABLE(InProcessWorkerObjectProxy);
59 public: 64 public:
60 static std::unique_ptr<InProcessWorkerObjectProxy> create(InProcessWorkerMes sagingProxy*); 65 static std::unique_ptr<InProcessWorkerObjectProxy> create(InProcessWorkerMes sagingProxy*);
61 ~InProcessWorkerObjectProxy() override { } 66 ~InProcessWorkerObjectProxy() override;
62 67
63 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, std::uniqu e_ptr<MessagePortChannelArray>); 68 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, std::uniqu e_ptr<MessagePortChannelArray>);
64 void postTaskToMainExecutionContext(std::unique_ptr<ExecutionContextTask>); 69 void postTaskToMainExecutionContext(std::unique_ptr<ExecutionContextTask>);
65 void confirmMessageFromWorkerObject(bool hasPendingActivity); 70 void confirmMessageFromWorkerObject();
66 void reportPendingActivity(bool hasPendingActivity); 71 void startPendingActivityTimer();
67 72
68 // WorkerReportingProxy overrides. 73 // WorkerReportingProxy overrides.
69 void reportException(const String& errorMessage, std::unique_ptr<SourceLocat ion>, int exceptionId) override; 74 void reportException(const String& errorMessage, std::unique_ptr<SourceLocat ion>, int exceptionId) override;
70 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , SourceLocation*) override; 75 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , SourceLocation*) override;
71 void postMessageToPageInspector(const String&) override; 76 void postMessageToPageInspector(const String&) override;
72 void didEvaluateWorkerScript(bool success) override { } 77 void didEvaluateWorkerScript(bool success) override;
73 void workerGlobalScopeStarted(WorkerOrWorkletGlobalScope*) override { } 78 void workerGlobalScopeStarted(WorkerOrWorkletGlobalScope*) override;
74 void workerGlobalScopeClosed() override; 79 void workerGlobalScopeClosed() override;
75 void workerThreadTerminated() override; 80 void workerThreadTerminated() override;
76 void willDestroyWorkerGlobalScope() override { } 81 void willDestroyWorkerGlobalScope() override;
77 82
78 protected: 83 protected:
79 InProcessWorkerObjectProxy(InProcessWorkerMessagingProxy*); 84 InProcessWorkerObjectProxy(InProcessWorkerMessagingProxy*);
80 virtual ExecutionContext* getExecutionContext(); 85 virtual ExecutionContext* getExecutionContext();
81 86
82 private: 87 private:
88 friend class InProcessWorkerMessagingProxyForTest;
89
90 void checkPendingActivity(TimerBase*);
91
83 // Returns the parent frame's task runners. 92 // Returns the parent frame's task runners.
84 ParentFrameTaskRunners* getParentFrameTaskRunners(); 93 ParentFrameTaskRunners* getParentFrameTaskRunners();
85 94
86 // This object always outlives this proxy. 95 // This object always outlives this proxy.
87 InProcessWorkerMessagingProxy* m_messagingProxy; 96 InProcessWorkerMessagingProxy* m_messagingProxy;
97
98 // Used for checking pending activities on the worker global scope. This is
99 // cancelled when the worker global scope is destroyed.
100 std::unique_ptr<Timer<InProcessWorkerObjectProxy>> m_timer;
101
102 // The current interval duration of the timer. This is initially set to
103 // kDefaultIntervalInSec and exponentially increased up to
104 // |m_maxIntervalInSec|.
105 double m_currentIntervalInSec;
106
107 // The max interval duration of the timer. This is usually kMaxIntervalInSec
108 // but made as a member variable for testing.
109 double m_maxIntervalInSec;
110
111 Persistent<WorkerGlobalScope> m_workerGlobalScope;
88 }; 112 };
89 113
90 } // namespace blink 114 } // namespace blink
91 115
92 #endif // InProcessWorkerObjectProxy_h 116 #endif // InProcessWorkerObjectProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698