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

Side by Side Diff: components/gcm_driver/default_gcm_app_handler.cc

Issue 409883006: GCM: D-Bus methods for wake-on-packet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: GCM: D-Bus methods for wake-on-packet 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 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 "components/gcm_driver/default_gcm_app_handler.h" 5 #include "components/gcm_driver/default_gcm_app_handler.h"
6 6
7 #include "base/callback.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "net/base/ip_endpoint.h" 9 #include "net/base/ip_endpoint.h"
9 10
10 namespace gcm { 11 namespace gcm {
11 12
12 DefaultGCMAppHandler::DefaultGCMAppHandler() { 13 DefaultGCMAppHandler::DefaultGCMAppHandler() {
13 } 14 }
14 15
15 DefaultGCMAppHandler::~DefaultGCMAppHandler() { 16 DefaultGCMAppHandler::~DefaultGCMAppHandler() {
16 } 17 }
(...skipping 13 matching lines...) Expand all
30 << app_id; 31 << app_id;
31 } 32 }
32 33
33 void DefaultGCMAppHandler::OnSendError( 34 void DefaultGCMAppHandler::OnSendError(
34 const std::string& app_id, 35 const std::string& app_id,
35 const GCMClient::SendErrorDetails& send_error_details) { 36 const GCMClient::SendErrorDetails& send_error_details) {
36 LOG(ERROR) << "No app handler is found to route send error message for " 37 LOG(ERROR) << "No app handler is found to route send error message for "
37 << app_id; 38 << app_id;
38 } 39 }
39 40
41 // static
42 void DefaultGCMAppHandler::NullCallback(const std::string& result) {
43 }
44
45 // static
46 void DefaultGCMAppHandler::ErrorCallback(
47 const std::string& error_name,
48 const std::string& error) {
49 LOG(ERROR) << "GCM D-Bus method error " << error_name << ": " << error;
50 }
51
40 void DefaultGCMAppHandler::OnConnected(const net::IPEndPoint& ip_endpoint) { 52 void DefaultGCMAppHandler::OnConnected(const net::IPEndPoint& ip_endpoint) {
41 // TODO(semenzato): update CrOS NIC state. 53 const std::string ip_endpoint_string = ip_endpoint.ToString();
42 DVLOG(1) << "GCM connected to " << ip_endpoint.ToString(); 54 if (on_connected_cb_)
55 on_connected_cb_(ip_endpoint);
43 } 56 }
44 57
45 void DefaultGCMAppHandler::OnDisconnected() { 58 void DefaultGCMAppHandler::OnDisconnected() {
46 // TODO(semenzato): update CrOS NIC state. 59 if (on_disconnected_cb_)
47 DVLOG(1) << "GCM disconnected"; 60 on_disconnected_cb_();
61 }
62
63 // static
64 void DefaultGCMAppHandler::RegisterConnectionCallbacks(
65 void (*on_connected_cb)(const net::IPEndPoint& ip_endpoint),
66 void (*on_disconnected_cb)()) {
67 on_connected_cb_ = on_connected_cb;
68 on_disconnected_cb_ = on_disconnected_cb;
48 } 69 }
49 70
50 } // namespace gcm 71 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698