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 CHROME_BROWSER_RLZ_RLZ_H_ | 5 #ifndef CHROME_BROWSER_RLZ_RLZ_H_ |
6 #define CHROME_BROWSER_RLZ_RLZ_H_ | 6 #define CHROME_BROWSER_RLZ_RLZ_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(ENABLE_RLZ) | 10 #if defined(ENABLE_RLZ) |
11 | 11 |
12 #include <map> | 12 #include <map> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 #include "base/threading/thread.h" | |
19 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
21 #include "rlz/lib/rlz_lib.h" | 20 #include "rlz/lib/rlz_lib.h" |
22 | 21 |
| 22 namespace base { |
| 23 class SequencedTaskRunner; |
| 24 } |
23 namespace net { | 25 namespace net { |
24 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
25 } | 27 } |
26 | 28 |
27 // RLZ is a library which is used to measure distribution scenarios. | 29 // RLZ is a library which is used to measure distribution scenarios. |
28 // 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 |
29 // 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 |
30 // 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 |
31 // 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 |
32 // 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // will be returned from GetInstance() instead of the regular singleton. | 164 // will be returned from GetInstance() instead of the regular singleton. |
163 static RLZTracker* tracker_; | 165 static RLZTracker* tracker_; |
164 | 166 |
165 // Configuation data for RLZ tracker. Set by call to Init(). | 167 // Configuation data for RLZ tracker. Set by call to Init(). |
166 bool first_run_; | 168 bool first_run_; |
167 bool send_ping_immediately_; | 169 bool send_ping_immediately_; |
168 bool is_google_default_search_; | 170 bool is_google_default_search_; |
169 bool is_google_homepage_; | 171 bool is_google_homepage_; |
170 bool is_google_in_startpages_; | 172 bool is_google_in_startpages_; |
171 | 173 |
172 // Dedicated RLZ thread for accessing RlzValueStore and doing I/O. | |
173 base::Thread rlz_thread_; | |
174 | |
175 // Sequenced task runner used to post blocking tasks that access | 174 // Sequenced task runner used to post blocking tasks that access |
176 // RlzValueStore. | 175 // RlzValueStore. |
177 base::SequencedTaskRunner* blocking_task_runner_; | 176 base::SequencedTaskRunner* blocking_task_runner_; |
178 | 177 |
179 // URLRequestContextGetter used by RLZ library. | 178 // URLRequestContextGetter used by RLZ library. |
180 net::URLRequestContextGetter* url_request_context_; | 179 net::URLRequestContextGetter* url_request_context_; |
181 | 180 |
182 // Keeps track if the RLZ tracker has already performed its delayed | 181 // Keeps track if the RLZ tracker has already performed its delayed |
183 // initialization. | 182 // initialization. |
184 bool already_ran_; | 183 bool already_ran_; |
185 | 184 |
186 // Keeps a cache of RLZ access point strings, since they rarely change. | 185 // Keeps a cache of RLZ access point strings, since they rarely change. |
187 // The cache must be protected by a lock since it may be accessed from | 186 // The cache must be protected by a lock since it may be accessed from |
188 // the UI thread for reading and the IO thread for reading and/or writing. | 187 // the UI thread for reading and the IO thread for reading and/or writing. |
189 base::Lock cache_lock_; | 188 base::Lock cache_lock_; |
190 std::map<rlz_lib::AccessPoint, string16> rlz_cache_; | 189 std::map<rlz_lib::AccessPoint, string16> rlz_cache_; |
191 | 190 |
192 // Keeps track of whether the omnibox or host page have been used. | 191 // Keeps track of whether the omnibox or host page have been used. |
193 bool omnibox_used_; | 192 bool omnibox_used_; |
194 bool homepage_used_; | 193 bool homepage_used_; |
195 | 194 |
196 content::NotificationRegistrar registrar_; | 195 content::NotificationRegistrar registrar_; |
197 | 196 |
198 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 197 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
199 }; | 198 }; |
200 | 199 |
201 #endif // defined(ENABLE_RLZ) | 200 #endif // defined(ENABLE_RLZ) |
202 | 201 |
203 #endif // CHROME_BROWSER_RLZ_RLZ_H_ | 202 #endif // CHROME_BROWSER_RLZ_RLZ_H_ |
OLD | NEW |