OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 #include "core/workers/WorkerReportingProxy.h" | 37 #include "core/workers/WorkerReportingProxy.h" |
38 #include "platform/Timer.h" | 38 #include "platform/Timer.h" |
39 #include "platform/heap/Handle.h" | 39 #include "platform/heap/Handle.h" |
40 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
41 #include "wtf/WeakPtr.h" | 41 #include "wtf/WeakPtr.h" |
42 #include <memory> | 42 #include <memory> |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 class InProcessWorkerMessagingProxy; | 46 class InProcessWorkerMessagingProxy; |
47 class ParentFrameTaskRunners; | |
48 class ThreadedMessagingProxyBase; | 47 class ThreadedMessagingProxyBase; |
49 class WorkerGlobalScope; | 48 class WorkerGlobalScope; |
50 class WorkerOrWorkletGlobalScope; | 49 class WorkerOrWorkletGlobalScope; |
51 class WorkerThread; | 50 class WorkerThread; |
52 | 51 |
53 // A proxy to talk to the parent worker object. See class comments on | 52 // A proxy to talk to the parent worker object. See class comments on |
54 // ThreadedObjectProxyBase.h for lifetime of this class etc. | 53 // ThreadedObjectProxyBase.h for lifetime of this class etc. |
55 // | 54 // |
56 // This also checks pending activities on WorkerGlobalScope and reports a result | 55 // This also checks pending activities on WorkerGlobalScope and reports a result |
57 // to the message proxy when an exponential backoff timer is fired. | 56 // to the message proxy when an exponential backoff timer is fired. |
58 class CORE_EXPORT InProcessWorkerObjectProxy : public ThreadedObjectProxyBase { | 57 class CORE_EXPORT InProcessWorkerObjectProxy : public ThreadedObjectProxyBase { |
59 USING_FAST_MALLOC(InProcessWorkerObjectProxy); | 58 USING_FAST_MALLOC(InProcessWorkerObjectProxy); |
60 WTF_MAKE_NONCOPYABLE(InProcessWorkerObjectProxy); | 59 WTF_MAKE_NONCOPYABLE(InProcessWorkerObjectProxy); |
61 | 60 |
62 public: | 61 public: |
63 static std::unique_ptr<InProcessWorkerObjectProxy> create( | 62 static std::unique_ptr<InProcessWorkerObjectProxy> create( |
64 const WeakPtr<InProcessWorkerMessagingProxy>&, | 63 const WeakPtr<InProcessWorkerMessagingProxy>&); |
65 ParentFrameTaskRunners*); | |
66 ~InProcessWorkerObjectProxy() override; | 64 ~InProcessWorkerObjectProxy() override; |
67 | 65 |
68 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, | 66 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, |
69 MessagePortChannelArray); | 67 MessagePortChannelArray); |
70 void processUnhandledException(int exceptionId, WorkerThread*); | 68 void processUnhandledException(int exceptionId, WorkerThread*); |
71 void processMessageFromWorkerObject(PassRefPtr<SerializedScriptValue> message, | 69 void processMessageFromWorkerObject(PassRefPtr<SerializedScriptValue> message, |
72 MessagePortChannelArray channels, | 70 MessagePortChannelArray channels, |
73 WorkerThread*); | 71 WorkerThread*); |
74 | 72 |
75 // ThreadedObjectProxyBase overrides. | 73 // ThreadedObjectProxyBase overrides. |
76 void reportException(const String& errorMessage, | 74 void reportException(const String& errorMessage, |
77 std::unique_ptr<SourceLocation>, | 75 std::unique_ptr<SourceLocation>, |
78 int exceptionId) override; | 76 int exceptionId) override; |
79 void didCreateWorkerGlobalScope(WorkerOrWorkletGlobalScope*) override; | 77 void didCreateWorkerGlobalScope(WorkerOrWorkletGlobalScope*) override; |
80 void didEvaluateWorkerScript(bool success) override; | 78 void didEvaluateWorkerScript(bool success) override; |
81 void willDestroyWorkerGlobalScope() override; | 79 void willDestroyWorkerGlobalScope() override; |
82 | 80 |
83 protected: | 81 protected: |
84 InProcessWorkerObjectProxy(const WeakPtr<InProcessWorkerMessagingProxy>&, | 82 explicit InProcessWorkerObjectProxy( |
85 ParentFrameTaskRunners*); | 83 const WeakPtr<InProcessWorkerMessagingProxy>&); |
86 | 84 |
87 WeakPtr<ThreadedMessagingProxyBase> messagingProxyWeakPtr() final; | 85 WeakPtr<ThreadedMessagingProxyBase> messagingProxyWeakPtr() final; |
88 | 86 |
89 private: | 87 private: |
90 friend class InProcessWorkerMessagingProxyForTest; | 88 friend class InProcessWorkerMessagingProxyForTest; |
91 | 89 |
92 void startPendingActivityTimer(); | 90 void startPendingActivityTimer(); |
93 void checkPendingActivity(TimerBase*); | 91 void checkPendingActivity(TimerBase*); |
94 | 92 |
95 // No guarantees about the lifetimes of tasks posted by this proxy wrt the | 93 // No guarantees about the lifetimes of tasks posted by this proxy wrt the |
(...skipping 17 matching lines...) Expand all Loading... |
113 // The max interval duration of the timer. This is usually kMaxIntervalInSec | 111 // The max interval duration of the timer. This is usually kMaxIntervalInSec |
114 // but made as a member variable for testing. | 112 // but made as a member variable for testing. |
115 double m_maxIntervalInSec; | 113 double m_maxIntervalInSec; |
116 | 114 |
117 CrossThreadPersistent<WorkerGlobalScope> m_workerGlobalScope; | 115 CrossThreadPersistent<WorkerGlobalScope> m_workerGlobalScope; |
118 }; | 116 }; |
119 | 117 |
120 } // namespace blink | 118 } // namespace blink |
121 | 119 |
122 #endif // InProcessWorkerObjectProxy_h | 120 #endif // InProcessWorkerObjectProxy_h |
OLD | NEW |