| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/services/gcm/chromeos_gcm_connection_observer.h" | |
| 6 | |
| 7 #include "base/callback.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 10 #include "chromeos/dbus/shill_manager_client.h" | |
| 11 | |
| 12 namespace gcm { | |
| 13 | |
| 14 ChromeOSGCMConnectionObserver::ChromeOSGCMConnectionObserver() { | |
| 15 } | |
| 16 | |
| 17 ChromeOSGCMConnectionObserver::~ChromeOSGCMConnectionObserver() { | |
| 18 } | |
| 19 | |
| 20 // static | |
| 21 void ChromeOSGCMConnectionObserver::ErrorCallback( | |
| 22 const std::string& error_name, | |
| 23 const std::string& error) { | |
| 24 LOG(ERROR) << "GCM D-Bus method error " << error_name << ": " << error; | |
| 25 } | |
| 26 | |
| 27 void ChromeOSGCMConnectionObserver::OnConnected( | |
| 28 const net::IPEndPoint& ip_endpoint) { | |
| 29 ip_endpoint_ = ip_endpoint; | |
| 30 chromeos::DBusThreadManager::Get()-> | |
| 31 GetShillManagerClient()-> | |
| 32 AddWakeOnPacketConnection( | |
| 33 ip_endpoint, | |
| 34 base::Bind(&base::DoNothing), | |
| 35 base::Bind(&ChromeOSGCMConnectionObserver::ErrorCallback)); | |
| 36 } | |
| 37 | |
| 38 void ChromeOSGCMConnectionObserver::OnDisconnected() { | |
| 39 chromeos::DBusThreadManager::Get()-> | |
| 40 GetShillManagerClient()-> | |
| 41 RemoveWakeOnPacketConnection( | |
| 42 ip_endpoint_, | |
| 43 base::Bind(&base::DoNothing), | |
| 44 base::Bind(&ChromeOSGCMConnectionObserver::ErrorCallback)); | |
| 45 } | |
| 46 | |
| 47 } // namespace gcm | |
| OLD | NEW |