| OLD | NEW |
| (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 #include "sky/engine/core/html/parser/HTMLParserThread.h" | |
| 6 | |
| 7 #include "base/threading/thread.h" | |
| 8 #include "sky/engine/wtf/Assertions.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 static base::Thread* s_thread = 0; | |
| 13 static base::SingleThreadTaskRunner* s_taskRunner = 0; | |
| 14 | |
| 15 void HTMLParserThread::start() | |
| 16 { | |
| 17 ASSERT(!s_thread); | |
| 18 s_thread = new base::Thread("HTMLParserThread"); | |
| 19 s_thread->Start(); | |
| 20 s_thread->task_runner().swap(&s_taskRunner); | |
| 21 } | |
| 22 | |
| 23 void HTMLParserThread::stop() | |
| 24 { | |
| 25 ASSERT(s_thread); | |
| 26 base::Thread* thread = s_thread; | |
| 27 s_thread = 0; | |
| 28 | |
| 29 scoped_refptr<base::SingleThreadTaskRunner> taskRunner; | |
| 30 taskRunner.swap(&s_taskRunner); | |
| 31 | |
| 32 delete thread; | |
| 33 taskRunner = nullptr; | |
| 34 } | |
| 35 | |
| 36 base::SingleThreadTaskRunner* HTMLParserThread::taskRunner() | |
| 37 { | |
| 38 ASSERT(s_taskRunner); | |
| 39 return s_taskRunner; | |
| 40 } | |
| 41 | |
| 42 } // namespace blink | |
| OLD | NEW |