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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 if (account_removed) { | 462 if (account_removed) { |
463 DVLOG(1) << "Detected that account has been removed. Forcing checkin."; | 463 DVLOG(1) << "Detected that account has been removed. Forcing checkin."; |
464 checkin_request_.reset(); | 464 checkin_request_.reset(); |
465 StartCheckin(); | 465 StartCheckin(); |
466 } else if (!accounts_set_before) { | 466 } else if (!accounts_set_before) { |
467 SchedulePeriodicCheckin(); | 467 SchedulePeriodicCheckin(); |
468 DVLOG(1) << "Accounts set for the first time. Scheduled periodic checkin."; | 468 DVLOG(1) << "Accounts set for the first time. Scheduled periodic checkin."; |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
| 472 void GCMClientImpl::UpdateAccountMapping( |
| 473 const AccountMapping& account_mapping) { |
| 474 gcm_store_->AddAccountMapping(account_mapping, |
| 475 base::Bind(&GCMClientImpl::DefaultStoreCallback, |
| 476 weak_ptr_factory_.GetWeakPtr())); |
| 477 } |
| 478 |
| 479 void GCMClientImpl::RemoveAccountMapping(const std::string& account_id) { |
| 480 gcm_store_->RemoveAccountMapping( |
| 481 account_id, |
| 482 base::Bind(&GCMClientImpl::DefaultStoreCallback, |
| 483 weak_ptr_factory_.GetWeakPtr())); |
| 484 } |
| 485 |
472 void GCMClientImpl::StartCheckin() { | 486 void GCMClientImpl::StartCheckin() { |
473 // Make sure no checkin is in progress. | 487 // Make sure no checkin is in progress. |
474 if (checkin_request_.get()) | 488 if (checkin_request_.get()) |
475 return; | 489 return; |
476 | 490 |
477 checkin_proto::ChromeBuildProto chrome_build_proto; | 491 checkin_proto::ChromeBuildProto chrome_build_proto; |
478 ToCheckinProtoVersion(chrome_build_info_, &chrome_build_proto); | 492 ToCheckinProtoVersion(chrome_build_info_, &chrome_build_proto); |
479 CheckinRequest::RequestInfo request_info(device_checkin_info_.android_id, | 493 CheckinRequest::RequestInfo request_info(device_checkin_info_.android_id, |
480 device_checkin_info_.secret, | 494 device_checkin_info_.secret, |
481 device_checkin_info_.account_tokens, | 495 device_checkin_info_.account_tokens, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 void GCMClientImpl::SetDeviceCredentialsCallback(bool success) { | 591 void GCMClientImpl::SetDeviceCredentialsCallback(bool success) { |
578 // TODO(fgorski): This is one of the signals that store needs a rebuild. | 592 // TODO(fgorski): This is one of the signals that store needs a rebuild. |
579 DCHECK(success); | 593 DCHECK(success); |
580 } | 594 } |
581 | 595 |
582 void GCMClientImpl::UpdateRegistrationCallback(bool success) { | 596 void GCMClientImpl::UpdateRegistrationCallback(bool success) { |
583 // TODO(fgorski): This is one of the signals that store needs a rebuild. | 597 // TODO(fgorski): This is one of the signals that store needs a rebuild. |
584 DCHECK(success); | 598 DCHECK(success); |
585 } | 599 } |
586 | 600 |
| 601 void GCMClientImpl::DefaultStoreCallback(bool success) { |
| 602 DCHECK(success); |
| 603 } |
| 604 |
587 void GCMClientImpl::Stop() { | 605 void GCMClientImpl::Stop() { |
588 weak_ptr_factory_.InvalidateWeakPtrs(); | 606 weak_ptr_factory_.InvalidateWeakPtrs(); |
589 device_checkin_info_.Reset(); | 607 device_checkin_info_.Reset(); |
590 connection_factory_.reset(); | 608 connection_factory_.reset(); |
591 delegate_->OnDisconnected(); | 609 delegate_->OnDisconnected(); |
592 mcs_client_.reset(); | 610 mcs_client_.reset(); |
593 checkin_request_.reset(); | 611 checkin_request_.reset(); |
594 pending_registration_requests_.clear(); | 612 pending_registration_requests_.clear(); |
595 state_ = INITIALIZED; | 613 state_ = INITIALIZED; |
596 gcm_store_->Close(); | 614 gcm_store_->Close(); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 | 984 |
967 recorder_.RecordIncomingSendError( | 985 recorder_.RecordIncomingSendError( |
968 data_message_stanza.category(), | 986 data_message_stanza.category(), |
969 data_message_stanza.to(), | 987 data_message_stanza.to(), |
970 data_message_stanza.id()); | 988 data_message_stanza.id()); |
971 delegate_->OnMessageSendError(data_message_stanza.category(), | 989 delegate_->OnMessageSendError(data_message_stanza.category(), |
972 send_error_details); | 990 send_error_details); |
973 } | 991 } |
974 | 992 |
975 } // namespace gcm | 993 } // namespace gcm |
OLD | NEW |