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

Side by Side Diff: google_apis/gcm/engine/gcm_store_impl.cc

Issue 713573003: Fixing all of problems found by vc++ /analyze in GCM code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 545
546 void GCMStoreImpl::Backend::SetGServicesSettings( 546 void GCMStoreImpl::Backend::SetGServicesSettings(
547 const std::map<std::string, std::string>& settings, 547 const std::map<std::string, std::string>& settings,
548 const std::string& settings_digest, 548 const std::string& settings_digest,
549 const UpdateCallback& callback) { 549 const UpdateCallback& callback) {
550 leveldb::WriteBatch write_batch; 550 leveldb::WriteBatch write_batch;
551 551
552 // Remove all existing settings. 552 // Remove all existing settings.
553 leveldb::ReadOptions read_options; 553 leveldb::ReadOptions read_options;
554 read_options.verify_checksums = true; 554 read_options.verify_checksums = true;
555 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(read_options)); 555 scoped_ptr<leveldb::Iterator> db_iter(db_->NewIterator(read_options));
556 for (iter->Seek(MakeSlice(kGServiceSettingKeyStart)); 556 for (db_iter->Seek(MakeSlice(kGServiceSettingKeyStart));
557 iter->Valid() && iter->key().ToString() < kGServiceSettingKeyEnd; 557 db_iter->Valid() && db_iter->key().ToString() < kGServiceSettingKeyEnd;
558 iter->Next()) { 558 db_iter->Next()) {
559 write_batch.Delete(iter->key()); 559 write_batch.Delete(db_iter->key());
560 } 560 }
561 561
562 // Add the new settings. 562 // Add the new settings.
563 for (std::map<std::string, std::string>::const_iterator iter = 563 for (std::map<std::string, std::string>::const_iterator iter =
564 settings.begin(); 564 settings.begin();
565 iter != settings.end(); ++iter) { 565 iter != settings.end(); ++iter) {
566 write_batch.Put(MakeSlice(MakeGServiceSettingKey(iter->first)), 566 write_batch.Put(MakeSlice(MakeGServiceSettingKey(iter->first)),
567 MakeSlice(iter->second)); 567 MakeSlice(iter->second));
568 } 568 }
569 569
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 removed_message_counts.begin(); 1137 removed_message_counts.begin();
1138 iter != removed_message_counts.end(); ++iter) { 1138 iter != removed_message_counts.end(); ++iter) {
1139 DCHECK_NE(app_message_counts_.count(iter->first), 0U); 1139 DCHECK_NE(app_message_counts_.count(iter->first), 0U);
1140 app_message_counts_[iter->first] -= iter->second; 1140 app_message_counts_[iter->first] -= iter->second;
1141 DCHECK_GE(app_message_counts_[iter->first], 0); 1141 DCHECK_GE(app_message_counts_[iter->first], 0);
1142 } 1142 }
1143 callback.Run(true); 1143 callback.Run(true);
1144 } 1144 }
1145 1145
1146 } // namespace gcm 1146 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698