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

Side by Side Diff: Source/platform/WebThreadRunner.h

Issue 469683002: Implement WebThreadSupportingGC, which wraps a WebThread attached to Oilpan's GC (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WebThreadRunner_h
6 #define WebThreadRunner_h
7
8 #include "platform/heap/glue/MessageLoopInterruptor.h"
9 #include "platform/heap/glue/PendingGCRunner.h"
10 #include "public/platform/Platform.h"
11 #include "public/platform/WebThread.h"
12 #include "wtf/Noncopyable.h"
13 #include "wtf/OwnPtr.h"
14 #include "wtf/PassOwnPtr.h"
15
16 namespace blink {
17
18 class WebThreadRunner {
Mads Ager (chromium) 2014/08/13 07:26:20 WebThreadSupportingGC? Should we add a comment al
haraken 2014/08/13 08:03:09 Renamed to WebThreadSupportingGC & added the comme
19 WTF_MAKE_NONCOPYABLE(WebThreadRunner);
20 public:
21 static PassOwnPtr<WebThreadRunner> create(const char*);
22
23 void postTask(WebThread::Task* task)
24 {
25 m_thread->postTask(task);
26 }
27
28 void postDelayedTask(WebThread::Task* task, long long delayMs)
29 {
30 m_thread->postDelayedTask(task, delayMs);
31 }
32
33 bool isCurrentThread() const
34 {
35 return m_thread->isCurrentThread();
36 }
37
38 void addTaskObserver(WebThread::TaskObserver* observer)
39 {
40 m_thread->addTaskObserver(observer);
41 }
42
43 void removeTaskObserver(WebThread::TaskObserver* observer)
44 {
45 m_thread->removeTaskObserver(observer);
46 }
47
48 void enterRunLoop()
49 {
50 m_thread->enterRunLoop();
51 }
52
53 void exitRunLoop()
54 {
55 m_thread->exitRunLoop();
56 }
57
58 void attachGC();
59 void detachGC();
60
61 WebThread& platformThread() const
62 {
63 ASSERT(m_thread);
64 return *m_thread;
65 }
66
67 private:
68 explicit WebThreadRunner(const char*);
69
70 OwnPtr<PendingGCRunner> m_pendingGCRunner;
71 OwnPtr<MessageLoopInterruptor> m_messageLoopInterruptor;
72
73 // FIXME: This has to be last because of crbug.com/401397.
74 // A WorkerThread might get deleted before it had a chance to properly
75 // shut down. By deleting the WebThread first, we can guarantee that
76 // no pending tasks on the thread might want to access any of the other
77 // members during the WorkerThread's destruction.
78 OwnPtr<WebThread> m_thread;
79 };
80
81 }
82
83 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698