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

Side by Side Diff: chrome/browser/rlz/rlz.h

Issue 11645040: RLZ on ChromeOS-related polishing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/test_login_utils.cc ('k') | chrome/browser/rlz/rlz.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/time.h"
19 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
21 #include "rlz/lib/rlz_lib.h" 22 #include "rlz/lib/rlz_lib.h"
22 23
23 class Profile; 24 class Profile;
24 namespace net { 25 namespace net {
25 class URLRequestContextGetter; 26 class URLRequestContextGetter;
26 } 27 }
27 28
28 // RLZ is a library which is used to measure distribution scenarios. 29 // RLZ is a library which is used to measure distribution scenarios.
29 // 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
30 // 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
31 // 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
32 // 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
33 // 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.
34 // 35 //
35 // For partner or bundled installs, the RLZ might send more information 36 // For partner or bundled installs, the RLZ might send more information
36 // according to the terms disclosed in the EULA. 37 // according to the terms disclosed in the EULA.
37 38
38 class RLZTracker : public content::NotificationObserver { 39 class RLZTracker : public content::NotificationObserver {
39 public: 40 public:
40 // Initializes the RLZ library services for use in chrome. Schedules a 41 // Initializes the RLZ library services for use in chrome. Schedules a delayed
41 // delayed task (delayed by |delay| seconds) that performs the ping and 42 // task that performs the ping and registers some events when 'first-run' is
42 // registers some events when 'first-run' is true. 43 // true.
44 //
45 // When |send_ping_immediately| is true, financial ping should be sent
46 // immediately after a first search is recorded, without waiting for the next
47 // restart of chrome. However, we only want this behaviour on first run.
Roger Tawa OOO till Jul 10th 2012/12/20 18:37:23 We don't wait for "the next restart of chrome". I
Ivan Korotkov 2012/12/21 10:42:02 Done.
43 // 48 //
44 // If the chrome brand is organic (no partners) then the pings don't occur. 49 // If the chrome brand is organic (no partners) then the pings don't occur.
45 static bool InitRlzFromProfileDelayed(Profile* profile, 50 static bool InitRlzFromProfileDelayed(Profile* profile,
46 bool first_run, 51 bool first_run,
47 int delay); 52 bool send_ping_immediately,
53 base::TimeDelta delay);
48 54
49 // Records an RLZ event. Some events can be access point independent. 55 // Records an RLZ event. Some events can be access point independent.
50 // Returns false it the event could not be recorded. Requires write access 56 // Returns false it the event could not be recorded. Requires write access
51 // to the HKCU registry hive on windows. 57 // to the HKCU registry hive on windows.
52 static bool RecordProductEvent(rlz_lib::Product product, 58 static bool RecordProductEvent(rlz_lib::Product product,
53 rlz_lib::AccessPoint point, 59 rlz_lib::AccessPoint point,
54 rlz_lib::Event event_id); 60 rlz_lib::Event event_id);
55 61
56 // For the point parameter of RecordProductEvent. 62 // For the point parameter of RecordProductEvent.
57 static const rlz_lib::AccessPoint CHROME_OMNIBOX; 63 static const rlz_lib::AccessPoint CHROME_OMNIBOX;
(...skipping 21 matching lines...) Expand all
79 static void EnableZeroDelayForTesting(); 85 static void EnableZeroDelayForTesting();
80 86
81 // The following methods are made protected so that they can be used for 87 // The following methods are made protected so that they can be used for
82 // testing purposes. Production code should never need to call these. 88 // testing purposes. Production code should never need to call these.
83 protected: 89 protected:
84 RLZTracker(); 90 RLZTracker();
85 virtual ~RLZTracker(); 91 virtual ~RLZTracker();
86 92
87 // Called by InitRlzFromProfileDelayed with values taken from |profile|. 93 // Called by InitRlzFromProfileDelayed with values taken from |profile|.
88 static bool InitRlzDelayed(bool first_run, 94 static bool InitRlzDelayed(bool first_run,
89 int delay, 95 bool send_ping_immediately,
96 base::TimeDelta delay,
90 bool is_google_default_search, 97 bool is_google_default_search,
91 bool is_google_homepage, 98 bool is_google_homepage,
92 bool is_google_in_startpages); 99 bool is_google_in_startpages);
93 100
94 // Performs initialization of RLZ tracker that is purposefully delayed so 101 // Performs initialization of RLZ tracker that is purposefully delayed so
95 // that it does not interfere with chrome startup time. 102 // that it does not interfere with chrome startup time.
96 virtual void DelayedInit(); 103 virtual void DelayedInit();
97 104
98 // content::NotificationObserver implementation: 105 // content::NotificationObserver implementation:
99 virtual void Observe(int type, 106 virtual void Observe(int type,
(...skipping 10 matching lines...) Expand all
110 // cache since the response from the RLZ server may have changed then. 117 // cache since the response from the RLZ server may have changed then.
111 // Protected so that its accessible from tests. 118 // Protected so that its accessible from tests.
112 void PingNowImpl(); 119 void PingNowImpl();
113 120
114 private: 121 private:
115 friend struct DefaultSingletonTraits<RLZTracker>; 122 friend struct DefaultSingletonTraits<RLZTracker>;
116 friend class base::RefCountedThreadSafe<RLZTracker>; 123 friend class base::RefCountedThreadSafe<RLZTracker>;
117 124
118 // Implementation called from InitRlzDelayed() static method. 125 // Implementation called from InitRlzDelayed() static method.
119 bool Init(bool first_run, 126 bool Init(bool first_run,
120 int delay, 127 bool send_ping_immediately,
128 base::TimeDelta delay,
121 bool google_default_search, 129 bool google_default_search,
122 bool google_default_homepage, 130 bool google_default_homepage,
123 bool is_google_in_startpages); 131 bool is_google_in_startpages);
124 132
125 // Implementation called from RecordProductEvent() static method. 133 // Implementation called from RecordProductEvent() static method.
126 bool RecordProductEventImpl(rlz_lib::Product product, 134 bool RecordProductEventImpl(rlz_lib::Product product,
127 rlz_lib::AccessPoint point, 135 rlz_lib::AccessPoint point,
128 rlz_lib::Event event_id); 136 rlz_lib::Event event_id);
129 137
130 // Records FIRST_SEARCH event. Called from Observe() on blocking task runner. 138 // Records FIRST_SEARCH event. Called from Observe() on blocking task runner.
131 void RecordFirstSearch(rlz_lib::AccessPoint point); 139 void RecordFirstSearch(rlz_lib::AccessPoint point);
132 140
133 // Implementation called from GetAccessPointRlz() static method. 141 // Implementation called from GetAccessPointRlz() static method.
134 bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, string16* rlz); 142 bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, string16* rlz);
135 143
136 // Schedules the delayed initialization. This method is virtual to allow 144 // Schedules the delayed initialization. This method is virtual to allow
137 // tests to override how the scheduling is done. 145 // tests to override how the scheduling is done.
138 virtual void ScheduleDelayedInit(int delay); 146 virtual void ScheduleDelayedInit(base::TimeDelta delay);
139 147
140 // Schedules a call to rlz_lib::RecordProductEvent(). This method is virtual 148 // Schedules a call to rlz_lib::RecordProductEvent(). This method is virtual
141 // to allow tests to override how the scheduling is done. 149 // to allow tests to override how the scheduling is done.
142 virtual bool ScheduleRecordProductEvent(rlz_lib::Product product, 150 virtual bool ScheduleRecordProductEvent(rlz_lib::Product product,
143 rlz_lib::AccessPoint point, 151 rlz_lib::AccessPoint point,
144 rlz_lib::Event event_id); 152 rlz_lib::Event event_id);
145 153
146 // Schedules a call to rlz_lib::RecordFirstSearch(). This method is virtual 154 // Schedules a call to rlz_lib::RecordFirstSearch(). This method is virtual
147 // to allow tests to override how the scheduling is done. 155 // to allow tests to override how the scheduling is done.
148 virtual bool ScheduleRecordFirstSearch(rlz_lib::AccessPoint point); 156 virtual bool ScheduleRecordFirstSearch(rlz_lib::AccessPoint point);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 bool omnibox_used_; 203 bool omnibox_used_;
196 bool homepage_used_; 204 bool homepage_used_;
197 205
198 // Main and (optionally) reactivation brand codes, assigned on UI thread. 206 // Main and (optionally) reactivation brand codes, assigned on UI thread.
199 std::string brand_; 207 std::string brand_;
200 std::string reactivation_brand_; 208 std::string reactivation_brand_;
201 209
202 content::NotificationRegistrar registrar_; 210 content::NotificationRegistrar registrar_;
203 211
204 // Minimum delay before sending financial ping after initialization. 212 // Minimum delay before sending financial ping after initialization.
205 int min_delay_; 213 base::TimeDelta min_init_delay_;
206 214
207 DISALLOW_COPY_AND_ASSIGN(RLZTracker); 215 DISALLOW_COPY_AND_ASSIGN(RLZTracker);
208 }; 216 };
209 217
210 #endif // defined(ENABLE_RLZ) 218 #endif // defined(ENABLE_RLZ)
211 219
212 #endif // CHROME_BROWSER_RLZ_RLZ_H_ 220 #endif // CHROME_BROWSER_RLZ_RLZ_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/test_login_utils.cc ('k') | chrome/browser/rlz/rlz.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698