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

Side by Side Diff: components/variations/variations_seed_store.h

Issue 1438123002: Removed callbacks to JNI functions + added gzip compressed seed support & pulling response time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implemented the rest TODOs: pulling time from response and GZIP compressed seed support Created 5 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
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 #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/callback.h"
11 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
13 #include "base/time/time.h" 12 #include "base/time/time.h"
14 13
15 class PrefService; 14 class PrefService;
16 class PrefRegistrySimple; 15 class PrefRegistrySimple;
17 16
18 namespace variations { 17 namespace variations {
19 class VariationsSeed; 18 class VariationsSeed;
20 } 19 }
21 20
22 namespace variations { 21 namespace variations {
23 22
24 typedef base::Callback<void(std::string*, std::string*, std::string*)>
25 VariationsFirstRunSeedCallback;
26
27 // VariationsSeedStore is a helper class for reading and writing the variations 23 // VariationsSeedStore is a helper class for reading and writing the variations
28 // seed from Local State. 24 // seed from Local State.
29 class VariationsSeedStore { 25 class VariationsSeedStore {
30 public: 26 public:
31 explicit VariationsSeedStore(PrefService* local_state); 27 explicit VariationsSeedStore(PrefService* local_state);
32 virtual ~VariationsSeedStore(); 28 virtual ~VariationsSeedStore();
33 29
34 // 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
35 // 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
36 // successful, |seed| will contain the loaded data and true is returned. 32 // successful, |seed| will contain the loaded data and true is returned.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return seed_has_country_code_; 68 return seed_has_country_code_;
73 } 69 }
74 70
75 // Returns the invalid signature in base64 format, or an empty string if the 71 // Returns the invalid signature in base64 format, or an empty string if the
76 // signature was valid, missing, or if signature verification is disabled. 72 // signature was valid, missing, or if signature verification is disabled.
77 std::string GetInvalidSignature() const; 73 std::string GetInvalidSignature() const;
78 74
79 // Registers Local State prefs used by this class. 75 // Registers Local State prefs used by this class.
80 static void RegisterPrefs(PrefRegistrySimple* registry); 76 static void RegisterPrefs(PrefRegistrySimple* registry);
81 77
82 // Registers callback for pulling variations first run seed from Java side
83 // in Chrome for Android.
84 void SetVariationsFirstRunSeedCallback(
85 const VariationsFirstRunSeedCallback& callback) {
86 get_variations_first_run_seed_ = callback;
87 }
88
89 protected: 78 protected:
90 // Note: UMA histogram enum - don't re-order or remove entries. 79 // Note: UMA histogram enum - don't re-order or remove entries.
91 enum VerifySignatureResult { 80 enum VerifySignatureResult {
92 VARIATIONS_SEED_SIGNATURE_MISSING, 81 VARIATIONS_SEED_SIGNATURE_MISSING,
93 VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, 82 VARIATIONS_SEED_SIGNATURE_DECODE_FAILED,
94 VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE, 83 VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE,
95 VARIATIONS_SEED_SIGNATURE_INVALID_SEED, 84 VARIATIONS_SEED_SIGNATURE_INVALID_SEED,
96 VARIATIONS_SEED_SIGNATURE_VALID, 85 VARIATIONS_SEED_SIGNATURE_VALID,
97 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE, 86 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE,
98 }; 87 };
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Cached serial number from the most recently fetched variations seed. 133 // Cached serial number from the most recently fetched variations seed.
145 std::string variations_serial_number_; 134 std::string variations_serial_number_;
146 135
147 // Whether the most recently fetched variations seed has the country code 136 // Whether the most recently fetched variations seed has the country code
148 // field set. 137 // field set.
149 bool seed_has_country_code_; 138 bool seed_has_country_code_;
150 139
151 // Keeps track of an invalid signature. 140 // Keeps track of an invalid signature.
152 std::string invalid_base64_signature_; 141 std::string invalid_base64_signature_;
153 142
154 VariationsFirstRunSeedCallback get_variations_first_run_seed_;
155
156 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); 143 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore);
157 }; 144 };
158 145
159 } // namespace variations 146 } // namespace variations
160 147
161 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_ 148 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698