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 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_ | 5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_ |
6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_ | 6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 explicit VariationsSeedStore(PrefService* local_state); | 27 explicit VariationsSeedStore(PrefService* local_state); |
28 virtual ~VariationsSeedStore(); | 28 virtual ~VariationsSeedStore(); |
29 | 29 |
30 // Loads the variations seed data from local state into |seed|. If there is a | 30 // Loads the variations seed data from local state into |seed|. If there is a |
31 // problem with loading, the pref value is cleared and false is returned. If | 31 // problem with loading, the pref value is cleared and false is returned. If |
32 // successful, |seed| will contain the loaded data and true is returned. | 32 // successful, |seed| will contain the loaded data and true is returned. |
33 bool LoadSeed(variations::VariationsSeed* seed); | 33 bool LoadSeed(variations::VariationsSeed* seed); |
34 | 34 |
35 // Stores the given seed |data| (serialized protobuf) to local state, along | 35 // Stores the given seed |data| (serialized protobuf) to local state, along |
36 // with a base64-encoded digital signature for seed and the date when it was | 36 // with a base64-encoded digital signature for seed and the date when it was |
37 // fetched. If |is_delta_compressed| is true, treats |data| as being delta | 37 // fetched. If |is_gzip_compressed| is true, treats |data| as being gzip |
| 38 // compressed and decompresses it before any other processing. |
| 39 // If |is_delta_compressed| is true, treats |data| as being delta |
38 // compressed and attempts to decode it first using the store's seed data. | 40 // compressed and attempts to decode it first using the store's seed data. |
39 // The actual seed data will be base64 encoded for storage. If the string | 41 // The actual seed data will be base64 encoded for storage. If the string |
40 // is invalid, the existing prefs are untouched and false is returned. | 42 // is invalid, the existing prefs are untouched and false is returned. |
41 // Additionally, stores the |country_code| that was received with the seed in | 43 // Additionally, stores the |country_code| that was received with the seed in |
42 // a separate pref. On success and if |parsed_seed| is not NULL, |parsed_seed| | 44 // a separate pref. On success and if |parsed_seed| is not NULL, |parsed_seed| |
43 // will be filled with the de-serialized decoded protobuf. | 45 // will be filled with the de-serialized decoded protobuf. |
44 bool StoreSeedData(const std::string& data, | 46 bool StoreSeedData(const std::string& data, |
45 const std::string& base64_seed_signature, | 47 const std::string& base64_seed_signature, |
46 const std::string& country_code, | 48 const std::string& country_code, |
47 const base::Time& date_fetched, | 49 const base::Time& date_fetched, |
48 bool is_delta_compressed, | 50 bool is_delta_compressed, |
| 51 bool is_gzip_compressed, |
49 variations::VariationsSeed* parsed_seed); | 52 variations::VariationsSeed* parsed_seed); |
50 | 53 |
51 // Updates |kVariationsSeedDate| and logs when previous date was from a | 54 // Updates |kVariationsSeedDate| and logs when previous date was from a |
52 // different day. | 55 // different day. |
53 void UpdateSeedDateAndLogDayChange(const base::Time& server_date_fetched); | 56 void UpdateSeedDateAndLogDayChange(const base::Time& server_date_fetched); |
54 | 57 |
| 58 // Reports to UMA that the seed format specified by the server is unsupported. |
| 59 void ReportUnsupportedSeedFormatError(); |
| 60 |
55 // Returns the serial number of the last loaded or stored seed. | 61 // Returns the serial number of the last loaded or stored seed. |
56 const std::string& variations_serial_number() const { | 62 const std::string& variations_serial_number() const { |
57 return variations_serial_number_; | 63 return variations_serial_number_; |
58 } | 64 } |
59 | 65 |
60 // Returns whether the last loaded or stored seed has the country field set. | 66 // Returns whether the last loaded or stored seed has the country field set. |
61 bool seed_has_country_code() const { | 67 bool seed_has_country_code() const { |
62 return seed_has_country_code_; | 68 return seed_has_country_code_; |
63 } | 69 } |
64 | 70 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 133 |
128 // Keeps track of an invalid signature. | 134 // Keeps track of an invalid signature. |
129 std::string invalid_base64_signature_; | 135 std::string invalid_base64_signature_; |
130 | 136 |
131 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); | 137 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); |
132 }; | 138 }; |
133 | 139 |
134 } // namespace variations | 140 } // namespace variations |
135 | 141 |
136 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_ | 142 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_ |
OLD | NEW |