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

Side by Side Diff: Source/platform/WebThreadSupportingGC.cpp

Issue 474683003: Not for review - Rebase of crrev.com/62833003 Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 6 years, 1 month 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/platform/WebThreadSupportingGC.h ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/WebThreadSupportingGC.h" 6 #include "platform/WebThreadSupportingGC.h"
7 #include "WebThreadOwnPtr.h"
7 8
8 namespace blink { 9 namespace blink {
9 10
10 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::create(const char* name ) 11 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::create(const char* name )
11 { 12 {
12 return adoptPtr(new WebThreadSupportingGC(name)); 13 return adoptPtr(new WebThreadSupportingGC(name));
13 } 14 }
14 15
15 WebThreadSupportingGC::WebThreadSupportingGC(const char* name) 16 WebThreadSupportingGC::WebThreadSupportingGC(const char* name)
16 : m_thread(adoptPtr(blink::Platform::current()->createThread(name))) 17 : m_thread(new WebThreadOwnPtr(blink::Platform::current()->createThread(name )))
17 { 18 {
18 } 19 }
19 20
20 WebThreadSupportingGC::~WebThreadSupportingGC() 21 WebThreadSupportingGC::~WebThreadSupportingGC()
21 { 22 {
22 if (ThreadState::current()) { 23 if (ThreadState::current()) {
23 // WebThread's destructor blocks until all the tasks are processed. 24 // WebThread's destructor blocks until all the tasks are processed.
24 ThreadState::SafePointScope scope(ThreadState::HeapPointersOnStack); 25 ThreadState::SafePointScope scope(ThreadState::HeapPointersOnStack);
25 m_thread.clear(); 26 m_thread->clear();
26 } 27 }
27 } 28 }
28 29
29 void WebThreadSupportingGC::attachGC() 30 void WebThreadSupportingGC::attachGC()
30 { 31 {
31 m_pendingGCRunner = adoptPtr(new PendingGCRunner); 32 m_pendingGCRunner = adoptPtr(new PendingGCRunner);
32 m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(&platformThre ad())); 33 m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(&platformThre ad()));
33 platformThread().addTaskObserver(m_pendingGCRunner.get()); 34 platformThread().addTaskObserver(m_pendingGCRunner.get());
34 ThreadState::attach(); 35 ThreadState::attach();
35 ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get()); 36 ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get());
36 } 37 }
37 38
38 void WebThreadSupportingGC::detachGC() 39 void WebThreadSupportingGC::detachGC()
39 { 40 {
40 ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get()); 41 ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get());
41 ThreadState::detach(); 42 ThreadState::detach();
42 platformThread().removeTaskObserver(m_pendingGCRunner.get()); 43 platformThread().removeTaskObserver(m_pendingGCRunner.get());
43 m_pendingGCRunner = nullptr; 44 m_pendingGCRunner = nullptr;
44 m_messageLoopInterruptor = nullptr; 45 m_messageLoopInterruptor = nullptr;
45 } 46 }
46 47
47 } // namespace blink 48 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/WebThreadSupportingGC.h ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698