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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/refcounted_adb_thread.cc
diff --git a/chrome/browser/devtools/refcounted_adb_thread.cc b/chrome/browser/devtools/refcounted_adb_thread.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bc905329a6b5468e288c8076cdcf202e3b2972f7
--- /dev/null
+++ b/chrome/browser/devtools/refcounted_adb_thread.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/devtools/refcounted_adb_thread.h"
+
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+const char kDevToolsAdbBridgeThreadName[] = "Chrome_DevToolsADBThread";
+
+RefCountedAdbThread* RefCountedAdbThread::instance_ = NULL;
+
+// static
+scoped_refptr<RefCountedAdbThread> RefCountedAdbThread::GetInstance() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!instance_)
+ new RefCountedAdbThread();
+ return instance_;
+}
+
+RefCountedAdbThread::RefCountedAdbThread() {
+ instance_ = this;
+ thread_ = new base::Thread(kDevToolsAdbBridgeThreadName);
+ base::Thread::Options options;
+ options.message_loop_type = base::MessageLoop::TYPE_IO;
+ if (!thread_->StartWithOptions(options)) {
+ delete thread_;
+ thread_ = NULL;
+ }
+}
+
+base::MessageLoop* RefCountedAdbThread::message_loop() {
+ return thread_ ? thread_->message_loop() : NULL;
+}
+
+// static
+void RefCountedAdbThread::StopThread(base::Thread* thread) {
+ thread->Stop();
+}
+
+RefCountedAdbThread::~RefCountedAdbThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ instance_ = NULL;
+ if (!thread_)
+ return;
+ // Shut down thread on FILE thread to join into IO.
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&RefCountedAdbThread::StopThread, thread_));
+}
« 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