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 <string> | 10 #include <string> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/threading/sequenced_worker_pool.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 net { | 20 namespace net { |
21 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
22 } | 22 } |
23 | 23 |
24 namespace rlz { | 24 namespace rlz { |
25 | 25 |
26 class RLZTrackerDelegate; | 26 class RLZTrackerDelegate; |
27 | 27 |
28 // RLZ is a library which is used to measure distribution scenarios. | 28 // 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 | 29 // 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 | 30 // 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 | 31 // 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 | 32 // 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. | 33 // RLZ library which can be found at http://code.google.com/p/rlz. |
34 // | 34 // |
35 // For partner or bundled installs, the RLZ might send more information | 35 // For partner or bundled installs, the RLZ might send more information |
36 // according to the terms disclosed in the EULA. | 36 // according to the terms disclosed in the EULA. |
37 | 37 |
38 class RLZTracker { | 38 class RLZTracker { |
39 public: | 39 public: |
40 // Sets the RLZTrackerDelegate that should be used by the global RLZTracker | 40 // Sets the RLZTrackerDelegate that should be used by the global RLZTracker |
41 // instance. Must be called before calling any other method of RLZTracker. | 41 // instance. Must be called before calling any other method of RLZTracker. |
42 static void SetRlzDelegate(scoped_ptr<RLZTrackerDelegate> delegate); | 42 static void SetRlzDelegate(std::unique_ptr<RLZTrackerDelegate> delegate); |
43 | 43 |
44 // Initializes the RLZ library services for use in chrome. Schedules a delayed | 44 // Initializes the RLZ library services for use in chrome. Schedules a delayed |
45 // task that performs the ping and registers some events when 'first-run' is | 45 // task that performs the ping and registers some events when 'first-run' is |
46 // true. | 46 // true. |
47 // | 47 // |
48 // When |send_ping_immediately| is true, a financial ping should be sent | 48 // When |send_ping_immediately| is true, a financial ping should be sent |
49 // immediately after a first search is recorded, without waiting for |delay|. | 49 // immediately after a first search is recorded, without waiting for |delay|. |
50 // However, we only want this behaviour on first run. | 50 // However, we only want this behaviour on first run. |
51 // | 51 // |
52 // If the chrome brand is organic (no partners) then the pings don't occur. | 52 // If the chrome brand is organic (no partners) then the pings don't occur. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Sends the financial ping to the RLZ servers and invalidates the RLZ string | 121 // Sends the financial ping to the RLZ servers and invalidates the RLZ string |
122 // cache since the response from the RLZ server may have changed then. | 122 // cache since the response from the RLZ server may have changed then. |
123 // Protected so that its accessible from tests. | 123 // Protected so that its accessible from tests. |
124 void PingNowImpl(); | 124 void PingNowImpl(); |
125 | 125 |
126 private: | 126 private: |
127 friend struct base::DefaultSingletonTraits<RLZTracker>; | 127 friend struct base::DefaultSingletonTraits<RLZTracker>; |
128 friend class base::RefCountedThreadSafe<RLZTracker>; | 128 friend class base::RefCountedThreadSafe<RLZTracker>; |
129 | 129 |
130 // Implementation called from SetRlzDelegate() static method. | 130 // Implementation called from SetRlzDelegate() static method. |
131 void SetDelegate(scoped_ptr<RLZTrackerDelegate> delegate); | 131 void SetDelegate(std::unique_ptr<RLZTrackerDelegate> delegate); |
132 | 132 |
133 // Implementation called from InitRlzDelayed() static method. | 133 // Implementation called from InitRlzDelayed() static method. |
134 bool Init(bool first_run, | 134 bool Init(bool first_run, |
135 bool send_ping_immediately, | 135 bool send_ping_immediately, |
136 base::TimeDelta delay, | 136 base::TimeDelta delay, |
137 bool is_google_default_search, | 137 bool is_google_default_search, |
138 bool is_google_homepage, | 138 bool is_google_homepage, |
139 bool is_google_in_startpages); | 139 bool is_google_in_startpages); |
140 | 140 |
141 // Implementation called from CleanupRlz static method. | 141 // Implementation called from CleanupRlz static method. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 // Returns a pointer to the bool corresponding to whether |point| has been | 194 // Returns a pointer to the bool corresponding to whether |point| has been |
195 // used but not reported. | 195 // used but not reported. |
196 bool* GetAccessPointRecord(rlz_lib::AccessPoint point); | 196 bool* GetAccessPointRecord(rlz_lib::AccessPoint point); |
197 | 197 |
198 // Tracker used for testing purposes only. If this value is non-NULL, it | 198 // Tracker used for testing purposes only. If this value is non-NULL, it |
199 // will be returned from GetInstance() instead of the regular singleton. | 199 // will be returned from GetInstance() instead of the regular singleton. |
200 static RLZTracker* tracker_; | 200 static RLZTracker* tracker_; |
201 | 201 |
202 // Delegate abstracting embedder specific knowledge. Must not be null. | 202 // Delegate abstracting embedder specific knowledge. Must not be null. |
203 scoped_ptr<RLZTrackerDelegate> delegate_; | 203 std::unique_ptr<RLZTrackerDelegate> delegate_; |
204 | 204 |
205 // Configuation data for RLZ tracker. Set by call to Init(). | 205 // Configuation data for RLZ tracker. Set by call to Init(). |
206 bool first_run_; | 206 bool first_run_; |
207 bool send_ping_immediately_; | 207 bool send_ping_immediately_; |
208 bool is_google_default_search_; | 208 bool is_google_default_search_; |
209 bool is_google_homepage_; | 209 bool is_google_homepage_; |
210 bool is_google_in_startpages_; | 210 bool is_google_in_startpages_; |
211 | 211 |
212 // Unique sequence token so that tasks posted by RLZTracker are executed | 212 // Unique sequence token so that tasks posted by RLZTracker are executed |
213 // sequentially in the blocking pool. | 213 // sequentially in the blocking pool. |
(...skipping 20 matching lines...) Expand all Loading... |
234 | 234 |
235 // Minimum delay before sending financial ping after initialization. | 235 // Minimum delay before sending financial ping after initialization. |
236 base::TimeDelta min_init_delay_; | 236 base::TimeDelta min_init_delay_; |
237 | 237 |
238 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 238 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
239 }; | 239 }; |
240 | 240 |
241 } // namespace rlz | 241 } // namespace rlz |
242 | 242 |
243 #endif // COMPONENTS_RLZ_RLZ_TRACKER_H_ | 243 #endif // COMPONENTS_RLZ_RLZ_TRACKER_H_ |
OLD | NEW |