1 // Copyright 2013 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.
5 #include "chrome/browser/devtools/refcounted_adb_thread.h"
7 #include "content/public/browser/browser_thread.h"
9 using content::BrowserThread
;
11 const char kDevToolsAdbBridgeThreadName
[] = "Chrome_DevToolsADBThread";
13 RefCountedAdbThread
* RefCountedAdbThread::instance_
= NULL
;
16 scoped_refptr
<RefCountedAdbThread
> RefCountedAdbThread::GetInstance() {
17 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
19 new RefCountedAdbThread();
23 RefCountedAdbThread::RefCountedAdbThread() {
25 thread_
= new base::Thread(kDevToolsAdbBridgeThreadName
);
26 base::Thread::Options options
;
27 options
.message_loop_type
= base::MessageLoop::TYPE_IO
;
28 if (!thread_
->StartWithOptions(options
)) {
34 base::MessageLoop
* RefCountedAdbThread::message_loop() {
35 return thread_
? thread_
->message_loop() : NULL
;
39 void RefCountedAdbThread::StopThread(base::Thread
* thread
) {
43 RefCountedAdbThread::~RefCountedAdbThread() {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
48 // Shut down thread on FILE thread to join into IO.
49 BrowserThread::PostTask(
50 BrowserThread::FILE, FROM_HERE
,
51 base::Bind(&RefCountedAdbThread::StopThread
, thread_
));