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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 base::Time* last_checkin_time, | 766 base::Time* last_checkin_time, |
767 std::set<std::string>* accounts) { | 767 std::set<std::string>* accounts) { |
768 leveldb::ReadOptions read_options; | 768 leveldb::ReadOptions read_options; |
769 read_options.verify_checksums = true; | 769 read_options.verify_checksums = true; |
770 | 770 |
771 std::string result; | 771 std::string result; |
772 leveldb::Status s = db_->Get(read_options, | 772 leveldb::Status s = db_->Get(read_options, |
773 MakeSlice(kLastCheckinTimeKey), | 773 MakeSlice(kLastCheckinTimeKey), |
774 &result); | 774 &result); |
775 int64 time_internal = 0LL; | 775 int64 time_internal = 0LL; |
776 if (s.ok() && !base::StringToInt64(result, &time_internal)) | 776 if (s.ok() && !base::StringToInt64(result, &time_internal)) { |
777 LOG(ERROR) << "Failed to restore last checkin time. Using default = 0."; | 777 LOG(ERROR) << "Failed to restore last checkin time. Using default = 0."; |
778 time_internal = 0LL; | |
miu
2015/01/29 02:56:15
Should this method return false here instead?
fgorski
2015/01/29 22:48:44
This is not as severe as other problems we might b
| |
779 } | |
778 | 780 |
779 // In case we cannot read last checkin time, we default it to 0, as we don't | 781 // In case we cannot read last checkin time, we default it to 0, as we don't |
780 // want that situation to cause the whole load to fail. | 782 // want that situation to cause the whole load to fail. |
781 *last_checkin_time = base::Time::FromInternalValue(time_internal); | 783 *last_checkin_time = base::Time::FromInternalValue(time_internal); |
782 | 784 |
783 accounts->clear(); | 785 accounts->clear(); |
784 s = db_->Get(read_options, MakeSlice(kLastCheckinAccountsKey), &result); | 786 s = db_->Get(read_options, MakeSlice(kLastCheckinAccountsKey), &result); |
785 if (!s.ok()) | 787 if (!s.ok()) |
786 DVLOG(1) << "No accounts where stored during last run."; | 788 DVLOG(1) << "No accounts where stored during last run."; |
787 | 789 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 | 847 |
846 bool GCMStoreImpl::Backend::LoadLastTokenFetchTime( | 848 bool GCMStoreImpl::Backend::LoadLastTokenFetchTime( |
847 base::Time* last_token_fetch_time) { | 849 base::Time* last_token_fetch_time) { |
848 leveldb::ReadOptions read_options; | 850 leveldb::ReadOptions read_options; |
849 read_options.verify_checksums = true; | 851 read_options.verify_checksums = true; |
850 | 852 |
851 std::string result; | 853 std::string result; |
852 leveldb::Status s = | 854 leveldb::Status s = |
853 db_->Get(read_options, MakeSlice(kLastTokenFetchTimeKey), &result); | 855 db_->Get(read_options, MakeSlice(kLastTokenFetchTimeKey), &result); |
854 int64 time_internal = 0LL; | 856 int64 time_internal = 0LL; |
855 if (s.ok() && !base::StringToInt64(result, &time_internal)) | 857 if (s.ok() && !base::StringToInt64(result, &time_internal)) { |
856 LOG(ERROR) << "Failed to restore last checkin time. Using default = 0."; | 858 LOG(ERROR) << |
859 "Failed to restore last token fetching time. Using default = 0."; | |
860 time_internal = 0LL; | |
miu
2015/01/29 02:56:16
ditto: Should this method return false here instea
fgorski
2015/01/29 22:48:44
Same here.
| |
861 } | |
857 | 862 |
858 // In case we cannot read last token fetching time, we default it to 0. | 863 // In case we cannot read last token fetching time, we default it to 0. |
859 *last_token_fetch_time = base::Time::FromInternalValue(time_internal); | 864 *last_token_fetch_time = base::Time::FromInternalValue(time_internal); |
860 | 865 |
861 return true; | 866 return true; |
862 } | 867 } |
863 | 868 |
864 GCMStoreImpl::GCMStoreImpl( | 869 GCMStoreImpl::GCMStoreImpl( |
865 const base::FilePath& path, | 870 const base::FilePath& path, |
866 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 871 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1137 removed_message_counts.begin(); | 1142 removed_message_counts.begin(); |
1138 iter != removed_message_counts.end(); ++iter) { | 1143 iter != removed_message_counts.end(); ++iter) { |
1139 DCHECK_NE(app_message_counts_.count(iter->first), 0U); | 1144 DCHECK_NE(app_message_counts_.count(iter->first), 0U); |
1140 app_message_counts_[iter->first] -= iter->second; | 1145 app_message_counts_[iter->first] -= iter->second; |
1141 DCHECK_GE(app_message_counts_[iter->first], 0); | 1146 DCHECK_GE(app_message_counts_[iter->first], 0); |
1142 } | 1147 } |
1143 callback.Run(true); | 1148 callback.Run(true); |
1144 } | 1149 } |
1145 | 1150 |
1146 } // namespace gcm | 1151 } // namespace gcm |
OLD | NEW |