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/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ~Backend(); | 172 ~Backend(); |
173 | 173 |
174 bool LoadDeviceCredentials(uint64* android_id, uint64* security_token); | 174 bool LoadDeviceCredentials(uint64* android_id, uint64* security_token); |
175 bool LoadRegistrations(RegistrationInfoMap* registrations); | 175 bool LoadRegistrations(RegistrationInfoMap* registrations); |
176 bool LoadIncomingMessages(std::vector<std::string>* incoming_messages); | 176 bool LoadIncomingMessages(std::vector<std::string>* incoming_messages); |
177 bool LoadOutgoingMessages(OutgoingMessageMap* outgoing_messages); | 177 bool LoadOutgoingMessages(OutgoingMessageMap* outgoing_messages); |
178 bool LoadLastCheckinInfo(base::Time* last_checkin_time, | 178 bool LoadLastCheckinInfo(base::Time* last_checkin_time, |
179 std::set<std::string>* accounts); | 179 std::set<std::string>* accounts); |
180 bool LoadGServicesSettings(std::map<std::string, std::string>* settings, | 180 bool LoadGServicesSettings(std::map<std::string, std::string>* settings, |
181 std::string* digest); | 181 std::string* digest); |
182 bool LoadAccountMappingInfo(AccountMappingMap* account_mappings); | 182 bool LoadAccountMappingInfo(AccountMappings* account_mappings); |
183 | 183 |
184 const base::FilePath path_; | 184 const base::FilePath path_; |
185 scoped_refptr<base::SequencedTaskRunner> foreground_task_runner_; | 185 scoped_refptr<base::SequencedTaskRunner> foreground_task_runner_; |
186 scoped_ptr<Encryptor> encryptor_; | 186 scoped_ptr<Encryptor> encryptor_; |
187 | 187 |
188 scoped_ptr<leveldb::DB> db_; | 188 scoped_ptr<leveldb::DB> db_; |
189 }; | 189 }; |
190 | 190 |
191 GCMStoreImpl::Backend::Backend( | 191 GCMStoreImpl::Backend::Backend( |
192 const base::FilePath& path, | 192 const base::FilePath& path, |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 << ", and value: " << value; | 785 << ", and value: " << value; |
786 } | 786 } |
787 | 787 |
788 // Load the settings digest. It's ok if it is empty. | 788 // Load the settings digest. It's ok if it is empty. |
789 db_->Get(read_options, MakeSlice(kGServiceSettingsDigestKey), digest); | 789 db_->Get(read_options, MakeSlice(kGServiceSettingsDigestKey), digest); |
790 | 790 |
791 return true; | 791 return true; |
792 } | 792 } |
793 | 793 |
794 bool GCMStoreImpl::Backend::LoadAccountMappingInfo( | 794 bool GCMStoreImpl::Backend::LoadAccountMappingInfo( |
795 AccountMappingMap* account_mappings) { | 795 AccountMappings* account_mappings) { |
796 leveldb::ReadOptions read_options; | 796 leveldb::ReadOptions read_options; |
797 read_options.verify_checksums = true; | 797 read_options.verify_checksums = true; |
798 | 798 |
799 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(read_options)); | 799 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(read_options)); |
800 for (iter->Seek(MakeSlice(kAccountKeyStart)); | 800 for (iter->Seek(MakeSlice(kAccountKeyStart)); |
801 iter->Valid() && iter->key().ToString() < kAccountKeyEnd; | 801 iter->Valid() && iter->key().ToString() < kAccountKeyEnd; |
802 iter->Next()) { | 802 iter->Next()) { |
803 AccountMapping account_mapping; | 803 AccountMapping account_mapping; |
804 account_mapping.account_id = ParseAccountKey(iter->key().ToString()); | 804 account_mapping.account_id = ParseAccountKey(iter->key().ToString()); |
805 if (!account_mapping.ParseFromString(iter->value().ToString())) { | 805 if (!account_mapping.ParseFromString(iter->value().ToString())) { |
806 DVLOG(1) << "Failed to parse account info with ID: " | 806 DVLOG(1) << "Failed to parse account info with ID: " |
807 << account_mapping.account_id; | 807 << account_mapping.account_id; |
808 return false; | 808 return false; |
809 } | 809 } |
810 DVLOG(1) << "Found account mapping with ID: " << account_mapping.account_id; | 810 DVLOG(1) << "Found account mapping with ID: " << account_mapping.account_id; |
811 (*account_mappings)[account_mapping.account_id] = account_mapping; | 811 account_mappings->push_back(account_mapping); |
812 } | 812 } |
813 | 813 |
814 return true; | 814 return true; |
815 } | 815 } |
816 | 816 |
817 GCMStoreImpl::GCMStoreImpl( | 817 GCMStoreImpl::GCMStoreImpl( |
818 const base::FilePath& path, | 818 const base::FilePath& path, |
819 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 819 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
820 scoped_ptr<Encryptor> encryptor) | 820 scoped_ptr<Encryptor> encryptor) |
821 : backend_(new Backend(path, | 821 : backend_(new Backend(path, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 removed_message_counts.begin(); | 1080 removed_message_counts.begin(); |
1081 iter != removed_message_counts.end(); ++iter) { | 1081 iter != removed_message_counts.end(); ++iter) { |
1082 DCHECK_NE(app_message_counts_.count(iter->first), 0U); | 1082 DCHECK_NE(app_message_counts_.count(iter->first), 0U); |
1083 app_message_counts_[iter->first] -= iter->second; | 1083 app_message_counts_[iter->first] -= iter->second; |
1084 DCHECK_GE(app_message_counts_[iter->first], 0); | 1084 DCHECK_GE(app_message_counts_[iter->first], 0); |
1085 } | 1085 } |
1086 callback.Run(true); | 1086 callback.Run(true); |
1087 } | 1087 } |
1088 | 1088 |
1089 } // namespace gcm | 1089 } // namespace gcm |
OLD | NEW |