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/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
21 #include "rlz/lib/rlz_lib.h" | 21 #include "rlz/lib/rlz_lib.h" |
22 | 22 |
23 class Profile; | |
23 namespace net { | 24 namespace net { |
24 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
25 } | 26 } |
26 | 27 |
27 // RLZ is a library which is used to measure distribution scenarios. | 28 // 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 | 29 // 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 | 30 // 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 | 31 // 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 | 32 // 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. | 33 // RLZ library which can be found at http://code.google.com/p/rlz. |
33 // | 34 // |
34 // For partner or bundled installs, the RLZ might send more information | 35 // For partner or bundled installs, the RLZ might send more information |
35 // according to the terms disclosed in the EULA. | 36 // according to the terms disclosed in the EULA. |
36 | 37 |
37 class RLZTracker : public content::NotificationObserver { | 38 class RLZTracker : public content::NotificationObserver { |
38 public: | 39 public: |
39 // Initializes the RLZ library services for use in chrome. Schedules a | 40 // Initializes the RLZ library services for use in chrome. Schedules a |
40 // delayed task (delayed by |delay| seconds) that performs the ping and | 41 // delayed task (delayed by |delay| seconds) that performs the ping and |
41 // registers some events when 'first-run' is true. | 42 // registers some events when 'first-run' is true. |
42 // | 43 // |
43 // If the chrome brand is organic (no partners) then the pings don't occur. | 44 // If the chrome brand is organic (no partners) then the pings don't occur. |
44 static bool InitRlzDelayed(bool first_run, | 45 static bool InitRlzDelayed(bool first_run, |
45 int delay, | 46 int delay, |
46 bool is_google_default_search, | 47 bool is_google_default_search, |
47 bool is_google_homepage, | 48 bool is_google_homepage, |
48 bool is_google_in_startpages); | 49 bool is_google_in_startpages); |
Roger Tawa OOO till Jul 10th
2012/11/28 15:23:18
This function is no longer called externally excep
Ivan Korotkov
2012/11/29 17:42:28
Done.
| |
49 | 50 |
51 // Shortcut for InitRlzDelayed which retrieves parameters from |profile|. | |
52 static bool InitRlzFromProfileDelayed(Profile* profile, | |
53 bool first_run, | |
54 int delay); | |
55 | |
50 // Records an RLZ event. Some events can be access point independent. | 56 // Records an RLZ event. Some events can be access point independent. |
51 // Returns false it the event could not be recorded. Requires write access | 57 // Returns false it the event could not be recorded. Requires write access |
52 // to the HKCU registry hive on windows. | 58 // to the HKCU registry hive on windows. |
53 static bool RecordProductEvent(rlz_lib::Product product, | 59 static bool RecordProductEvent(rlz_lib::Product product, |
54 rlz_lib::AccessPoint point, | 60 rlz_lib::AccessPoint point, |
55 rlz_lib::Event event_id); | 61 rlz_lib::Event event_id); |
56 | 62 |
57 // For the point parameter of RecordProductEvent. | 63 // For the point parameter of RecordProductEvent. |
58 static const rlz_lib::AccessPoint CHROME_OMNIBOX; | 64 static const rlz_lib::AccessPoint CHROME_OMNIBOX; |
59 static const rlz_lib::AccessPoint CHROME_HOME_PAGE; | 65 static const rlz_lib::AccessPoint CHROME_HOME_PAGE; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 // 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. |
180 // 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 |
181 // 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. |
182 base::Lock cache_lock_; | 188 base::Lock cache_lock_; |
183 std::map<rlz_lib::AccessPoint, string16> rlz_cache_; | 189 std::map<rlz_lib::AccessPoint, string16> rlz_cache_; |
184 | 190 |
185 // 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. |
186 bool omnibox_used_; | 192 bool omnibox_used_; |
187 bool homepage_used_; | 193 bool homepage_used_; |
188 | 194 |
195 // Main and (optionally) reactivation brand codes, assigned on UI thread. | |
196 std::string brand_; | |
197 std::string reactivation_brand_; | |
198 | |
189 content::NotificationRegistrar registrar_; | 199 content::NotificationRegistrar registrar_; |
190 | 200 |
191 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 201 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
192 }; | 202 }; |
193 | 203 |
194 #endif // defined(ENABLE_RLZ) | 204 #endif // defined(ENABLE_RLZ) |
195 | 205 |
196 #endif // CHROME_BROWSER_RLZ_RLZ_H_ | 206 #endif // CHROME_BROWSER_RLZ_RLZ_H_ |
OLD | NEW |