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" |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "base/threading/sequenced_worker_pool.h" | |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "rlz/lib/rlz_lib.h" | 18 #include "rlz/lib/rlz_lib.h" |
19 | 19 |
20 namespace base { | |
21 class SequencedTaskRunner; | |
22 } | |
23 | |
20 namespace rlz { | 24 namespace rlz { |
21 | 25 |
22 class RLZTrackerDelegate; | 26 class RLZTrackerDelegate; |
23 | 27 |
24 // RLZ is a library which is used to measure distribution scenarios. | 28 // 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 | 29 // 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 | 30 // 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 | 31 // 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 | 32 // 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. | 33 // 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. | 202 // Delegate abstracting embedder specific knowledge. Must not be null. |
199 std::unique_ptr<RLZTrackerDelegate> delegate_; | 203 std::unique_ptr<RLZTrackerDelegate> delegate_; |
200 | 204 |
201 // Configuation data for RLZ tracker. Set by call to Init(). | 205 // Configuation data for RLZ tracker. Set by call to Init(). |
202 bool first_run_; | 206 bool first_run_; |
203 bool send_ping_immediately_; | 207 bool send_ping_immediately_; |
204 bool is_google_default_search_; | 208 bool is_google_default_search_; |
205 bool is_google_homepage_; | 209 bool is_google_homepage_; |
206 bool is_google_in_startpages_; | 210 bool is_google_in_startpages_; |
207 | 211 |
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 | 212 // Keeps track if the RLZ tracker has already performed its delayed |
213 // initialization. | 213 // initialization. |
214 bool already_ran_; | 214 bool already_ran_; |
215 | 215 |
216 // Keeps a cache of RLZ access point strings, since they rarely change. | 216 // 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 | 217 // 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. | 218 // the UI thread for reading and the IO thread for reading and/or writing. |
219 base::Lock cache_lock_; | 219 base::Lock cache_lock_; |
220 std::map<rlz_lib::AccessPoint, base::string16> rlz_cache_; | 220 std::map<rlz_lib::AccessPoint, base::string16> rlz_cache_; |
221 | 221 |
222 // Keeps track of whether the omnibox, home page or app list have been used. | 222 // Keeps track of whether the omnibox, home page or app list have been used. |
223 bool omnibox_used_; | 223 bool omnibox_used_; |
224 bool homepage_used_; | 224 bool homepage_used_; |
225 bool app_list_used_; | 225 bool app_list_used_; |
226 | 226 |
227 // Main and (optionally) reactivation brand codes, assigned on UI thread. | 227 // Main and (optionally) reactivation brand codes, assigned on UI thread. |
228 std::string brand_; | 228 std::string brand_; |
229 std::string reactivation_brand_; | 229 std::string reactivation_brand_; |
230 | 230 |
231 // Minimum delay before sending financial ping after initialization. | 231 // Minimum delay before sending financial ping after initialization. |
232 base::TimeDelta min_init_delay_; | 232 base::TimeDelta min_init_delay_; |
233 | 233 |
234 // Runner for RLZ background tasks. | |
235 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
gab
2017/07/27 18:29:37
More specific name (background_task_runner_? or im
Roger Tawa OOO till Jul 10th
2017/07/28 18:43:06
Done.
| |
236 | |
234 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 237 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
235 }; | 238 }; |
236 | 239 |
237 } // namespace rlz | 240 } // namespace rlz |
238 | 241 |
239 #endif // COMPONENTS_RLZ_RLZ_TRACKER_H_ | 242 #endif // COMPONENTS_RLZ_RLZ_TRACKER_H_ |
OLD | NEW |