OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_RLZ_RLZ_TRACKER_H_ | 5 #ifndef COMPONENTS_RLZ_RLZ_TRACKER_H_ |
6 #define COMPONENTS_RLZ_RLZ_TRACKER_H_ | 6 #define COMPONENTS_RLZ_RLZ_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/sequence_checker.h" |
14 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
15 #include "base/threading/sequenced_worker_pool.h" | |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "rlz/lib/rlz_lib.h" | 19 #include "rlz/lib/rlz_lib.h" |
19 | 20 |
| 21 namespace base { |
| 22 class SequencedTaskRunner; |
| 23 } |
| 24 |
20 namespace rlz { | 25 namespace rlz { |
21 | 26 |
22 class RLZTrackerDelegate; | 27 class RLZTrackerDelegate; |
23 | 28 |
24 // RLZ is a library which is used to measure distribution scenarios. | 29 // RLZ is a library which is used to measure distribution scenarios. |
25 // Its job is to record certain lifetime events in the registry and to send | 30 // Its job is to record certain lifetime events in the registry and to send |
26 // them encoded as a compact string at most twice. The sent data does | 31 // them encoded as a compact string at most twice. The sent data does |
27 // not contain information that can be used to identify a user or to infer | 32 // not contain information that can be used to identify a user or to infer |
28 // browsing habits. The API in this file is a wrapper around the open source | 33 // browsing habits. The API in this file is a wrapper around the open source |
29 // RLZ library which can be found at http://code.google.com/p/rlz. | 34 // RLZ library which can be found at http://code.google.com/p/rlz. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Delegate abstracting embedder specific knowledge. Must not be null. | 203 // Delegate abstracting embedder specific knowledge. Must not be null. |
199 std::unique_ptr<RLZTrackerDelegate> delegate_; | 204 std::unique_ptr<RLZTrackerDelegate> delegate_; |
200 | 205 |
201 // Configuation data for RLZ tracker. Set by call to Init(). | 206 // Configuation data for RLZ tracker. Set by call to Init(). |
202 bool first_run_; | 207 bool first_run_; |
203 bool send_ping_immediately_; | 208 bool send_ping_immediately_; |
204 bool is_google_default_search_; | 209 bool is_google_default_search_; |
205 bool is_google_homepage_; | 210 bool is_google_homepage_; |
206 bool is_google_in_startpages_; | 211 bool is_google_in_startpages_; |
207 | 212 |
208 // Unique sequence token so that tasks posted by RLZTracker are executed | |
209 // sequentially in the blocking pool. | |
210 base::SequencedWorkerPool::SequenceToken worker_pool_token_; | |
211 | |
212 // Keeps track if the RLZ tracker has already performed its delayed | 213 // Keeps track if the RLZ tracker has already performed its delayed |
213 // initialization. | 214 // initialization. |
214 bool already_ran_; | 215 bool already_ran_; |
215 | 216 |
216 // Keeps a cache of RLZ access point strings, since they rarely change. | 217 // Keeps a cache of RLZ access point strings, since they rarely change. |
217 // The cache must be protected by a lock since it may be accessed from | 218 // The cache must be protected by a lock since it may be accessed from |
218 // the UI thread for reading and the IO thread for reading and/or writing. | 219 // the UI thread for reading and the IO thread for reading and/or writing. |
219 base::Lock cache_lock_; | 220 base::Lock cache_lock_; |
220 std::map<rlz_lib::AccessPoint, base::string16> rlz_cache_; | 221 std::map<rlz_lib::AccessPoint, base::string16> rlz_cache_; |
221 | 222 |
222 // Keeps track of whether the omnibox, home page or app list have been used. | 223 // Keeps track of whether the omnibox, home page or app list have been used. |
223 bool omnibox_used_; | 224 bool omnibox_used_; |
224 bool homepage_used_; | 225 bool homepage_used_; |
225 bool app_list_used_; | 226 bool app_list_used_; |
226 | 227 |
227 // Main and (optionally) reactivation brand codes, assigned on UI thread. | 228 // Main and (optionally) reactivation brand codes, assigned on UI thread. |
228 std::string brand_; | 229 std::string brand_; |
229 std::string reactivation_brand_; | 230 std::string reactivation_brand_; |
230 | 231 |
231 // Minimum delay before sending financial ping after initialization. | 232 // Minimum delay before sending financial ping after initialization. |
232 base::TimeDelta min_init_delay_; | 233 base::TimeDelta min_init_delay_; |
233 | 234 |
| 235 // Runner for RLZ background tasks. The checked is used to verify operations |
| 236 // occur in the correct sequence, especially in tests. |
| 237 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; |
| 238 SEQUENCE_CHECKER(sequence_checker_); |
| 239 |
234 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 240 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
235 }; | 241 }; |
236 | 242 |
237 } // namespace rlz | 243 } // namespace rlz |
238 | 244 |
239 #endif // COMPONENTS_RLZ_RLZ_TRACKER_H_ | 245 #endif // COMPONENTS_RLZ_RLZ_TRACKER_H_ |
OLD | NEW |