Chromium Code Reviews| 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 "google_apis/gcm/engine/gcm_store_impl.h" | 5 #include "google_apis/gcm/engine/gcm_store_impl.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 message, | 703 message, |
| 704 base::Bind(&GCMStoreImpl::AddOutgoingMessageContinuation, | 704 base::Bind(&GCMStoreImpl::AddOutgoingMessageContinuation, |
| 705 weak_ptr_factory_.GetWeakPtr(), | 705 weak_ptr_factory_.GetWeakPtr(), |
| 706 callback, | 706 callback, |
| 707 app_id))); | 707 app_id))); |
| 708 return true; | 708 return true; |
| 709 } | 709 } |
| 710 return false; | 710 return false; |
| 711 } | 711 } |
| 712 | 712 |
| 713 void GCMStoreImpl::OverwriteOutgoingMessage(const std::string& persistent_id, | |
| 714 const MCSMessage& message, | |
| 715 const UpdateCallback& callback) { | |
| 716 DCHECK_EQ(message.tag(), kDataMessageStanzaTag); | |
| 717 std::string app_id = reinterpret_cast<const mcs_proto::DataMessageStanza*>( | |
| 718 &message.GetProtobuf())->from(); | |
|
fgorski
2014/01/27 17:39:38
app_id is stored in category
Nicolas Zea
2014/01/28 08:15:35
from is supposed to store project id, and category
fgorski
2014/01/28 18:10:27
Ok. For upstream messages the following holds true
Nicolas Zea
2014/01/31 11:58:43
Done.
| |
| 719 DCHECK(!app_id.empty()); | |
| 720 // There should already be pending messages for this app. | |
| 721 DCHECK(app_message_counts_.count(app_id)); | |
| 722 // TODO(zea); consider verifying the specific message already exists. | |
| 723 blocking_task_runner_->PostTask( | |
| 724 FROM_HERE, | |
| 725 base::Bind(&GCMStoreImpl::Backend::AddOutgoingMessage, | |
| 726 backend_, | |
| 727 persistent_id, | |
| 728 message, | |
| 729 callback)); | |
| 730 } | |
| 731 | |
| 713 void GCMStoreImpl::RemoveOutgoingMessage(const std::string& persistent_id, | 732 void GCMStoreImpl::RemoveOutgoingMessage(const std::string& persistent_id, |
| 714 const UpdateCallback& callback) { | 733 const UpdateCallback& callback) { |
| 715 blocking_task_runner_->PostTask( | 734 blocking_task_runner_->PostTask( |
| 716 FROM_HERE, | 735 FROM_HERE, |
| 717 base::Bind(&GCMStoreImpl::Backend::RemoveOutgoingMessages, | 736 base::Bind(&GCMStoreImpl::Backend::RemoveOutgoingMessages, |
| 718 backend_, | 737 backend_, |
| 719 PersistentIdList(1, persistent_id), | 738 PersistentIdList(1, persistent_id), |
| 720 base::Bind(&GCMStoreImpl::RemoveOutgoingMessagesContinuation, | 739 base::Bind(&GCMStoreImpl::RemoveOutgoingMessagesContinuation, |
| 721 weak_ptr_factory_.GetWeakPtr(), | 740 weak_ptr_factory_.GetWeakPtr(), |
| 722 callback))); | 741 callback))); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 removed_message_counts.begin(); | 833 removed_message_counts.begin(); |
| 815 iter != removed_message_counts.end(); ++iter) { | 834 iter != removed_message_counts.end(); ++iter) { |
| 816 DCHECK_NE(app_message_counts_.count(iter->first), 0U); | 835 DCHECK_NE(app_message_counts_.count(iter->first), 0U); |
| 817 app_message_counts_[iter->first] -= iter->second; | 836 app_message_counts_[iter->first] -= iter->second; |
| 818 DCHECK_GE(app_message_counts_[iter->first], 0); | 837 DCHECK_GE(app_message_counts_[iter->first], 0); |
| 819 } | 838 } |
| 820 callback.Run(true); | 839 callback.Run(true); |
| 821 } | 840 } |
| 822 | 841 |
| 823 } // namespace gcm | 842 } // namespace gcm |
| OLD | NEW |