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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 void GCMStoreImpl::Backend::RemoveRegistration(const std::string& app_id, | 351 void GCMStoreImpl::Backend::RemoveRegistration(const std::string& app_id, |
352 const UpdateCallback& callback) { | 352 const UpdateCallback& callback) { |
353 if (!db_.get()) { | 353 if (!db_.get()) { |
354 LOG(ERROR) << "GCMStore db doesn't exist."; | 354 LOG(ERROR) << "GCMStore db doesn't exist."; |
355 foreground_task_runner_->PostTask(FROM_HERE, base::Bind(callback, false)); | 355 foreground_task_runner_->PostTask(FROM_HERE, base::Bind(callback, false)); |
356 return; | 356 return; |
357 } | 357 } |
358 leveldb::WriteOptions write_options; | 358 leveldb::WriteOptions write_options; |
359 write_options.sync = true; | 359 write_options.sync = true; |
360 | 360 |
361 leveldb::Status status = db_->Delete(write_options, MakeSlice(app_id)); | 361 leveldb::Status status = |
| 362 db_->Delete(write_options, MakeSlice(MakeRegistrationKey(app_id))); |
362 if (status.ok()) { | 363 if (status.ok()) { |
363 foreground_task_runner_->PostTask(FROM_HERE, base::Bind(callback, true)); | 364 foreground_task_runner_->PostTask(FROM_HERE, base::Bind(callback, true)); |
364 return; | 365 return; |
365 } | 366 } |
366 LOG(ERROR) << "LevelDB remove failed: " << status.ToString(); | 367 LOG(ERROR) << "LevelDB remove failed: " << status.ToString(); |
367 foreground_task_runner_->PostTask(FROM_HERE, base::Bind(callback, false)); | 368 foreground_task_runner_->PostTask(FROM_HERE, base::Bind(callback, false)); |
368 } | 369 } |
369 | 370 |
370 void GCMStoreImpl::Backend::AddIncomingMessage(const std::string& persistent_id, | 371 void GCMStoreImpl::Backend::AddIncomingMessage(const std::string& persistent_id, |
371 const UpdateCallback& callback) { | 372 const UpdateCallback& callback) { |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 removed_message_counts.begin(); | 1080 removed_message_counts.begin(); |
1080 iter != removed_message_counts.end(); ++iter) { | 1081 iter != removed_message_counts.end(); ++iter) { |
1081 DCHECK_NE(app_message_counts_.count(iter->first), 0U); | 1082 DCHECK_NE(app_message_counts_.count(iter->first), 0U); |
1082 app_message_counts_[iter->first] -= iter->second; | 1083 app_message_counts_[iter->first] -= iter->second; |
1083 DCHECK_GE(app_message_counts_[iter->first], 0); | 1084 DCHECK_GE(app_message_counts_[iter->first], 0); |
1084 } | 1085 } |
1085 callback.Run(true); | 1086 callback.Run(true); |
1086 } | 1087 } |
1087 | 1088 |
1088 } // namespace gcm | 1089 } // namespace gcm |
OLD | NEW |