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

Side by Side Diff: Source/core/workers/WorkerMessagingProxy.h

Issue 887463003: Turn WorkerLoaderProxy into a threadsafe, ref-counted object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clarify WorkerLoaderProxyProvider's obligations on shutdown Created 5 years, 10 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
« no previous file with comments | « Source/core/workers/WorkerLoaderProxy.cpp ('k') | Source/core/workers/WorkerMessagingProxy.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 28 matching lines...) Expand all
39 39
40 namespace blink { 40 namespace blink {
41 41
42 class WorkerObjectProxy; 42 class WorkerObjectProxy;
43 class DedicatedWorkerThread; 43 class DedicatedWorkerThread;
44 class ExecutionContext; 44 class ExecutionContext;
45 class Worker; 45 class Worker;
46 class WorkerClients; 46 class WorkerClients;
47 class WorkerInspectorProxy; 47 class WorkerInspectorProxy;
48 48
49 class WorkerMessagingProxy final : public WorkerGlobalScopeProxy, public WorkerL oaderProxy { 49 class WorkerMessagingProxy final
50 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED; 50 : public WorkerGlobalScopeProxy
51 , private WorkerLoaderProxyProvider {
52 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy);
53 WTF_MAKE_FAST_ALLOCATED;
51 public: 54 public:
52 WorkerMessagingProxy(Worker*, PassOwnPtrWillBeRawPtr<WorkerClients>); 55 WorkerMessagingProxy(Worker*, PassOwnPtrWillBeRawPtr<WorkerClients>);
53 56
54 // Implementations of WorkerGlobalScopeProxy. 57 // Implementations of WorkerGlobalScopeProxy.
55 // (Only use these methods in the worker object thread.) 58 // (Only use these methods in the worker object thread.)
56 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String& use rAgent, const String& sourceCode, WorkerThreadStartMode) override; 59 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String& use rAgent, const String& sourceCode, WorkerThreadStartMode) override;
57 virtual void terminateWorkerGlobalScope() override; 60 virtual void terminateWorkerGlobalScope() override;
58 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue >, PassOwnPtr<MessagePortChannelArray>) override; 61 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue >, PassOwnPtr<MessagePortChannelArray>) override;
59 virtual bool hasPendingActivity() const override; 62 virtual bool hasPendingActivity() const override;
60 virtual void workerObjectDestroyed() override; 63 virtual void workerObjectDestroyed() override;
61 64
62 // These methods come from worker context thread via WorkerObjectProxy 65 // These methods come from worker context thread via WorkerObjectProxy
63 // and are called on the worker object thread (e.g. main thread). 66 // and are called on the worker object thread (e.g. main thread).
64 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr <MessagePortChannelArray>); 67 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr <MessagePortChannelArray>);
65 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, int exceptionId); 68 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, int exceptionId);
66 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , int lineNumber, const String& sourceURL); 69 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , int lineNumber, const String& sourceURL);
67 void postMessageToPageInspector(const String&); 70 void postMessageToPageInspector(const String&);
68 void postWorkerConsoleAgentEnabled(); 71 void postWorkerConsoleAgentEnabled();
69 WorkerInspectorProxy* workerInspectorProxy(); 72 WorkerInspectorProxy* workerInspectorProxy();
70 void confirmMessageFromWorkerObject(bool hasPendingActivity); 73 void confirmMessageFromWorkerObject(bool hasPendingActivity);
71 void reportPendingActivity(bool hasPendingActivity); 74 void reportPendingActivity(bool hasPendingActivity);
72 void workerGlobalScopeClosed(); 75 void workerGlobalScopeClosed();
73 void workerThreadTerminated(); 76 void workerThreadTerminated();
74 77
75 // Implementation of WorkerLoaderProxy.
76 // These methods are called on different threads to schedule loading
77 // requests and to send callbacks back to WorkerGlobalScope.
78 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override;
79 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o verride;
80
81 void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>); 78 void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>);
82 79
83 protected: 80 protected:
84 virtual ~WorkerMessagingProxy(); 81 virtual ~WorkerMessagingProxy();
85 82
86 private: 83 private:
87 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessaging Proxy*); 84 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessaging Proxy*);
88 void terminateInternally(); 85 void terminateInternally();
89 86
87 // WorkerLoaderProxyProvider
88 // These methods are called on different threads to schedule loading
89 // requests and to send callbacks back to WorkerGlobalScope.
90 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override;
91 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o verride;
92
90 RefPtrWillBePersistent<ExecutionContext> m_executionContext; 93 RefPtrWillBePersistent<ExecutionContext> m_executionContext;
91 OwnPtr<WorkerObjectProxy> m_workerObjectProxy; 94 OwnPtr<WorkerObjectProxy> m_workerObjectProxy;
92 Worker* m_workerObject; 95 Worker* m_workerObject;
93 bool m_mayBeDestroyed; 96 bool m_mayBeDestroyed;
94 RefPtr<DedicatedWorkerThread> m_workerThread; 97 RefPtr<DedicatedWorkerThread> m_workerThread;
95 98
96 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje ct to worker thread. 99 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje ct to worker thread.
97 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke r thread reported that it was still active. 100 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke r thread reported that it was still active.
98 101
99 bool m_askedToTerminate; 102 bool m_askedToTerminate;
100 103
101 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued here until there's a thread object created. 104 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued here until there's a thread object created.
102 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; 105 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy;
103 106
104 OwnPtrWillBePersistent<WorkerClients> m_workerClients; 107 OwnPtrWillBePersistent<WorkerClients> m_workerClients;
108
109 RefPtr<WorkerLoaderProxy> m_loaderProxy;
105 }; 110 };
106 111
107 } // namespace blink 112 } // namespace blink
108 113
109 #endif // WorkerMessagingProxy_h 114 #endif // WorkerMessagingProxy_h
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerLoaderProxy.cpp ('k') | Source/core/workers/WorkerMessagingProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698