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

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

Issue 15338009: Move workers to Chromium threading (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert actual model change Created 7 years, 7 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/WorkerRunLoop.cpp ('k') | Source/core/workers/WorkerThread.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 13 matching lines...) Expand all
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/page/ContentSecurityPolicy.h" 30 #include "core/page/ContentSecurityPolicy.h"
31 #include "core/page/GroupSettings.h" 31 #include "core/page/GroupSettings.h"
32 #include "core/workers/WorkerRunLoop.h" 32 #include "core/workers/WorkerRunLoop.h"
33 #include "weborigin/SecurityOrigin.h" 33 #include "weborigin/SecurityOrigin.h"
34 #include <wtf/Forward.h> 34 #include "wtf/Forward.h"
35 #include <wtf/OwnPtr.h> 35 #include "wtf/OwnPtr.h"
36 #include <wtf/PassRefPtr.h> 36 #include "wtf/PassRefPtr.h"
37 #include <wtf/RefCounted.h> 37 #include "wtf/RefCounted.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 class KURL; 41 class KURL;
42 class NotificationClient; 42 class NotificationClient;
43 class WorkerContext; 43 class WorkerContext;
44 class WorkerLoaderProxy; 44 class WorkerLoaderProxy;
45 class WorkerReportingProxy; 45 class WorkerReportingProxy;
46 struct WorkerThreadStartupData; 46 struct WorkerThreadStartupData;
47 47
48 enum WorkerThreadStartMode { DontPauseWorkerContextOnStart, PauseWorkerConte xtOnStart }; 48 enum WorkerThreadStartMode { DontPauseWorkerContextOnStart, PauseWorkerConte xtOnStart };
49 49
50 class WorkerThread : public RefCounted<WorkerThread> { 50 class WorkerThread : public RefCounted<WorkerThread> {
51 public: 51 public:
52 virtual ~WorkerThread(); 52 virtual ~WorkerThread();
53 53
54 bool start(); 54 bool start();
55 void stop(); 55 void stop();
56 56
57 ThreadIdentifier threadID() const { return m_threadID; } 57 bool isCurrentThread() const;
58 WorkerRunLoop& runLoop() { return m_runLoop; } 58 WorkerRunLoop& runLoop() { return m_runLoop; }
59 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx y; } 59 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx y; }
60 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo rtingProxy; } 60 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo rtingProxy; }
61 61
62 // Number of active worker threads. 62 // Number of active worker threads.
63 static unsigned workerThreadCount(); 63 static unsigned workerThreadCount();
64 static void releaseFastMallocFreeMemoryInAllThreads(); 64 static void releaseFastMallocFreeMemoryInAllThreads();
65 65
66 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 66 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
67 NotificationClient* getNotificationClient() { return m_notificationClien t; } 67 NotificationClient* getNotificationClient() { return m_notificationClien t; }
68 void setNotificationClient(NotificationClient* client) { m_notificationC lient = client; } 68 void setNotificationClient(NotificationClient* client) { m_notificationC lient = client; }
69 #endif 69 #endif
70 70
71 protected: 71 protected:
72 WorkerThread(const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThr eadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::Header Type, const SecurityOrigin* topOrigin); 72 WorkerThread(const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThr eadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::Header Type, const SecurityOrigin* topOrigin);
73 73
74 // Factory method for creating a new worker context for the thread. 74 // Factory method for creating a new worker context for the thread.
75 virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPoli cy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin) = 0 ; 75 virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPoli cy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin) = 0 ;
76 76
77 // Executes the event loop for the worker thread. Derived classes can ov erride to perform actions before/after entering the event loop. 77 // Executes the event loop for the worker thread. Derived classes can ov erride to perform actions before/after entering the event loop.
78 virtual void runEventLoop(); 78 virtual void runEventLoop();
79 79
80 WorkerContext* workerContext() { return m_workerContext.get(); } 80 WorkerContext* workerContext() { return m_workerContext.get(); }
81 81
82 private: 82 private:
83 // Static function executed as the core routine on the new thread. Passe d a pointer to a WorkerThread object. 83 // Static function executed as the core routine on the new thread. Passe d a pointer to a WorkerThread object.
84 static void workerThreadStart(void*); 84 static void workerThreadStart(void*);
85
85 void workerThread(); 86 void workerThread();
86 87
87 ThreadIdentifier m_threadID; 88 ThreadIdentifier m_threadID;
88 WorkerRunLoop m_runLoop; 89 WorkerRunLoop m_runLoop;
89 WorkerLoaderProxy& m_workerLoaderProxy; 90 WorkerLoaderProxy& m_workerLoaderProxy;
90 WorkerReportingProxy& m_workerReportingProxy; 91 WorkerReportingProxy& m_workerReportingProxy;
91 92
92 RefPtr<WorkerContext> m_workerContext; 93 RefPtr<WorkerContext> m_workerContext;
93 Mutex m_threadCreationMutex; 94 Mutex m_threadCreationMutex;
94 95
95 OwnPtr<WorkerThreadStartupData> m_startupData; 96 OwnPtr<WorkerThreadStartupData> m_startupData;
96 97
97 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 98 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
98 NotificationClient* m_notificationClient; 99 NotificationClient* m_notificationClient;
99 #endif 100 #endif
100 }; 101 };
101 102
102 } // namespace WebCore 103 } // namespace WebCore
103 104
104 #endif // WorkerThread_h 105 #endif // WorkerThread_h
105 106
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerRunLoop.cpp ('k') | Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698