| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // This method is public for use by the Singleton class. | 59 // This method is public for use by the Singleton class. |
| 60 static RLZTracker* GetInstance(); | 60 static RLZTracker* GetInstance(); |
| 61 | 61 |
| 62 // The following methods are made protected so that they can be used for | 62 // The following methods are made protected so that they can be used for |
| 63 // testing purposes. Production code should never need to call these. | 63 // testing purposes. Production code should never need to call these. |
| 64 protected: | 64 protected: |
| 65 RLZTracker(); | 65 RLZTracker(); |
| 66 ~RLZTracker(); | 66 ~RLZTracker(); |
| 67 | 67 |
| 68 // Thread function entry point, see ScheduleFinancialPing(). Assumes argument | |
| 69 // is a pointer to an RLZTracker. | |
| 70 static void _cdecl PingNow(void* tracker); | |
| 71 | |
| 72 // Performs initialization of RLZ tracker that is purposefully delayed so | 68 // Performs initialization of RLZ tracker that is purposefully delayed so |
| 73 // that it does not interfere with chrome startup time. | 69 // that it does not interfere with chrome startup time. |
| 74 virtual void DelayedInit(); | 70 virtual void DelayedInit(); |
| 75 | 71 |
| 76 // content::NotificationObserver implementation: | 72 // content::NotificationObserver implementation: |
| 77 virtual void Observe(int type, | 73 virtual void Observe(int type, |
| 78 const content::NotificationSource& source, | 74 const content::NotificationSource& source, |
| 79 const content::NotificationDetails& details) OVERRIDE; | 75 const content::NotificationDetails& details) OVERRIDE; |
| 80 | 76 |
| 81 // Used by test code to override the default RLZTracker instance returned | 77 // Used by test code to override the default RLZTracker instance returned |
| 82 // by GetInstance(). | 78 // by GetInstance(). |
| 83 void set_tracker(RLZTracker* tracker) { | 79 void set_tracker(RLZTracker* tracker) { |
| 84 tracker_ = tracker; | 80 tracker_ = tracker; |
| 85 } | 81 } |
| 86 | 82 |
| 83 // Sends the financial ping to the RLZ servers and invalidates the RLZ string |
| 84 // cache since the response from the RLZ server may have changed then. |
| 85 // Protected so that its accessible from tests. |
| 86 void PingNowImpl(); |
| 87 |
| 87 private: | 88 private: |
| 88 friend struct DefaultSingletonTraits<RLZTracker>; | 89 friend struct DefaultSingletonTraits<RLZTracker>; |
| 89 friend class base::RefCountedThreadSafe<RLZTracker>; | 90 friend class base::RefCountedThreadSafe<RLZTracker>; |
| 90 | 91 |
| 91 // Implementation called from InitRlzDelayed() static method. | 92 // Implementation called from InitRlzDelayed() static method. |
| 92 bool Init(bool first_run, int delay, bool google_default_search, | 93 bool Init(bool first_run, int delay, bool google_default_search, |
| 93 bool google_default_homepage); | 94 bool google_default_homepage); |
| 94 | 95 |
| 95 // Implementation called from RecordProductEvent() static method. | 96 // Implementation called from RecordProductEvent() static method. |
| 96 bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, string16* rlz); | 97 bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, string16* rlz); |
| 97 | 98 |
| 98 // Schedules the delayed initialization. This method is virtual to allow | 99 // Schedules the delayed initialization. This method is virtual to allow |
| 99 // tests to override how the scheduling is done. | 100 // tests to override how the scheduling is done. |
| 100 virtual void ScheduleDelayedInit(int delay); | 101 virtual void ScheduleDelayedInit(int delay); |
| 101 | 102 |
| 102 // Schedules a call to rlz_lib::SendFinancialPing(). This method is virtual | 103 // Schedules a call to rlz_lib::SendFinancialPing(). This method is virtual |
| 103 // to allow tests to override how the scheduling is done. | 104 // to allow tests to override how the scheduling is done. |
| 104 virtual void ScheduleFinancialPing(); | 105 virtual void ScheduleFinancialPing(); |
| 105 | 106 |
| 106 // Schedules a call to GetAccessPointRlz() on the I/O thread if the current | 107 // Schedules a call to GetAccessPointRlz() on the I/O thread if the current |
| 107 // thread is not already the I/O thread, otherwise does nothing. Returns | 108 // thread is not already the I/O thread, otherwise does nothing. Returns |
| 108 // true if the call was scheduled, and false otherwise. This method is | 109 // true if the call was scheduled, and false otherwise. This method is |
| 109 // virtual to allow tests to override how the scheduling is done. | 110 // virtual to allow tests to override how the scheduling is done. |
| 110 virtual bool ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point); | 111 virtual bool ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point); |
| 111 | 112 |
| 112 // Sends the financial ping to the RLZ servers and invalidates the RLZ string | |
| 113 // cache since the response from the RLZ server may have changed then. | |
| 114 void PingNowImpl(); | |
| 115 | |
| 116 // Sends the financial ping to the RLZ servers. This method is virtual to | 113 // Sends the financial ping to the RLZ servers. This method is virtual to |
| 117 // allow tests to override. | 114 // allow tests to override. |
| 118 virtual bool SendFinancialPing(const std::string& brand, | 115 virtual bool SendFinancialPing(const std::string& brand, |
| 119 const string16& lang, | 116 const string16& lang, |
| 120 const string16& referral); | 117 const string16& referral); |
| 121 | 118 |
| 122 // Tracker used for testing purposes only. If this value is non-NULL, it | 119 // Tracker used for testing purposes only. If this value is non-NULL, it |
| 123 // will be returned from GetInstance() instead of the regular singleton. | 120 // will be returned from GetInstance() instead of the regular singleton. |
| 124 static RLZTracker* tracker_; | 121 static RLZTracker* tracker_; |
| 125 | 122 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 bool homepage_used_; | 141 bool homepage_used_; |
| 145 | 142 |
| 146 content::NotificationRegistrar registrar_; | 143 content::NotificationRegistrar registrar_; |
| 147 | 144 |
| 148 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 145 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
| 149 }; | 146 }; |
| 150 | 147 |
| 151 #endif // defined(OS_WIN) | 148 #endif // defined(OS_WIN) |
| 152 | 149 |
| 153 #endif // CHROME_BROWSER_RLZ_RLZ_H_ | 150 #endif // CHROME_BROWSER_RLZ_RLZ_H_ |
| OLD | NEW |