| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // This file implements the platform-neutral Load() and Store() functions for a | 5 // This file implements the platform-neutral Load() and Store() functions for a |
| 6 // profile's safebrowsing.incidents_sent preference dictionary. The preference | 6 // profile's safebrowsing.incidents_sent preference dictionary. The preference |
| 7 // dict is converted to a protocol buffer message which is then serialized into | 7 // dict is converted to a protocol buffer message which is then serialized into |
| 8 // a byte array. This serialized data is written to or read from some | 8 // a byte array. This serialized data is written to or read from some |
| 9 // platform-specific storage via {Read,Write}StoreData implemented elsewhere. | 9 // platform-specific storage via {Read,Write}StoreData implemented elsewhere. |
| 10 // | 10 // |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 case PlatformStateStoreLoadResult::CLEARED_NO_DATA: | 142 case PlatformStateStoreLoadResult::CLEARED_NO_DATA: |
| 143 // Return a (possibly empty) dictionary for the success cases. | 143 // Return a (possibly empty) dictionary for the success cases. |
| 144 break; | 144 break; |
| 145 case PlatformStateStoreLoadResult::DATA_CLEAR_FAILED: | 145 case PlatformStateStoreLoadResult::DATA_CLEAR_FAILED: |
| 146 case PlatformStateStoreLoadResult::OPEN_FAILED: | 146 case PlatformStateStoreLoadResult::OPEN_FAILED: |
| 147 case PlatformStateStoreLoadResult::READ_FAILED: | 147 case PlatformStateStoreLoadResult::READ_FAILED: |
| 148 case PlatformStateStoreLoadResult::PARSE_ERROR: | 148 case PlatformStateStoreLoadResult::PARSE_ERROR: |
| 149 // Return null for all error cases. | 149 // Return null for all error cases. |
| 150 value_dict.reset(); | 150 value_dict.reset(); |
| 151 break; | 151 break; |
| 152 case PlatformStateStoreLoadResult::NUM_RESULTS: |
| 153 NOTREACHED(); |
| 154 break; |
| 152 } | 155 } |
| 153 UMA_HISTOGRAM_ENUMERATION( | 156 UMA_HISTOGRAM_ENUMERATION( |
| 154 "SBIRS.PSSLoadResult", static_cast<uint32_t>(result), | 157 "SBIRS.PSSLoadResult", static_cast<uint32_t>(result), |
| 155 static_cast<uint32_t>(PlatformStateStoreLoadResult::NUM_RESULTS)); | 158 static_cast<uint32_t>(PlatformStateStoreLoadResult::NUM_RESULTS)); |
| 156 return value_dict.Pass(); | 159 return value_dict.Pass(); |
| 157 #else | 160 #else |
| 158 return scoped_ptr<base::DictionaryValue>(); | 161 return scoped_ptr<base::DictionaryValue>(); |
| 159 #endif | 162 #endif |
| 160 } | 163 } |
| 161 | 164 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 191 return PlatformStateStoreLoadResult::PARSE_ERROR; | 194 return PlatformStateStoreLoadResult::PARSE_ERROR; |
| 192 value_dict->Clear(); | 195 value_dict->Clear(); |
| 193 RestoreFromProtobuf(store_data.type_to_incidents(), value_dict); | 196 RestoreFromProtobuf(store_data.type_to_incidents(), value_dict); |
| 194 return PlatformStateStoreLoadResult::SUCCESS; | 197 return PlatformStateStoreLoadResult::SUCCESS; |
| 195 } | 198 } |
| 196 | 199 |
| 197 #endif // USE_PLATFORM_STATE_STORE | 200 #endif // USE_PLATFORM_STATE_STORE |
| 198 | 201 |
| 199 } // namespace platform_state_store | 202 } // namespace platform_state_store |
| 200 } // namespace safe_browsing | 203 } // namespace safe_browsing |
| OLD | NEW |