| 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" | 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 namespace net { | 23 namespace net { |
| 24 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
| 25 } | 25 } |
| 26 | 26 |
| 27 // RLZ is a library which is used to measure distribution scenarios. | 27 // 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 | 28 // Its job is to record certain lifetime events in the registry and to send |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 friend struct DefaultSingletonTraits<RLZTracker>; | 106 friend struct DefaultSingletonTraits<RLZTracker>; |
| 107 friend class base::RefCountedThreadSafe<RLZTracker>; | 107 friend class base::RefCountedThreadSafe<RLZTracker>; |
| 108 | 108 |
| 109 // Implementation called from InitRlzDelayed() static method. | 109 // Implementation called from InitRlzDelayed() static method. |
| 110 bool Init(bool first_run, | 110 bool Init(bool first_run, |
| 111 int delay, | 111 int delay, |
| 112 bool google_default_search, | 112 bool google_default_search, |
| 113 bool google_default_homepage, | 113 bool google_default_homepage, |
| 114 bool is_google_in_startpages); | 114 bool is_google_in_startpages); |
| 115 | 115 |
| 116 // Initializes task runners for tasks that access RlzValueStore and perform | |
| 117 // disk I/O. | |
| 118 virtual bool InitWorkers(); | |
| 119 | |
| 120 // Implementation called from RecordProductEvent() static method. | 116 // Implementation called from RecordProductEvent() static method. |
| 121 bool RecordProductEventImpl(rlz_lib::Product product, | 117 bool RecordProductEventImpl(rlz_lib::Product product, |
| 122 rlz_lib::AccessPoint point, | 118 rlz_lib::AccessPoint point, |
| 123 rlz_lib::Event event_id); | 119 rlz_lib::Event event_id); |
| 124 | 120 |
| 125 // Records FIRST_SEARCH event. Called from Observe() on blocking task runner. | 121 // Records FIRST_SEARCH event. Called from Observe() on blocking task runner. |
| 126 void RecordFirstSearch(rlz_lib::AccessPoint point); | 122 void RecordFirstSearch(rlz_lib::AccessPoint point); |
| 127 | 123 |
| 128 // Implementation called from GetAccessPointRlz() static method. | 124 // Implementation called from GetAccessPointRlz() static method. |
| 129 bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, string16* rlz); | 125 bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, string16* rlz); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // will be returned from GetInstance() instead of the regular singleton. | 158 // will be returned from GetInstance() instead of the regular singleton. |
| 163 static RLZTracker* tracker_; | 159 static RLZTracker* tracker_; |
| 164 | 160 |
| 165 // Configuation data for RLZ tracker. Set by call to Init(). | 161 // Configuation data for RLZ tracker. Set by call to Init(). |
| 166 bool first_run_; | 162 bool first_run_; |
| 167 bool send_ping_immediately_; | 163 bool send_ping_immediately_; |
| 168 bool is_google_default_search_; | 164 bool is_google_default_search_; |
| 169 bool is_google_homepage_; | 165 bool is_google_homepage_; |
| 170 bool is_google_in_startpages_; | 166 bool is_google_in_startpages_; |
| 171 | 167 |
| 172 // Dedicated RLZ thread for accessing RlzValueStore and doing I/O. | 168 // Unique sequence token so that tasks posted by RLZTracker are executed |
| 173 base::Thread rlz_thread_; | 169 // sequentially in the blocking pool. |
| 174 | 170 base::SequencedWorkerPool::SequenceToken worker_pool_token_; |
| 175 // Sequenced task runner used to post blocking tasks that access | |
| 176 // RlzValueStore. | |
| 177 base::SequencedTaskRunner* blocking_task_runner_; | |
| 178 | 171 |
| 179 // URLRequestContextGetter used by RLZ library. | 172 // URLRequestContextGetter used by RLZ library. |
| 180 net::URLRequestContextGetter* url_request_context_; | 173 net::URLRequestContextGetter* url_request_context_; |
| 181 | 174 |
| 182 // Keeps track if the RLZ tracker has already performed its delayed | 175 // Keeps track if the RLZ tracker has already performed its delayed |
| 183 // initialization. | 176 // initialization. |
| 184 bool already_ran_; | 177 bool already_ran_; |
| 185 | 178 |
| 186 // Keeps a cache of RLZ access point strings, since they rarely change. | 179 // 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 | 180 // 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. | 181 // the UI thread for reading and the IO thread for reading and/or writing. |
| 189 base::Lock cache_lock_; | 182 base::Lock cache_lock_; |
| 190 std::map<rlz_lib::AccessPoint, string16> rlz_cache_; | 183 std::map<rlz_lib::AccessPoint, string16> rlz_cache_; |
| 191 | 184 |
| 192 // Keeps track of whether the omnibox or host page have been used. | 185 // Keeps track of whether the omnibox or host page have been used. |
| 193 bool omnibox_used_; | 186 bool omnibox_used_; |
| 194 bool homepage_used_; | 187 bool homepage_used_; |
| 195 | 188 |
| 196 content::NotificationRegistrar registrar_; | 189 content::NotificationRegistrar registrar_; |
| 197 | 190 |
| 198 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 191 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
| 199 }; | 192 }; |
| 200 | 193 |
| 201 #endif // defined(ENABLE_RLZ) | 194 #endif // defined(ENABLE_RLZ) |
| 202 | 195 |
| 203 #endif // CHROME_BROWSER_RLZ_RLZ_H_ | 196 #endif // CHROME_BROWSER_RLZ_RLZ_H_ |
| OLD | NEW |