| 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 13 matching lines...) Expand all  Loading... | 
|   24  * |   24  * | 
|   25  */ |   25  */ | 
|   26  |   26  | 
|   27 #ifndef WorkerThread_h |   27 #ifndef WorkerThread_h | 
|   28 #define WorkerThread_h |   28 #define WorkerThread_h | 
|   29  |   29  | 
|   30 #include "core/dom/ExecutionContextTask.h" |   30 #include "core/dom/ExecutionContextTask.h" | 
|   31 #include "core/frame/csp/ContentSecurityPolicy.h" |   31 #include "core/frame/csp/ContentSecurityPolicy.h" | 
|   32 #include "core/workers/WorkerGlobalScope.h" |   32 #include "core/workers/WorkerGlobalScope.h" | 
|   33 #include "platform/SharedTimer.h" |   33 #include "platform/SharedTimer.h" | 
|   34 #include "platform/WebThreadSupportingGC.h" |   34 #include "platform/heap/glue/MessageLoopInterruptor.h" | 
 |   35 #include "platform/heap/glue/PendingGCRunner.h" | 
|   35 #include "platform/weborigin/SecurityOrigin.h" |   36 #include "platform/weborigin/SecurityOrigin.h" | 
 |   37 #include "public/platform/WebThread.h" | 
|   36 #include "wtf/Forward.h" |   38 #include "wtf/Forward.h" | 
|   37 #include "wtf/MessageQueue.h" |   39 #include "wtf/MessageQueue.h" | 
|   38 #include "wtf/OwnPtr.h" |   40 #include "wtf/OwnPtr.h" | 
|   39 #include "wtf/PassRefPtr.h" |   41 #include "wtf/PassRefPtr.h" | 
|   40 #include "wtf/RefCounted.h" |   42 #include "wtf/RefCounted.h" | 
|   41  |   43  | 
|   42 namespace blink { |   44 namespace blink { | 
|   43 class WebWaitableEvent; |   45 class WebWaitableEvent; | 
|   44 } |   46 } | 
|   45  |   47  | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   90         WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScop
     e.get(); } |   92         WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScop
     e.get(); } | 
|   91         bool terminated() const { return m_terminated; } |   93         bool terminated() const { return m_terminated; } | 
|   92  |   94  | 
|   93         // Number of active worker threads. |   95         // Number of active worker threads. | 
|   94         static unsigned workerThreadCount(); |   96         static unsigned workerThreadCount(); | 
|   95  |   97  | 
|   96         PlatformThreadId platformThreadId() const; |   98         PlatformThreadId platformThreadId() const; | 
|   97  |   99  | 
|   98         void interruptAndDispatchInspectorCommands(); |  100         void interruptAndDispatchInspectorCommands(); | 
|   99         void setWorkerInspectorController(WorkerInspectorController*); |  101         void setWorkerInspectorController(WorkerInspectorController*); | 
 |  102         void postTaskLanguageChanged(); | 
 |  103         // static void notifyAcceptLanguagesChanged(const String& newLanguagesLi
     st); | 
 |  104         static void notifyAcceptLanguagesChanged(const Vector<String>& newLangua
     gesList); | 
|  100  |  105  | 
|  101     protected: |  106     protected: | 
|  102         WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBe
     RawPtr<WorkerThreadStartupData>); |  107         WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBe
     RawPtr<WorkerThreadStartupData>); | 
|  103  |  108  | 
|  104         // Factory method for creating a new worker context for the thread. |  109         // Factory method for creating a new worker context for the thread. | 
|  105         virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScop
     e(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; |  110         virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScop
     e(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; | 
|  106  |  111  | 
|  107         virtual void postInitialize() { } |  112         virtual void postInitialize() { } | 
|  108  |  113  | 
|  109     private: |  114     private: | 
|  110         friend class WorkerSharedTimer; |  115         friend class WorkerSharedTimer; | 
|  111         friend class WorkerThreadShutdownFinishTask; |  116         friend class WorkerThreadShutdownFinishTask; | 
|  112  |  117  | 
|  113         void stopInShutdownSequence(); |  118         void stopInShutdownSequence(); | 
|  114         void stopInternal(); |  119         void stopInternal(); | 
|  115  |  120  | 
|  116         void initialize(); |  121         void initialize(); | 
|  117         void cleanup(); |  122         void cleanup(); | 
|  118         void idleHandler(); |  123         void idleHandler(); | 
|  119         void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs
     ); |  124         void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs
     ); | 
|  120  |  125  | 
|  121         bool m_terminated; |  126         bool m_terminated; | 
|  122         OwnPtr<WorkerSharedTimer> m_sharedTimer; |  127         OwnPtr<WorkerSharedTimer> m_sharedTimer; | 
|  123         MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; |  128         MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; | 
 |  129         OwnPtr<PendingGCRunner> m_pendingGCRunner; | 
|  124         OwnPtr<WebThread::TaskObserver> m_microtaskRunner; |  130         OwnPtr<WebThread::TaskObserver> m_microtaskRunner; | 
 |  131         OwnPtr<MessageLoopInterruptor> m_messageLoopInterruptor; | 
|  125  |  132  | 
|  126         WorkerLoaderProxy& m_workerLoaderProxy; |  133         WorkerLoaderProxy& m_workerLoaderProxy; | 
|  127         WorkerReportingProxy& m_workerReportingProxy; |  134         WorkerReportingProxy& m_workerReportingProxy; | 
|  128  |  135  | 
|  129         RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorContr
     oller; |  136         RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorContr
     oller; | 
|  130         Mutex m_workerInspectorControllerMutex; |  137         Mutex m_workerInspectorControllerMutex; | 
|  131  |  138  | 
|  132         Mutex m_threadCreationMutex; |  139         Mutex m_threadCreationMutex; | 
|  133         RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; |  140         RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; | 
|  134         OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; |  141         OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; | 
|  135  |  142  | 
|  136         // Used to signal thread shutdown. |  143         // Used to signal thread shutdown. | 
|  137         OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; |  144         OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; | 
|  138  |  145  | 
|  139         // Used to signal thread termination. |  146         // Used to signal thread termination. | 
|  140         OwnPtr<blink::WebWaitableEvent> m_terminationEvent; |  147         OwnPtr<blink::WebWaitableEvent> m_terminationEvent; | 
|  141  |  148  | 
|  142         // FIXME: This has to be last because of crbug.com/401397 - the |  149         // FIXME: This has to be last because of crbug.com/401397 - the | 
|  143         // WorkerThread might get deleted before it had a chance to properly |  150         // WorkerThread might get deleted before it had a chance to properly | 
|  144         // shut down. By deleting the WebThread first, we can guarantee that |  151         // shut down. By deleting the WebThread first, we can guarantee that | 
|  145         // no pending tasks on the thread might want to access any of the other |  152         // no pending tasks on the thread might want to access any of the other | 
|  146         // members during the WorkerThread's destruction. |  153         // members during the WorkerThread's destruction. | 
|  147         OwnPtr<WebThreadSupportingGC> m_thread; |  154         OwnPtr<blink::WebThread> m_thread; | 
|  148     }; |  155     }; | 
|  149  |  156  | 
|  150 } // namespace blink |  157 } // namespace blink | 
|  151  |  158  | 
|  152 #endif // WorkerThread_h |  159 #endif // WorkerThread_h | 
| OLD | NEW |