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

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

Issue 1075603003: workers: Move core worker functionality into InProcessWorkerBase. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/Worker.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 25 matching lines...) Expand all
36 #include "wtf/PassOwnPtr.h" 36 #include "wtf/PassOwnPtr.h"
37 #include "wtf/PassRefPtr.h" 37 #include "wtf/PassRefPtr.h"
38 #include "wtf/RefPtr.h" 38 #include "wtf/RefPtr.h"
39 #include "wtf/Vector.h" 39 #include "wtf/Vector.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class WorkerObjectProxy; 43 class WorkerObjectProxy;
44 class WorkerThread; 44 class WorkerThread;
45 class ExecutionContext; 45 class ExecutionContext;
46 class Worker; 46 class InProcessWorkerBase;
47 class WorkerClients; 47 class WorkerClients;
48 class WorkerInspectorProxy; 48 class WorkerInspectorProxy;
49 49
50 class CORE_EXPORT WorkerMessagingProxy 50 class CORE_EXPORT WorkerMessagingProxy
51 : public WorkerGlobalScopeProxy 51 : public WorkerGlobalScopeProxy
52 , private WorkerLoaderProxyProvider { 52 , private WorkerLoaderProxyProvider {
53 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); 53 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy);
54 WTF_MAKE_FAST_ALLOCATED(WorkerMessagingProxy);
55 public: 54 public:
56 WorkerMessagingProxy(Worker*, PassOwnPtrWillBeRawPtr<WorkerClients>);
57
58 // Implementations of WorkerGlobalScopeProxy. 55 // Implementations of WorkerGlobalScopeProxy.
59 // (Only use these methods in the worker object thread.) 56 // (Only use these methods in the worker object thread.)
60 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String& use rAgent, const String& sourceCode, WorkerThreadStartMode) override; 57 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String& use rAgent, const String& sourceCode, WorkerThreadStartMode) override;
61 virtual void terminateWorkerGlobalScope() override; 58 virtual void terminateWorkerGlobalScope() override;
62 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue >, PassOwnPtr<MessagePortChannelArray>) override; 59 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue >, PassOwnPtr<MessagePortChannelArray>) override;
63 virtual bool hasPendingActivity() const override; 60 virtual bool hasPendingActivity() const override;
64 virtual void workerObjectDestroyed() override; 61 virtual void workerObjectDestroyed() override;
65 62
66 // These methods come from worker context thread via WorkerObjectProxy 63 // These methods come from worker context thread via WorkerObjectProxy
67 // and are called on the worker object thread (e.g. main thread). 64 // and are called on the worker object thread (e.g. main thread).
68 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr <MessagePortChannelArray>); 65 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr <MessagePortChannelArray>);
69 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, int exceptionId); 66 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, int exceptionId);
70 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , int lineNumber, const String& sourceURL); 67 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , int lineNumber, const String& sourceURL);
71 void postMessageToPageInspector(const String&); 68 void postMessageToPageInspector(const String&);
72 void postWorkerConsoleAgentEnabled(); 69 void postWorkerConsoleAgentEnabled();
73 WorkerInspectorProxy* workerInspectorProxy(); 70 WorkerInspectorProxy* workerInspectorProxy();
74 void confirmMessageFromWorkerObject(bool hasPendingActivity); 71 void confirmMessageFromWorkerObject(bool hasPendingActivity);
75 void reportPendingActivity(bool hasPendingActivity); 72 void reportPendingActivity(bool hasPendingActivity);
76 void workerGlobalScopeClosed(); 73 void workerGlobalScopeClosed();
77 void workerThreadTerminated(); 74 void workerThreadTerminated();
78 75
79 void workerThreadCreated(PassRefPtr<WorkerThread>); 76 void workerThreadCreated(PassRefPtr<WorkerThread>);
80 77
81 protected: 78 protected:
79 WorkerMessagingProxy(InProcessWorkerBase*, PassOwnPtrWillBeRawPtr<WorkerClie nts>);
82 virtual ~WorkerMessagingProxy(); 80 virtual ~WorkerMessagingProxy();
83 81
84 virtual PassRefPtr<WorkerThread> createWorkerThread(double originTime, PassO wnPtr<WorkerThreadStartupData>); 82 virtual PassRefPtr<WorkerThread> createWorkerThread(double originTime, PassO wnPtr<WorkerThreadStartupData>) = 0;
85 83
86 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } 84 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; }
87 WorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProxy.get(); } 85 WorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProxy.get(); }
88 86
89 private: 87 private:
90 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessaging Proxy*); 88 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessaging Proxy*);
91 void terminateInternally(); 89 void terminateInternally();
92 90
93 // WorkerLoaderProxyProvider 91 // WorkerLoaderProxyProvider
94 // These methods are called on different threads to schedule loading 92 // These methods are called on different threads to schedule loading
95 // requests and to send callbacks back to WorkerGlobalScope. 93 // requests and to send callbacks back to WorkerGlobalScope.
96 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; 94 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override;
97 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o verride; 95 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o verride;
98 96
99 RefPtrWillBePersistent<ExecutionContext> m_executionContext; 97 RefPtrWillBePersistent<ExecutionContext> m_executionContext;
100 OwnPtr<WorkerObjectProxy> m_workerObjectProxy; 98 OwnPtr<WorkerObjectProxy> m_workerObjectProxy;
101 Worker* m_workerObject; 99 InProcessWorkerBase* m_workerObject;
102 bool m_mayBeDestroyed; 100 bool m_mayBeDestroyed;
103 RefPtr<WorkerThread> m_workerThread; 101 RefPtr<WorkerThread> m_workerThread;
104 102
105 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje ct to worker thread. 103 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje ct to worker thread.
106 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke r thread reported that it was still active. 104 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke r thread reported that it was still active.
107 105
108 bool m_askedToTerminate; 106 bool m_askedToTerminate;
109 107
110 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued here until there's a thread object created. 108 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued here until there's a thread object created.
111 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; 109 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy;
112 110
113 OwnPtrWillBePersistent<WorkerClients> m_workerClients; 111 OwnPtrWillBePersistent<WorkerClients> m_workerClients;
114 112
115 RefPtr<WorkerLoaderProxy> m_loaderProxy; 113 RefPtr<WorkerLoaderProxy> m_loaderProxy;
116 }; 114 };
117 115
118 } // namespace blink 116 } // namespace blink
119 117
120 #endif // WorkerMessagingProxy_h 118 #endif // WorkerMessagingProxy_h
OLDNEW
« no previous file with comments | « Source/core/workers/Worker.cpp ('k') | Source/core/workers/WorkerMessagingProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698