| Index: components/rlz/rlz_tracker.h
|
| diff --git a/chrome/browser/rlz/rlz.h b/components/rlz/rlz_tracker.h
|
| similarity index 87%
|
| rename from chrome/browser/rlz/rlz.h
|
| rename to components/rlz/rlz_tracker.h
|
| index 4fd9b9c79a5421c2afedfef42ddcaa435ab16fb4..b0808580c2c68b5e4d5e8f0f23e70c4cf5123c90 100644
|
| --- a/chrome/browser/rlz/rlz.h
|
| +++ b/components/rlz/rlz_tracker.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_RLZ_RLZ_H_
|
| -#define CHROME_BROWSER_RLZ_RLZ_H_
|
| +#ifndef COMPONENTS_RLZ_RLZ_TRACKER_H_
|
| +#define COMPONENTS_RLZ_RLZ_TRACKER_H_
|
|
|
| #include "build/build_config.h"
|
|
|
| @@ -13,19 +13,19 @@
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "base/memory/singleton.h"
|
| #include "base/strings/string16.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "base/time/time.h"
|
| -#include "content/public/browser/notification_observer.h"
|
| -#include "content/public/browser/notification_registrar.h"
|
| #include "rlz/lib/rlz_lib.h"
|
|
|
| -class Profile;
|
| namespace net {
|
| class URLRequestContextGetter;
|
| }
|
|
|
| +class RLZTrackerDelegate;
|
| +
|
| // RLZ is a library which is used to measure distribution scenarios.
|
| // Its job is to record certain lifetime events in the registry and to send
|
| // them encoded as a compact string at most twice. The sent data does
|
| @@ -36,8 +36,12 @@ class URLRequestContextGetter;
|
| // For partner or bundled installs, the RLZ might send more information
|
| // according to the terms disclosed in the EULA.
|
|
|
| -class RLZTracker : public content::NotificationObserver {
|
| +class RLZTracker {
|
| public:
|
| + // Sets the RLZTrackerDelegate that should be used by the global RLZTracker
|
| + // instance. Must be called before calling any other method of RLZTracker.
|
| + static void SetRlzDelegate(scoped_ptr<RLZTrackerDelegate> delegate);
|
| +
|
| // Initializes the RLZ library services for use in chrome. Schedules a delayed
|
| // task that performs the ping and registers some events when 'first-run' is
|
| // true.
|
| @@ -47,10 +51,12 @@ class RLZTracker : public content::NotificationObserver {
|
| // However, we only want this behaviour on first run.
|
| //
|
| // If the chrome brand is organic (no partners) then the pings don't occur.
|
| - static bool InitRlzFromProfileDelayed(Profile* profile,
|
| - bool first_run,
|
| - bool send_ping_immediately,
|
| - base::TimeDelta delay);
|
| + static bool InitRlzDelayed(bool first_run,
|
| + bool send_ping_immediately,
|
| + base::TimeDelta delay,
|
| + bool is_google_default_search,
|
| + bool is_google_homepage,
|
| + bool is_google_in_startpages);
|
|
|
| // Records an RLZ event. Some events can be access point independent.
|
| // Returns false it the event could not be recorded. Requires write access
|
| @@ -91,7 +97,7 @@ class RLZTracker : public content::NotificationObserver {
|
| // This method is public for use by the Singleton class.
|
| static RLZTracker* GetInstance();
|
|
|
| - // Enables zero delay for InitRlzFromProfileDelayed. For testing only.
|
| + // Enables zero delay for InitRlzDelayed. For testing only.
|
| static void EnableZeroDelayForTesting();
|
|
|
| #if !defined(OS_IOS)
|
| @@ -103,30 +109,15 @@ class RLZTracker : public content::NotificationObserver {
|
| // testing purposes. Production code should never need to call these.
|
| protected:
|
| RLZTracker();
|
| - ~RLZTracker() override;
|
| -
|
| - // Called by InitRlzFromProfileDelayed with values taken from |profile|.
|
| - static bool InitRlzDelayed(bool first_run,
|
| - bool send_ping_immediately,
|
| - base::TimeDelta delay,
|
| - bool is_google_default_search,
|
| - bool is_google_homepage,
|
| - bool is_google_in_startpages);
|
| + virtual ~RLZTracker();
|
|
|
| // Performs initialization of RLZ tracker that is purposefully delayed so
|
| // that it does not interfere with chrome startup time.
|
| virtual void DelayedInit();
|
|
|
| - // content::NotificationObserver implementation:
|
| - void Observe(int type,
|
| - const content::NotificationSource& source,
|
| - const content::NotificationDetails& details) override;
|
| -
|
| // Used by test code to override the default RLZTracker instance returned
|
| // by GetInstance().
|
| - void set_tracker(RLZTracker* tracker) {
|
| - tracker_ = tracker;
|
| - }
|
| + void set_tracker(RLZTracker* tracker) { tracker_ = tracker; }
|
|
|
| // Sends the financial ping to the RLZ servers and invalidates the RLZ string
|
| // cache since the response from the RLZ server may have changed then.
|
| @@ -137,20 +128,26 @@ class RLZTracker : public content::NotificationObserver {
|
| friend struct DefaultSingletonTraits<RLZTracker>;
|
| friend class base::RefCountedThreadSafe<RLZTracker>;
|
|
|
| + // Implementation called from SetRlzDelegate() static method.
|
| + void SetDelegate(scoped_ptr<RLZTrackerDelegate> delegate);
|
| +
|
| // Implementation called from InitRlzDelayed() static method.
|
| bool Init(bool first_run,
|
| bool send_ping_immediately,
|
| base::TimeDelta delay,
|
| - bool google_default_search,
|
| - bool google_default_homepage,
|
| + bool is_google_default_search,
|
| + bool is_google_homepage,
|
| bool is_google_in_startpages);
|
|
|
| + // Implementation called from CleanupRlz static method.
|
| + void Cleanup();
|
| +
|
| // Implementation called from RecordProductEvent() static method.
|
| bool RecordProductEventImpl(rlz_lib::Product product,
|
| rlz_lib::AccessPoint point,
|
| rlz_lib::Event event_id);
|
|
|
| - // Records FIRST_SEARCH event. Called from Observe() on blocking task runner.
|
| + // Records FIRST_SEARCH event. Passed as bound callback to RLZTrackerDelegate.
|
| void RecordFirstSearch(rlz_lib::AccessPoint point);
|
|
|
| // Implementation called from GetAccessPointRlz() static method.
|
| @@ -203,6 +200,9 @@ class RLZTracker : public content::NotificationObserver {
|
| // will be returned from GetInstance() instead of the regular singleton.
|
| static RLZTracker* tracker_;
|
|
|
| + // Delegate abstracting embedder specific knowledge. Must not be null.
|
| + scoped_ptr<RLZTrackerDelegate> delegate_;
|
| +
|
| // Configuation data for RLZ tracker. Set by call to Init().
|
| bool first_run_;
|
| bool send_ping_immediately_;
|
| @@ -233,8 +233,6 @@ class RLZTracker : public content::NotificationObserver {
|
| std::string brand_;
|
| std::string reactivation_brand_;
|
|
|
| - content::NotificationRegistrar registrar_;
|
| -
|
| // Minimum delay before sending financial ping after initialization.
|
| base::TimeDelta min_init_delay_;
|
|
|
| @@ -243,4 +241,4 @@ class RLZTracker : public content::NotificationObserver {
|
|
|
| #endif // defined(ENABLE_RLZ)
|
|
|
| -#endif // CHROME_BROWSER_RLZ_RLZ_H_
|
| +#endif // COMPONENTS_RLZ_RLZ_TRACKER_H_
|
|
|