OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 WTF_MAKE_NONCOPYABLE(InProcessWorkerMessagingProxy); | 51 WTF_MAKE_NONCOPYABLE(InProcessWorkerMessagingProxy); |
52 | 52 |
53 public: | 53 public: |
54 // These methods should only be used on the parent context thread. | 54 // These methods should only be used on the parent context thread. |
55 void startWorkerGlobalScope(const KURL& scriptURL, | 55 void startWorkerGlobalScope(const KURL& scriptURL, |
56 const String& userAgent, | 56 const String& userAgent, |
57 const String& sourceCode, | 57 const String& sourceCode, |
58 ContentSecurityPolicy*, | 58 ContentSecurityPolicy*, |
59 const String& referrerPolicy); | 59 const String& referrerPolicy); |
60 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, | 60 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, |
61 std::unique_ptr<MessagePortChannelArray>); | 61 MessagePortChannelArray); |
62 | 62 |
63 void workerThreadCreated() override; | 63 void workerThreadCreated() override; |
64 void parentObjectDestroyed() override; | 64 void parentObjectDestroyed() override; |
65 | 65 |
66 bool hasPendingActivity() const; | 66 bool hasPendingActivity() const; |
67 | 67 |
68 // These methods come from worker context thread via | 68 // These methods come from worker context thread via |
69 // InProcessWorkerObjectProxy and are called on the parent context thread. | 69 // InProcessWorkerObjectProxy and are called on the parent context thread. |
70 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, | 70 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, |
71 std::unique_ptr<MessagePortChannelArray>); | 71 MessagePortChannelArray); |
72 void dispatchErrorEvent(const String& errorMessage, | 72 void dispatchErrorEvent(const String& errorMessage, |
73 std::unique_ptr<SourceLocation>, | 73 std::unique_ptr<SourceLocation>, |
74 int exceptionId); | 74 int exceptionId); |
75 | 75 |
76 // 'virtual' for testing. | 76 // 'virtual' for testing. |
77 virtual void confirmMessageFromWorkerObject(); | 77 virtual void confirmMessageFromWorkerObject(); |
78 | 78 |
79 // Called from InProcessWorkerObjectProxy when all pending activities on the | 79 // Called from InProcessWorkerObjectProxy when all pending activities on the |
80 // worker context are finished. See InProcessWorkerObjectProxy.h for details. | 80 // worker context are finished. See InProcessWorkerObjectProxy.h for details. |
81 virtual void pendingActivityFinished(); | 81 virtual void pendingActivityFinished(); |
(...skipping 11 matching lines...) Expand all Loading... |
93 InProcessWorkerMessagingProxy(ExecutionContext*, | 93 InProcessWorkerMessagingProxy(ExecutionContext*, |
94 InProcessWorkerBase*, | 94 InProcessWorkerBase*, |
95 WorkerClients*); | 95 WorkerClients*); |
96 | 96 |
97 std::unique_ptr<InProcessWorkerObjectProxy> m_workerObjectProxy; | 97 std::unique_ptr<InProcessWorkerObjectProxy> m_workerObjectProxy; |
98 WeakPersistent<InProcessWorkerBase> m_workerObject; | 98 WeakPersistent<InProcessWorkerBase> m_workerObject; |
99 Persistent<WorkerClients> m_workerClients; | 99 Persistent<WorkerClients> m_workerClients; |
100 | 100 |
101 struct QueuedTask { | 101 struct QueuedTask { |
102 RefPtr<SerializedScriptValue> message; | 102 RefPtr<SerializedScriptValue> message; |
103 std::unique_ptr<MessagePortChannelArray> channels; | 103 MessagePortChannelArray channels; |
104 | 104 |
105 QueuedTask(RefPtr<SerializedScriptValue> message, | 105 QueuedTask(RefPtr<SerializedScriptValue> message, |
106 std::unique_ptr<MessagePortChannelArray> channels); | 106 MessagePortChannelArray channels); |
107 ~QueuedTask(); | 107 ~QueuedTask(); |
108 }; | 108 }; |
109 | 109 |
110 // Tasks are queued here until there's a thread object created. | 110 // Tasks are queued here until there's a thread object created. |
111 Vector<std::unique_ptr<QueuedTask>> m_queuedEarlyTasks; | 111 Vector<std::unique_ptr<QueuedTask>> m_queuedEarlyTasks; |
112 | 112 |
113 // Unconfirmed messages from the parent context thread to the worker thread. | 113 // Unconfirmed messages from the parent context thread to the worker thread. |
114 // When this is greater than 0, |m_workerGlobalScopeHasPendingActivity| should | 114 // When this is greater than 0, |m_workerGlobalScopeHasPendingActivity| should |
115 // be true. | 115 // be true. |
116 unsigned m_unconfirmedMessageCount = 0; | 116 unsigned m_unconfirmedMessageCount = 0; |
117 | 117 |
118 // Indicates whether there are pending activities (e.g, MessageEvent, | 118 // Indicates whether there are pending activities (e.g, MessageEvent, |
119 // setTimeout) on the worker context. | 119 // setTimeout) on the worker context. |
120 bool m_workerGlobalScopeHasPendingActivity = false; | 120 bool m_workerGlobalScopeHasPendingActivity = false; |
121 | 121 |
122 WeakPtrFactory<InProcessWorkerMessagingProxy> m_weakPtrFactory; | 122 WeakPtrFactory<InProcessWorkerMessagingProxy> m_weakPtrFactory; |
123 }; | 123 }; |
124 | 124 |
125 } // namespace blink | 125 } // namespace blink |
126 | 126 |
127 #endif // InProcessWorkerMessagingProxy_h | 127 #endif // InProcessWorkerMessagingProxy_h |
OLD | NEW |