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

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

Issue 106353005: Expose performance.memory in workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@Perf-Memory-SharedWorker
Patch Set: Created 6 years, 9 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
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 class WebWaitableEvent; 39 class WebWaitableEvent;
40 } 40 }
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 class KURL; 44 class KURL;
45 class NotificationClient; 45 class NotificationClient;
46 class WorkerGlobalScope; 46 class WorkerGlobalScope;
47 class WorkerLoaderProxy; 47 class WorkerLoaderProxy;
48 class WorkerReportingProxy; 48 class WorkerReportingProxy;
49 class WorkerSettings;
49 struct WorkerThreadStartupData; 50 struct WorkerThreadStartupData;
50 51
51 enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerG lobalScopeOnStart }; 52 enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerG lobalScopeOnStart };
52 53
53 class WorkerThread : public RefCounted<WorkerThread> { 54 class WorkerThread : public RefCounted<WorkerThread> {
54 public: 55 public:
55 virtual ~WorkerThread(); 56 virtual ~WorkerThread();
56 57
57 bool start(); 58 bool start();
58 void stop(); 59 void stop();
59 60
60 // Can be used to wait for this worker thread to shut down. 61 // Can be used to wait for this worker thread to shut down.
61 // (This is signalled on the main thread, so it's assumed to be waited o n the worker context thread) 62 // (This is signalled on the main thread, so it's assumed to be waited o n the worker context thread)
62 blink::WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); } 63 blink::WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); }
63 64
64 bool isCurrentThread() const; 65 bool isCurrentThread() const;
65 WorkerRunLoop& runLoop() { return m_runLoop; } 66 WorkerRunLoop& runLoop() { return m_runLoop; }
66 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx y; } 67 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx y; }
67 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo rtingProxy; } 68 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo rtingProxy; }
68 69
69 // Number of active worker threads. 70 // Number of active worker threads.
70 static unsigned workerThreadCount(); 71 static unsigned workerThreadCount();
71 static void releaseFastMallocFreeMemoryInAllThreads(); 72 static void releaseFastMallocFreeMemoryInAllThreads();
72 73
73 NotificationClient* getNotificationClient() { return m_notificationClien t; } 74 NotificationClient* getNotificationClient() { return m_notificationClien t; }
74 void setNotificationClient(NotificationClient* client) { m_notificationC lient = client; } 75 void setNotificationClient(NotificationClient* client) { m_notificationC lient = client; }
75 76
77 WorkerSettings* settings() { return m_settings.get(); }
78
76 protected: 79 protected:
77 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtr<Worke rThreadStartupData>); 80 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtr<Worke rSettings>, PassOwnPtr<WorkerThreadStartupData>);
78 81
79 // Factory method for creating a new worker context for the thread. 82 // Factory method for creating a new worker context for the thread.
80 virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtr <WorkerThreadStartupData>) = 0; 83 virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtr <WorkerThreadStartupData>) = 0;
81 84
82 // Executes the event loop for the worker thread. Derived classes can ov erride to perform actions before/after entering the event loop. 85 // Executes the event loop for the worker thread. Derived classes can ov erride to perform actions before/after entering the event loop.
83 virtual void runEventLoop(); 86 virtual void runEventLoop();
84 87
85 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get( ); } 88 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get( ); }
86 89
87 private: 90 private:
88 // Static function executed as the core routine on the new thread. Passe d a pointer to a WorkerThread object. 91 // Static function executed as the core routine on the new thread. Passe d a pointer to a WorkerThread object.
89 static void workerThreadStart(void*); 92 static void workerThreadStart(void*);
90 93
91 void workerThread(); 94 void workerThread();
92 95
93 ThreadIdentifier m_threadID; 96 ThreadIdentifier m_threadID;
94 WorkerRunLoop m_runLoop; 97 WorkerRunLoop m_runLoop;
95 WorkerLoaderProxy& m_workerLoaderProxy; 98 WorkerLoaderProxy& m_workerLoaderProxy;
96 WorkerReportingProxy& m_workerReportingProxy; 99 WorkerReportingProxy& m_workerReportingProxy;
97 100
98 RefPtr<WorkerGlobalScope> m_workerGlobalScope; 101 RefPtr<WorkerGlobalScope> m_workerGlobalScope;
99 Mutex m_threadCreationMutex; 102 Mutex m_threadCreationMutex;
100 103
104 OwnPtr<WorkerSettings> m_settings;
kinuko 2014/02/28 05:23:29 Do we need to keep owning WorkerSettings here? Can
Pan 2014/03/03 09:16:52 done, thanks
105
101 OwnPtr<WorkerThreadStartupData> m_startupData; 106 OwnPtr<WorkerThreadStartupData> m_startupData;
102 107
103 NotificationClient* m_notificationClient; 108 NotificationClient* m_notificationClient;
104 109
105 // Used to signal thread shutdown. 110 // Used to signal thread shutdown.
106 OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; 111 OwnPtr<blink::WebWaitableEvent> m_shutdownEvent;
107 }; 112 };
108 113
109 } // namespace WebCore 114 } // namespace WebCore
110 115
111 #endif // WorkerThread_h 116 #endif // WorkerThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698