Chromium Code Reviews| 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); |
| -} |