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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLParserThread.cpp

Issue 2104913002: Rename threadSafeBind() to crossThreadBind() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_CTCPointer
Patch Set: Rebase Created 4 years, 5 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/html/parser/HTMLParserThread.h" 31 #include "core/html/parser/HTMLParserThread.h"
32 32
33 #include "platform/ThreadSafeFunctional.h" 33 #include "platform/CrossThreadFunctional.h"
34 #include "platform/WaitableEvent.h" 34 #include "platform/WaitableEvent.h"
35 #include "platform/heap/SafePoint.h" 35 #include "platform/heap/SafePoint.h"
36 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
37 #include "public/platform/WebTraceLocation.h" 37 #include "public/platform/WebTraceLocation.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 static HTMLParserThread* s_sharedThread = nullptr; 41 static HTMLParserThread* s_sharedThread = nullptr;
42 42
43 HTMLParserThread::HTMLParserThread() 43 HTMLParserThread::HTMLParserThread()
(...skipping 16 matching lines...) Expand all
60 m_thread->initialize(); 60 m_thread->initialize();
61 } 61 }
62 62
63 void HTMLParserThread::shutdown() 63 void HTMLParserThread::shutdown()
64 { 64 {
65 ASSERT(isMainThread()); 65 ASSERT(isMainThread());
66 ASSERT(s_sharedThread); 66 ASSERT(s_sharedThread);
67 // currentThread will always be non-null in production, but can be null in C hromium unit tests. 67 // currentThread will always be non-null in production, but can be null in C hromium unit tests.
68 if (Platform::current()->currentThread() && s_sharedThread->m_thread) { 68 if (Platform::current()->currentThread() && s_sharedThread->m_thread) {
69 WaitableEvent waitableEvent; 69 WaitableEvent waitableEvent;
70 s_sharedThread->postTask(threadSafeBind(&HTMLParserThread::cleanupHTMLPa rserThread, crossThreadUnretained(s_sharedThread), crossThreadUnretained(&waitab leEvent))); 70 s_sharedThread->postTask(crossThreadBind(&HTMLParserThread::cleanupHTMLP arserThread, crossThreadUnretained(s_sharedThread), crossThreadUnretained(&waita bleEvent)));
71 SafePointScope scope(BlinkGC::HeapPointersOnStack); 71 SafePointScope scope(BlinkGC::HeapPointersOnStack);
72 waitableEvent.wait(); 72 waitableEvent.wait();
73 } 73 }
74 delete s_sharedThread; 74 delete s_sharedThread;
75 s_sharedThread = nullptr; 75 s_sharedThread = nullptr;
76 } 76 }
77 77
78 void HTMLParserThread::cleanupHTMLParserThread(WaitableEvent* waitableEvent) 78 void HTMLParserThread::cleanupHTMLParserThread(WaitableEvent* waitableEvent)
79 { 79 {
80 m_thread->shutdown(); 80 m_thread->shutdown();
81 waitableEvent->signal(); 81 waitableEvent->signal();
82 } 82 }
83 83
84 HTMLParserThread* HTMLParserThread::shared() 84 HTMLParserThread* HTMLParserThread::shared()
85 { 85 {
86 return s_sharedThread; 86 return s_sharedThread;
87 } 87 }
88 88
89 void HTMLParserThread::postTask(std::unique_ptr<CrossThreadClosure> closure) 89 void HTMLParserThread::postTask(std::unique_ptr<CrossThreadClosure> closure)
90 { 90 {
91 ASSERT(isMainThread()); 91 ASSERT(isMainThread());
92 if (!m_thread) { 92 if (!m_thread) {
93 m_thread = WebThreadSupportingGC::create("HTMLParserThread"); 93 m_thread = WebThreadSupportingGC::create("HTMLParserThread");
94 postTask(threadSafeBind(&HTMLParserThread::setupHTMLParserThread, crossT hreadUnretained(this))); 94 postTask(crossThreadBind(&HTMLParserThread::setupHTMLParserThread, cross ThreadUnretained(this)));
95 } 95 }
96 96
97 m_thread->postTask(BLINK_FROM_HERE, std::move(closure)); 97 m_thread->postTask(BLINK_FROM_HERE, std::move(closure));
98 } 98 }
99 99
100 } // namespace blink 100 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698