| 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 "components/invalidation/push_client_channel.h" | 5 #include "components/invalidation/push_client_channel.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "components/invalidation/notifier_reason_util.h" | 8 #include "components/invalidation/notifier_reason_util.h" |
| 9 #include "google/cacheinvalidation/client_gateway.pb.h" | 9 #include "google/cacheinvalidation/client_gateway.pb.h" |
| 10 #include "google/cacheinvalidation/types.pb.h" | 10 #include "google/cacheinvalidation/types.pb.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 recipient.to = kBotJid; | 63 recipient.to = kBotJid; |
| 64 notifier::Notification notification; | 64 notifier::Notification notification; |
| 65 notification.channel = kChannelName; | 65 notification.channel = kChannelName; |
| 66 notification.recipients.push_back(recipient); | 66 notification.recipients.push_back(recipient); |
| 67 notification.data = encoded_message; | 67 notification.data = encoded_message; |
| 68 push_client_->SendNotification(notification); | 68 push_client_->SendNotification(notification); |
| 69 sent_messages_count_++; | 69 sent_messages_count_++; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void PushClientChannel::OnNotificationsEnabled() { | 72 void PushClientChannel::OnNotificationsEnabled() { |
| 73 NotifyStateChange(INVALIDATIONS_ENABLED); | 73 NotifyNetworkStatusChange(true); |
| 74 NotifyChannelStateChange(INVALIDATIONS_ENABLED); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void PushClientChannel::OnNotificationsDisabled( | 77 void PushClientChannel::OnNotificationsDisabled( |
| 77 notifier::NotificationsDisabledReason reason) { | 78 notifier::NotificationsDisabledReason reason) { |
| 78 NotifyStateChange(FromNotifierReason(reason)); | 79 NotifyNetworkStatusChange(false); |
| 80 NotifyChannelStateChange(FromNotifierReason(reason)); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void PushClientChannel::OnIncomingNotification( | 83 void PushClientChannel::OnIncomingNotification( |
| 82 const notifier::Notification& notification) { | 84 const notifier::Notification& notification) { |
| 83 std::string message; | 85 std::string message; |
| 84 std::string service_context; | 86 std::string service_context; |
| 85 int64 scheduling_hash; | 87 int64 scheduling_hash; |
| 86 if (!DecodeMessage( | 88 if (!DecodeMessage( |
| 87 notification.data, &message, &service_context, &scheduling_hash)) { | 89 notification.data, &message, &service_context, &scheduling_hash)) { |
| 88 DLOG(ERROR) << "Could not parse ClientGatewayMessage"; | 90 DLOG(ERROR) << "Could not parse ClientGatewayMessage"; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 scoped_ptr<base::DictionaryValue> PushClientChannel::CollectDebugData() const { | 155 scoped_ptr<base::DictionaryValue> PushClientChannel::CollectDebugData() const { |
| 154 scoped_ptr<base::DictionaryValue> status(new base::DictionaryValue); | 156 scoped_ptr<base::DictionaryValue> status(new base::DictionaryValue); |
| 155 status->SetString("PushClientChannel.NetworkChannel", "Push Client"); | 157 status->SetString("PushClientChannel.NetworkChannel", "Push Client"); |
| 156 status->SetInteger("PushClientChannel.SentMessages", sent_messages_count_); | 158 status->SetInteger("PushClientChannel.SentMessages", sent_messages_count_); |
| 157 status->SetInteger("PushClientChannel.ReceivedMessages", | 159 status->SetInteger("PushClientChannel.ReceivedMessages", |
| 158 SyncNetworkChannel::GetReceivedMessagesCount()); | 160 SyncNetworkChannel::GetReceivedMessagesCount()); |
| 159 return status.Pass(); | 161 return status.Pass(); |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace syncer | 164 } // namespace syncer |
| OLD | NEW |