| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" | 5 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 19 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 20 #include "chromeos/login/login_state.h" | 21 #include "chromeos/login/login_state.h" |
| 21 #include "chromeos/network/device_state.h" | 22 #include "chromeos/network/device_state.h" |
| 22 #include "chromeos/network/network_device_handler.h" | 23 #include "chromeos/network/network_device_handler.h" |
| 23 #include "chromeos/network/network_handler.h" | 24 #include "chromeos/network/network_handler.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 for (const auto& kv_pair : connection_observers_) { | 327 for (const auto& kv_pair : connection_observers_) { |
| 327 WakeOnPacketConnectionObserver* observer = kv_pair.second; | 328 WakeOnPacketConnectionObserver* observer = kv_pair.second; |
| 328 observer->HandleWifiDevicePropertiesReady(); | 329 observer->HandleWifiDevicePropertiesReady(); |
| 329 } | 330 } |
| 330 } | 331 } |
| 331 | 332 |
| 332 void WakeOnWifiManager::OnProfileAdded(Profile* profile) { | 333 void WakeOnWifiManager::OnProfileAdded(Profile* profile) { |
| 333 // add will do nothing if |profile| already exists in |connection_observers_|. | 334 // add will do nothing if |profile| already exists in |connection_observers_|. |
| 334 auto result = connection_observers_.add( | 335 auto result = connection_observers_.add( |
| 335 profile, | 336 profile, |
| 336 make_scoped_ptr(new WakeOnWifiManager::WakeOnPacketConnectionObserver( | 337 base::WrapUnique(new WakeOnWifiManager::WakeOnPacketConnectionObserver( |
| 337 profile, wifi_properties_received_))); | 338 profile, wifi_properties_received_))); |
| 338 | 339 |
| 339 if (result.second) { | 340 if (result.second) { |
| 340 // This is a profile we haven't seen before. | 341 // This is a profile we haven't seen before. |
| 341 gcm::GCMProfileServiceFactory::GetForProfile(profile) | 342 gcm::GCMProfileServiceFactory::GetForProfile(profile) |
| 342 ->driver() | 343 ->driver() |
| 343 ->WakeFromSuspendForHeartbeat( | 344 ->WakeFromSuspendForHeartbeat( |
| 344 IsWakeOnPacketEnabled(current_feature_)); | 345 IsWakeOnPacketEnabled(current_feature_)); |
| 345 } | 346 } |
| 346 } | 347 } |
| 347 | 348 |
| 348 void WakeOnWifiManager::OnProfileDestroyed(Profile* profile) { | 349 void WakeOnWifiManager::OnProfileDestroyed(Profile* profile) { |
| 349 connection_observers_.erase(profile); | 350 connection_observers_.erase(profile); |
| 350 } | 351 } |
| 351 | 352 |
| 352 } // namespace chromeos | 353 } // namespace chromeos |
| OLD | NEW |