| 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_GOOGLE_GOOGLE_SEARCH_COUNTER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_ |
| 6 #define CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_ | 6 #define CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "components/google/core/browser/google_search_metrics.h" | 9 #include "components/google/core/browser/google_search_metrics.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Returns true if |details| is valid and corresponds to a search results | 34 // Returns true if |details| is valid and corresponds to a search results |
| 35 // page. | 35 // page. |
| 36 bool ShouldRecordCommittedDetails( | 36 bool ShouldRecordCommittedDetails( |
| 37 const content::NotificationDetails& details) const; | 37 const content::NotificationDetails& details) const; |
| 38 | 38 |
| 39 const GoogleSearchMetrics* search_metrics() const { | 39 const GoogleSearchMetrics* search_metrics() const { |
| 40 return search_metrics_.get(); | 40 return search_metrics_.get(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 friend struct DefaultSingletonTraits<GoogleSearchCounter>; | 44 friend struct base::DefaultSingletonTraits<GoogleSearchCounter>; |
| 45 friend class GoogleSearchCounterTest; | 45 friend class GoogleSearchCounterTest; |
| 46 friend class GoogleSearchCounterAndroidTest; | 46 friend class GoogleSearchCounterAndroidTest; |
| 47 | 47 |
| 48 GoogleSearchCounter(); | 48 GoogleSearchCounter(); |
| 49 ~GoogleSearchCounter() override; | 49 ~GoogleSearchCounter() override; |
| 50 | 50 |
| 51 void ProcessCommittedEntry(const content::NotificationSource& source, | 51 void ProcessCommittedEntry(const content::NotificationSource& source, |
| 52 const content::NotificationDetails& details); | 52 const content::NotificationDetails& details); |
| 53 | 53 |
| 54 // Replace the internal metrics object with a dummy or a mock. This instance | 54 // Replace the internal metrics object with a dummy or a mock. This instance |
| 55 // takes ownership of |search_metrics|. | 55 // takes ownership of |search_metrics|. |
| 56 void SetSearchMetricsForTesting(GoogleSearchMetrics* search_metrics); | 56 void SetSearchMetricsForTesting(GoogleSearchMetrics* search_metrics); |
| 57 | 57 |
| 58 // Register this counter for all notifications we care about. | 58 // Register this counter for all notifications we care about. |
| 59 void RegisterForNotificationsInternal(); | 59 void RegisterForNotificationsInternal(); |
| 60 | 60 |
| 61 // content::NotificationObserver | 61 // content::NotificationObserver |
| 62 void Observe(int type, | 62 void Observe(int type, |
| 63 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 64 const content::NotificationDetails& details) override; | 64 const content::NotificationDetails& details) override; |
| 65 | 65 |
| 66 content::NotificationRegistrar registrar_; | 66 content::NotificationRegistrar registrar_; |
| 67 scoped_ptr<GoogleSearchMetrics> search_metrics_; | 67 scoped_ptr<GoogleSearchMetrics> search_metrics_; |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(GoogleSearchCounter); | 69 DISALLOW_COPY_AND_ASSIGN(GoogleSearchCounter); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_ | 72 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_ |
| OLD | NEW |