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

Side by Side Diff: components/invalidation/impl/push_client_channel.cc

Issue 1548113002: Switch to standard integer types in components/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 4 years, 12 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
OLDNEW
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/impl/push_client_channel.h" 5 #include "components/invalidation/impl/push_client_channel.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "build/build_config.h"
8 #include "components/invalidation/impl/notifier_reason_util.h" 9 #include "components/invalidation/impl/notifier_reason_util.h"
9 #include "google/cacheinvalidation/client_gateway.pb.h" 10 #include "google/cacheinvalidation/client_gateway.pb.h"
10 #include "google/cacheinvalidation/types.pb.h" 11 #include "google/cacheinvalidation/types.pb.h"
11 #include "jingle/notifier/listener/push_client.h" 12 #include "jingle/notifier/listener/push_client.h"
12 13
13 namespace syncer { 14 namespace syncer {
14 15
15 namespace { 16 namespace {
16 17
17 const char kBotJid[] = "tango@bot.talk.google.com"; 18 const char kBotJid[] = "tango@bot.talk.google.com";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void PushClientChannel::OnNotificationsDisabled( 78 void PushClientChannel::OnNotificationsDisabled(
78 notifier::NotificationsDisabledReason reason) { 79 notifier::NotificationsDisabledReason reason) {
79 NotifyNetworkStatusChange(false); 80 NotifyNetworkStatusChange(false);
80 NotifyChannelStateChange(FromNotifierReason(reason)); 81 NotifyChannelStateChange(FromNotifierReason(reason));
81 } 82 }
82 83
83 void PushClientChannel::OnIncomingNotification( 84 void PushClientChannel::OnIncomingNotification(
84 const notifier::Notification& notification) { 85 const notifier::Notification& notification) {
85 std::string message; 86 std::string message;
86 std::string service_context; 87 std::string service_context;
87 int64 scheduling_hash; 88 int64_t scheduling_hash;
88 if (!DecodeMessage( 89 if (!DecodeMessage(
89 notification.data, &message, &service_context, &scheduling_hash)) { 90 notification.data, &message, &service_context, &scheduling_hash)) {
90 DLOG(ERROR) << "Could not parse ClientGatewayMessage"; 91 DLOG(ERROR) << "Could not parse ClientGatewayMessage";
91 return; 92 return;
92 } 93 }
93 if (DeliverIncomingMessage(message)) { 94 if (DeliverIncomingMessage(message)) {
94 service_context_ = service_context; 95 service_context_ = service_context;
95 scheduling_hash_ = scheduling_hash; 96 scheduling_hash_ = scheduling_hash;
96 } 97 }
97 } 98 }
98 99
99 const std::string& PushClientChannel::GetServiceContextForTest() const { 100 const std::string& PushClientChannel::GetServiceContextForTest() const {
100 return service_context_; 101 return service_context_;
101 } 102 }
102 103
103 int64 PushClientChannel::GetSchedulingHashForTest() const { 104 int64_t PushClientChannel::GetSchedulingHashForTest() const {
104 return scheduling_hash_; 105 return scheduling_hash_;
105 } 106 }
106 107
107 std::string PushClientChannel::EncodeMessageForTest( 108 std::string PushClientChannel::EncodeMessageForTest(
108 const std::string& message, 109 const std::string& message,
109 const std::string& service_context, 110 const std::string& service_context,
110 int64 scheduling_hash) { 111 int64_t scheduling_hash) {
111 std::string encoded_message; 112 std::string encoded_message;
112 EncodeMessage(&encoded_message, message, service_context, scheduling_hash); 113 EncodeMessage(&encoded_message, message, service_context, scheduling_hash);
113 return encoded_message; 114 return encoded_message;
114 } 115 }
115 116
116 bool PushClientChannel::DecodeMessageForTest(const std::string& data, 117 bool PushClientChannel::DecodeMessageForTest(const std::string& data,
117 std::string* message, 118 std::string* message,
118 std::string* service_context, 119 std::string* service_context,
119 int64* scheduling_hash) { 120 int64_t* scheduling_hash) {
120 return DecodeMessage(data, message, service_context, scheduling_hash); 121 return DecodeMessage(data, message, service_context, scheduling_hash);
121 } 122 }
122 123
123 void PushClientChannel::EncodeMessage(std::string* encoded_message, 124 void PushClientChannel::EncodeMessage(std::string* encoded_message,
124 const std::string& message, 125 const std::string& message,
125 const std::string& service_context, 126 const std::string& service_context,
126 int64 scheduling_hash) { 127 int64_t scheduling_hash) {
127 ipc::invalidation::ClientGatewayMessage envelope; 128 ipc::invalidation::ClientGatewayMessage envelope;
128 envelope.set_is_client_to_server(true); 129 envelope.set_is_client_to_server(true);
129 if (!service_context.empty()) { 130 if (!service_context.empty()) {
130 envelope.set_service_context(service_context); 131 envelope.set_service_context(service_context);
131 envelope.set_rpc_scheduling_hash(scheduling_hash); 132 envelope.set_rpc_scheduling_hash(scheduling_hash);
132 } 133 }
133 envelope.set_network_message(message); 134 envelope.set_network_message(message);
134 envelope.SerializeToString(encoded_message); 135 envelope.SerializeToString(encoded_message);
135 } 136 }
136 137
137 bool PushClientChannel::DecodeMessage(const std::string& data, 138 bool PushClientChannel::DecodeMessage(const std::string& data,
138 std::string* message, 139 std::string* message,
139 std::string* service_context, 140 std::string* service_context,
140 int64* scheduling_hash) { 141 int64_t* scheduling_hash) {
141 ipc::invalidation::ClientGatewayMessage envelope; 142 ipc::invalidation::ClientGatewayMessage envelope;
142 if (!envelope.ParseFromString(data)) { 143 if (!envelope.ParseFromString(data)) {
143 return false; 144 return false;
144 } 145 }
145 *message = envelope.network_message(); 146 *message = envelope.network_message();
146 if (envelope.has_service_context()) { 147 if (envelope.has_service_context()) {
147 *service_context = envelope.service_context(); 148 *service_context = envelope.service_context();
148 } 149 }
149 if (envelope.has_rpc_scheduling_hash()) { 150 if (envelope.has_rpc_scheduling_hash()) {
150 *scheduling_hash = envelope.rpc_scheduling_hash(); 151 *scheduling_hash = envelope.rpc_scheduling_hash();
151 } 152 }
152 return true; 153 return true;
153 } 154 }
154 155
155 scoped_ptr<base::DictionaryValue> PushClientChannel::CollectDebugData() const { 156 scoped_ptr<base::DictionaryValue> PushClientChannel::CollectDebugData() const {
156 scoped_ptr<base::DictionaryValue> status(new base::DictionaryValue); 157 scoped_ptr<base::DictionaryValue> status(new base::DictionaryValue);
157 status->SetString("PushClientChannel.NetworkChannel", "Push Client"); 158 status->SetString("PushClientChannel.NetworkChannel", "Push Client");
158 status->SetInteger("PushClientChannel.SentMessages", sent_messages_count_); 159 status->SetInteger("PushClientChannel.SentMessages", sent_messages_count_);
159 status->SetInteger("PushClientChannel.ReceivedMessages", 160 status->SetInteger("PushClientChannel.ReceivedMessages",
160 SyncNetworkChannel::GetReceivedMessagesCount()); 161 SyncNetworkChannel::GetReceivedMessagesCount());
161 return status.Pass(); 162 return status.Pass();
162 } 163 }
163 164
164 } // namespace syncer 165 } // namespace syncer
OLDNEW
« no previous file with comments | « components/invalidation/impl/push_client_channel.h ('k') | components/invalidation/impl/push_client_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698