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

Side by Side Diff: chrome/browser/devtools/refcounted_adb_thread.cc

Issue 26568004: Introduced AndroidDeviceProvider to simplify testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unused constants, thus fixed compile errors. Created 7 years, 2 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
« no previous file with comments | « chrome/browser/devtools/refcounted_adb_thread.h ('k') | chrome/browser/ui/webui/inspect_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #include "chrome/browser/devtools/refcounted_adb_thread.h"
6
7 #include "content/public/browser/browser_thread.h"
8
9 using content::BrowserThread;
10
11 const char kDevToolsAdbBridgeThreadName[] = "Chrome_DevToolsADBThread";
12
13 RefCountedAdbThread* RefCountedAdbThread::instance_ = NULL;
14
15 // static
16 scoped_refptr<RefCountedAdbThread> RefCountedAdbThread::GetInstance() {
17 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
18 if (!instance_)
19 new RefCountedAdbThread();
20 return instance_;
21 }
22
23 RefCountedAdbThread::RefCountedAdbThread() {
24 instance_ = this;
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)) {
29 delete thread_;
30 thread_ = NULL;
31 }
32 }
33
34 base::MessageLoop* RefCountedAdbThread::message_loop() {
35 return thread_ ? thread_->message_loop() : NULL;
36 }
37
38 // static
39 void RefCountedAdbThread::StopThread(base::Thread* thread) {
40 thread->Stop();
41 }
42
43 RefCountedAdbThread::~RefCountedAdbThread() {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45 instance_ = NULL;
46 if (!thread_)
47 return;
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_));
52 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/refcounted_adb_thread.h ('k') | chrome/browser/ui/webui/inspect_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698