OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/notifier/push_client_channel.h" | 5 #include "sync/notifier/push_client_channel.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "google/cacheinvalidation/v2/client_gateway.pb.h" | 8 #include "google/cacheinvalidation/v2/client_gateway.pb.h" |
9 #include "jingle/notifier/listener/push_client.h" | 9 #include "jingle/notifier/listener/push_client.h" |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 invalidation::NetworkStatusCallback* network_status_receiver) { | 55 invalidation::NetworkStatusCallback* network_status_receiver) { |
56 network_status_receiver->Run(notifications_enabled_); | 56 network_status_receiver->Run(notifications_enabled_); |
57 network_status_receivers_.push_back(network_status_receiver); | 57 network_status_receivers_.push_back(network_status_receiver); |
58 } | 58 } |
59 | 59 |
60 void PushClientChannel::SetSystemResources( | 60 void PushClientChannel::SetSystemResources( |
61 invalidation::SystemResources* resources) { | 61 invalidation::SystemResources* resources) { |
62 // Do nothing. | 62 // Do nothing. |
63 } | 63 } |
64 | 64 |
65 void PushClientChannel::OnNotificationStateChange( | 65 void PushClientChannel::OnNotificationsEnabled() { |
66 bool notifications_enabled) { | |
67 for (NetworkStatusReceiverList::const_iterator it = | 66 for (NetworkStatusReceiverList::const_iterator it = |
68 network_status_receivers_.begin(); | 67 network_status_receivers_.begin(); |
69 it != network_status_receivers_.end(); ++it) { | 68 it != network_status_receivers_.end(); ++it) { |
70 (*it)->Run(notifications_enabled); | 69 (*it)->Run(true); |
71 } | 70 } |
72 } | 71 } |
73 | 72 |
| 73 void PushClientChannel::OnNotificationsDisabled( |
| 74 notifier::NotificationsDisabledReason reason) { |
| 75 for (NetworkStatusReceiverList::const_iterator it = |
| 76 network_status_receivers_.begin(); |
| 77 it != network_status_receivers_.end(); ++it) { |
| 78 (*it)->Run(false); |
| 79 } |
| 80 } |
| 81 |
74 void PushClientChannel::OnIncomingNotification( | 82 void PushClientChannel::OnIncomingNotification( |
75 const notifier::Notification& notification) { | 83 const notifier::Notification& notification) { |
76 if (!incoming_receiver_.get()) { | 84 if (!incoming_receiver_.get()) { |
77 DLOG(ERROR) << "No receiver for incoming notification"; | 85 DLOG(ERROR) << "No receiver for incoming notification"; |
78 return; | 86 return; |
79 } | 87 } |
80 std::string message; | 88 std::string message; |
81 if (!DecodeMessage(notification, | 89 if (!DecodeMessage(notification, |
82 &message, &service_context_, &scheduling_hash_)) { | 90 &message, &service_context_, &scheduling_hash_)) { |
83 DLOG(ERROR) << "Could not parse ClientGatewayMessage from: " | 91 DLOG(ERROR) << "Could not parse ClientGatewayMessage from: " |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if (envelope.has_service_context()) { | 150 if (envelope.has_service_context()) { |
143 *service_context = envelope.service_context(); | 151 *service_context = envelope.service_context(); |
144 } | 152 } |
145 if (envelope.has_rpc_scheduling_hash()) { | 153 if (envelope.has_rpc_scheduling_hash()) { |
146 *scheduling_hash = envelope.rpc_scheduling_hash(); | 154 *scheduling_hash = envelope.rpc_scheduling_hash(); |
147 } | 155 } |
148 return true; | 156 return true; |
149 } | 157 } |
150 | 158 |
151 } // namespace sync_notifier | 159 } // namespace sync_notifier |
OLD | NEW |