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

Unified Diff: chrome/browser/devtools/port_forwarding_controller.cc

Issue 26568004: Introduced AndroidDeviceProvider to simplify testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added files to changelist. 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
Index: chrome/browser/devtools/port_forwarding_controller.cc
diff --git a/chrome/browser/devtools/port_forwarding_controller.cc b/chrome/browser/devtools/port_forwarding_controller.cc
index 3eaf09539609634833e7ab3910d427a00961b725..d65612e687b8e86bbec85415eb9754de84e8707e 100644
--- a/chrome/browser/devtools/port_forwarding_controller.cc
+++ b/chrome/browser/devtools/port_forwarding_controller.cc
@@ -272,9 +272,9 @@ class PortForwardingController::Connection
content::BrowserThread::DeleteOnUIThread> {
public:
Connection(Registry* registry,
- scoped_refptr<DevToolsAdbBridge::AndroidDevice> device,
+ scoped_refptr<AndroidDevice> device,
const std::string& socket,
- scoped_refptr<DevToolsAdbBridge> bridge,
+ scoped_refptr<RefCountedAdbThread> adb_thread,
PrefService* pref_service);
const PortStatusMap& GetPortStatusMap();
@@ -317,8 +317,8 @@ class PortForwardingController::Connection
virtual bool ProcessIncomingMessage(const std::string& message) OVERRIDE;
PortForwardingController::Registry* registry_;
- scoped_refptr<DevToolsAdbBridge::AndroidDevice> device_;
- scoped_refptr<DevToolsAdbBridge> bridge_;
+ scoped_refptr<AndroidDevice> device_;
+ scoped_refptr<RefCountedAdbThread> adb_thread_;
PrefChangeRegistrar pref_change_registrar_;
scoped_refptr<AdbWebSocket> web_socket_;
int command_id_;
@@ -332,20 +332,20 @@ class PortForwardingController::Connection
PortForwardingController::Connection::Connection(
Registry* registry,
- scoped_refptr<DevToolsAdbBridge::AndroidDevice> device,
+ scoped_refptr<AndroidDevice> device,
const std::string& socket,
- scoped_refptr<DevToolsAdbBridge> bridge,
+ scoped_refptr<RefCountedAdbThread> adb_thread,
PrefService* pref_service)
: registry_(registry),
device_(device),
- bridge_(bridge),
+ adb_thread_(adb_thread),
command_id_(0) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
pref_change_registrar_.Init(pref_service);
(*registry_)[device_->serial()] = this;
web_socket_ = new AdbWebSocket(
device, socket, kDevToolsRemoteBrowserTarget,
- bridge_->GetAdbMessageLoop(), this);
+ adb_thread_->message_loop(), this);
AddRef(); // Balanced in OnSocketClosed();
}
@@ -382,7 +382,7 @@ void PortForwardingController::Connection::OnPrefsChange() {
}
}
- bridge_->GetAdbMessageLoop()->PostTask(
+ adb_thread_->message_loop()->PostTask(
FROM_HERE,
base::Bind(&Connection::ChangeForwardingMap,
this, new_forwarding_map));
@@ -390,7 +390,7 @@ void PortForwardingController::Connection::OnPrefsChange() {
void PortForwardingController::Connection::ChangeForwardingMap(
ForwardingMap new_forwarding_map) {
- DCHECK_EQ(base::MessageLoop::current(), bridge_->GetAdbMessageLoop());
+ DCHECK_EQ(base::MessageLoop::current(), adb_thread_->message_loop());
SerializeChanges(kTetheringUnbind, new_forwarding_map, forwarding_map_);
SerializeChanges(kTetheringBind, forwarding_map_, new_forwarding_map);
@@ -542,7 +542,7 @@ void PortForwardingController::Connection::OnSocketClosed(
bool PortForwardingController::Connection::ProcessIncomingMessage(
const std::string& message) {
- DCHECK_EQ(base::MessageLoop::current(), bridge_->GetAdbMessageLoop());
+ DCHECK_EQ(base::MessageLoop::current(), adb_thread_->message_loop());
if (ProcessResponse(message))
return true;
@@ -578,10 +578,8 @@ bool PortForwardingController::Connection::ProcessIncomingMessage(
return true;
}
-PortForwardingController::PortForwardingController(
- scoped_refptr<DevToolsAdbBridge> bridge,
- PrefService* pref_service)
- : bridge_(bridge),
+PortForwardingController::PortForwardingController(PrefService* pref_service)
+ : adb_thread_(RefCountedAdbThread::GetInstance()),
pref_service_(pref_service) {
}
@@ -603,7 +601,7 @@ PortForwardingController::UpdateDeviceList(
if (!socket.empty() || device->serial().empty()) {
// Will delete itself when disconnected.
new Connection(
- &registry_, device->device(), socket, bridge_, pref_service_);
+ &registry_, device->device(), socket, adb_thread_, pref_service_);
}
} else {
status[device->serial()] = (*rit).second->GetPortStatusMap();
@@ -636,7 +634,5 @@ BrowserContextKeyedService*
PortForwardingController::Factory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
- return new PortForwardingController(
- DevToolsAdbBridge::Factory::GetForProfile(profile),
- profile->GetPrefs());
+ return new PortForwardingController(profile->GetPrefs());
}

Powered by Google App Engine
This is Rietveld 408576698