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

Unified Diff: google_apis/gcm/engine/gcm_store_impl.cc

Issue 148293002: [GCM] Add basic collapse key support for upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.h ('k') | google_apis/gcm/engine/mcs_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/engine/gcm_store_impl.cc
diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc
index daf7d362fd90adb3005a612c7d894a872e4e2fd4..9844f8aafc53fbde3521c056986603375e632094 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -372,11 +372,11 @@ void GCMStoreImpl::Backend::RemoveOutgoingMessages(
mcs_proto::DataMessageStanza data_message;
// Skip the initial tag byte and parse the rest to extract the message.
if (data_message.ParseFromString(outgoing_message.substr(1))) {
- DCHECK(!data_message.from().empty());
- if (removed_message_counts.count(data_message.from()) != 0)
- removed_message_counts[data_message.from()]++;
+ DCHECK(!data_message.category().empty());
+ if (removed_message_counts.count(data_message.category()) != 0)
+ removed_message_counts[data_message.category()]++;
else
- removed_message_counts[data_message.from()] = 1;
+ removed_message_counts[data_message.category()] = 1;
}
DVLOG(1) << "Removing outgoing message with id " << *iter;
s = db_->Delete(write_options, MakeSlice(key));
@@ -688,7 +688,7 @@ bool GCMStoreImpl::AddOutgoingMessage(const std::string& persistent_id,
const UpdateCallback& callback) {
DCHECK_EQ(message.tag(), kDataMessageStanzaTag);
std::string app_id = reinterpret_cast<const mcs_proto::DataMessageStanza*>(
- &message.GetProtobuf())->from();
+ &message.GetProtobuf())->category();
DCHECK(!app_id.empty());
if (app_message_counts_.count(app_id) == 0)
app_message_counts_[app_id] = 0;
@@ -710,6 +710,25 @@ bool GCMStoreImpl::AddOutgoingMessage(const std::string& persistent_id,
return false;
}
+void GCMStoreImpl::OverwriteOutgoingMessage(const std::string& persistent_id,
+ const MCSMessage& message,
+ const UpdateCallback& callback) {
+ DCHECK_EQ(message.tag(), kDataMessageStanzaTag);
+ std::string app_id = reinterpret_cast<const mcs_proto::DataMessageStanza*>(
+ &message.GetProtobuf())->category();
+ DCHECK(!app_id.empty());
+ // There should already be pending messages for this app.
+ DCHECK(app_message_counts_.count(app_id));
+ // TODO(zea): consider verifying the specific message already exists.
+ blocking_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&GCMStoreImpl::Backend::AddOutgoingMessage,
+ backend_,
+ persistent_id,
+ message,
+ callback));
+}
+
void GCMStoreImpl::RemoveOutgoingMessage(const std::string& persistent_id,
const UpdateCallback& callback) {
blocking_task_runner_->PostTask(
@@ -779,12 +798,12 @@ void GCMStoreImpl::LoadContinuation(const LoadCallback& callback,
iter != result->outgoing_messages.end(); ++iter) {
const mcs_proto::DataMessageStanza* data_message =
reinterpret_cast<mcs_proto::DataMessageStanza*>(iter->second.get());
- DCHECK(!data_message->from().empty());
- if (app_message_counts_.count(data_message->from()) == 0)
- app_message_counts_[data_message->from()] = 1;
+ DCHECK(!data_message->category().empty());
+ if (app_message_counts_.count(data_message->category()) == 0)
+ app_message_counts_[data_message->category()] = 1;
else
- app_message_counts_[data_message->from()]++;
- if (app_message_counts_[data_message->from()] == kMessagesPerAppLimit)
+ app_message_counts_[data_message->category()]++;
+ if (app_message_counts_[data_message->category()] == kMessagesPerAppLimit)
num_throttled_apps++;
}
UMA_HISTOGRAM_COUNTS("GCM.NumThrottledApps", num_throttled_apps);
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.h ('k') | google_apis/gcm/engine/mcs_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698