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

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

Issue 500373004: DevTools: Make port forwarding part of DevToolsAndroidBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/device/port_forwarding_controller.cc
diff --git a/chrome/browser/devtools/device/port_forwarding_controller.cc b/chrome/browser/devtools/device/port_forwarding_controller.cc
index df610d199221fb35357ad699cf2d8bae1ccd4be0..786b453b5e267a45fff87c19b3e408b1de1ad8dd 100644
--- a/chrome/browser/devtools/device/port_forwarding_controller.cc
+++ b/chrome/browser/devtools/device/port_forwarding_controller.cc
@@ -541,27 +541,10 @@ PortForwardingController::PortForwardingController(Profile* profile)
OnPrefsChange();
}
-
PortForwardingController::~PortForwardingController() {}
-void PortForwardingController::Shutdown() {
- // Existing connection will not be shut down. This might be confusing for
- // some users, but the opposite is more confusing.
- StopListening();
-}
-
-void PortForwardingController::AddListener(Listener* listener) {
- listeners_.push_back(listener);
-}
-
-void PortForwardingController::RemoveListener(Listener* listener) {
- Listeners::iterator it =
- std::find(listeners_.begin(), listeners_.end(), listener);
- DCHECK(it != listeners_.end());
- listeners_.erase(it);
-}
-
-void PortForwardingController::DeviceListChanged(
+PortForwardingController::DevicesStatus
+PortForwardingController::DeviceListChanged(
const DevToolsAndroidBridge::RemoteDevices& devices) {
DevicesStatus status;
@@ -582,7 +565,7 @@ void PortForwardingController::DeviceListChanged(
}
}
- NotifyListeners(status);
+ return status;
}
void PortForwardingController::OnPrefsChange() {
@@ -602,36 +585,14 @@ void PortForwardingController::OnPrefsChange() {
}
if (!forwarding_map_.empty()) {
- StartListening();
+ listening_ = true;
dgozman 2014/08/27 08:08:34 I don't see where |listening_| is used.
vkuzkokov 2014/09/01 16:13:41 Good point.
UpdateConnections();
} else {
- StopListening();
+ listening_ = false;
ShutdownConnections();
- NotifyListeners(DevicesStatus());
}
}
-void PortForwardingController::StartListening() {
- if (listening_)
- return;
- listening_ = true;
- DevToolsAndroidBridge* android_bridge =
- DevToolsAndroidBridge::Factory::GetForProfile(profile_);
- if (android_bridge)
- android_bridge->AddDeviceListListener(this);
-
-}
-
-void PortForwardingController::StopListening() {
- if (!listening_)
- return;
- listening_ = false;
- DevToolsAndroidBridge* android_bridge =
- DevToolsAndroidBridge::Factory::GetForProfile(profile_);
- if (android_bridge)
- android_bridge->RemoveDeviceListListener(this);
-}
-
void PortForwardingController::UpdateConnections() {
for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it)
it->second->UpdateForwardingMap(forwarding_map_);
@@ -642,36 +603,3 @@ void PortForwardingController::ShutdownConnections() {
it->second->Shutdown();
registry_.clear();
}
-
-void PortForwardingController::NotifyListeners(
- const DevicesStatus& status) const {
- Listeners copy(listeners_); // Iterate over copy.
- for (Listeners::const_iterator it = copy.begin(); it != copy.end(); ++it)
- (*it)->PortStatusChanged(status);
-}
-
-// static
-PortForwardingController::Factory*
-PortForwardingController::Factory::GetInstance() {
- return Singleton<PortForwardingController::Factory>::get();
-}
-
-// static
-PortForwardingController* PortForwardingController::Factory::GetForProfile(
- Profile* profile) {
- return static_cast<PortForwardingController*>(GetInstance()->
- GetServiceForBrowserContext(profile, true));
-}
-
-PortForwardingController::Factory::Factory()
- : BrowserContextKeyedServiceFactory(
- "PortForwardingController",
- BrowserContextDependencyManager::GetInstance()) {}
-
-PortForwardingController::Factory::~Factory() {}
-
-KeyedService* PortForwardingController::Factory::BuildServiceInstanceFor(
- content::BrowserContext* context) const {
- Profile* profile = Profile::FromBrowserContext(context);
- return new PortForwardingController(profile);
-}

Powered by Google App Engine
This is Rietveld 408576698