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/gcm_driver/gcm_client_impl.h" | 5 #include "components/gcm_driver/gcm_client_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1337 case DELETED_MESSAGES: | 1337 case DELETED_MESSAGES: |
1338 recorder_.RecordDataMessageReceived(app_id, data_message_stanza.from(), | 1338 recorder_.RecordDataMessageReceived(app_id, data_message_stanza.from(), |
1339 data_message_stanza.ByteSize(), true, | 1339 data_message_stanza.ByteSize(), true, |
1340 GCMStatsRecorder::DELETED_MESSAGES); | 1340 GCMStatsRecorder::DELETED_MESSAGES); |
1341 delegate_->OnMessagesDeleted(app_id); | 1341 delegate_->OnMessagesDeleted(app_id); |
1342 break; | 1342 break; |
1343 case SEND_ERROR: | 1343 case SEND_ERROR: |
1344 HandleIncomingSendError(app_id, data_message_stanza, message_data); | 1344 HandleIncomingSendError(app_id, data_message_stanza, message_data); |
1345 break; | 1345 break; |
1346 case UNKNOWN: | 1346 case UNKNOWN: |
1347 delegate_->OnMessageReceivedError(data_message_stanza.id(), app_id, | |
1348 GCMClient::GCM_UNKNOWN_MESSAGE_TYPE); | |
1347 DVLOG(1) << "Unknown message_type received. Message ignored. " | 1349 DVLOG(1) << "Unknown message_type received. Message ignored. " |
1348 << "App ID: " << app_id << "."; | 1350 << "App ID: " << app_id << "."; |
1349 break; | 1351 break; |
1350 } | 1352 } |
1351 } | 1353 } |
1352 | 1354 |
1353 void GCMClientImpl::HandleIncomingDataMessage( | 1355 void GCMClientImpl::HandleIncomingDataMessage( |
1354 const std::string& app_id, | 1356 const std::string& app_id, |
1355 bool was_subtype, | 1357 bool was_subtype, |
1356 const mcs_proto::DataMessageStanza& data_message_stanza, | 1358 const mcs_proto::DataMessageStanza& data_message_stanza, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1397 << " incorrectly had was_subtype = " << was_subtype; | 1399 << " incorrectly had was_subtype = " << was_subtype; |
1398 } else { | 1400 } else { |
1399 registered = true; | 1401 registered = true; |
1400 } | 1402 } |
1401 } | 1403 } |
1402 } | 1404 } |
1403 | 1405 |
1404 recorder_.RecordDataMessageReceived(app_id, sender, | 1406 recorder_.RecordDataMessageReceived(app_id, sender, |
1405 data_message_stanza.ByteSize(), registered, | 1407 data_message_stanza.ByteSize(), registered, |
1406 GCMStatsRecorder::DATA_MESSAGE); | 1408 GCMStatsRecorder::DATA_MESSAGE); |
1407 if (!registered) | 1409 if (!registered) { |
1410 delegate_->OnMessageReceivedError(app_id, data_message_stanza.id(), | |
1411 GCMClient::GCM_INVALID_SUBTYPE); | |
Peter Beverloo
2016/12/15 19:24:24
It's a bit unfortunate that we need to do the GCMC
harkness
2016/12/21 17:23:37
I've mostly moved things to the GCMClient now. It
| |
1408 return; | 1412 return; |
1413 } | |
1409 | 1414 |
1410 IncomingMessage incoming_message; | 1415 IncomingMessage incoming_message; |
1416 incoming_message.id = data_message_stanza.id(); | |
1411 incoming_message.sender_id = data_message_stanza.from(); | 1417 incoming_message.sender_id = data_message_stanza.from(); |
1412 if (data_message_stanza.has_token()) | 1418 if (data_message_stanza.has_token()) |
1413 incoming_message.collapse_key = data_message_stanza.token(); | 1419 incoming_message.collapse_key = data_message_stanza.token(); |
1414 incoming_message.data = message_data; | 1420 incoming_message.data = message_data; |
1415 incoming_message.raw_data = data_message_stanza.raw_data(); | 1421 incoming_message.raw_data = data_message_stanza.raw_data(); |
1416 | 1422 |
1417 delegate_->OnMessageReceived(app_id, incoming_message); | 1423 delegate_->OnMessageReceived(app_id, incoming_message); |
1418 } | 1424 } |
1419 | 1425 |
1420 void GCMClientImpl::HandleIncomingSendError( | 1426 void GCMClientImpl::HandleIncomingSendError( |
(...skipping 19 matching lines...) Expand all Loading... | |
1440 bool GCMClientImpl::HasStandaloneRegisteredApp() const { | 1446 bool GCMClientImpl::HasStandaloneRegisteredApp() const { |
1441 if (registrations_.empty()) | 1447 if (registrations_.empty()) |
1442 return false; | 1448 return false; |
1443 // Note that account mapper is not counted as a standalone app since it is | 1449 // Note that account mapper is not counted as a standalone app since it is |
1444 // automatically started when other app uses GCM. | 1450 // automatically started when other app uses GCM. |
1445 return registrations_.size() > 1 || | 1451 return registrations_.size() > 1 || |
1446 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId); | 1452 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId); |
1447 } | 1453 } |
1448 | 1454 |
1449 } // namespace gcm | 1455 } // namespace gcm |
OLD | NEW |