Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: chrome/browser/google/google_search_counter.h

Issue 342053002: Add UMA metrics for Android Chrome Google Search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "content/public/browser/notification_registrar.h" 11 #include "content/public/browser/notification_registrar.h"
12 12
13 // A listener for counting Google searches from various search access points. No 13 // A listener for counting Google searches from various search access points. No
14 // actual search query content is observed. See GoogleSearchMetrics for more 14 // actual search query content is observed. See GoogleSearchMetrics for more
15 // details about these access points. 15 // details about these access points.
16 class GoogleSearchCounter : content::NotificationObserver { 16 class GoogleSearchCounter : content::NotificationObserver {
17 public: 17 public:
18 // Initialize the global instance. 18 // Initialize the global instance.
19 static void RegisterForNotifications(); 19 static void RegisterForNotifications();
20 20
21 // Return the singleton instance of GoogleSearchCounter. 21 // Return the singleton instance of GoogleSearchCounter.
22 static GoogleSearchCounter* GetInstance(); 22 static GoogleSearchCounter* GetInstance();
23 23
24 // Returns true if |details| is valid and corresponds to a search results
25 // page.
26 bool ShouldRecordCommittedDetails(
27 const content::NotificationDetails& details) const;
28
29 const GoogleSearchMetrics* search_metrics() const {
30 return search_metrics_.get();
31 }
32
24 private: 33 private:
25 friend struct DefaultSingletonTraits<GoogleSearchCounter>; 34 friend struct DefaultSingletonTraits<GoogleSearchCounter>;
26 friend class GoogleSearchCounterTest; 35 friend class GoogleSearchCounterTest;
27 36
28 GoogleSearchCounter(); 37 GoogleSearchCounter();
29 virtual ~GoogleSearchCounter(); 38 virtual ~GoogleSearchCounter();
30 39
31 void ProcessCommittedEntry(const content::NotificationSource& source, 40 void ProcessCommittedEntry(const content::NotificationSource& source,
32 const content::NotificationDetails& details); 41 const content::NotificationDetails& details);
33 42
34 // Replace the internal metrics object with a dummy or a mock. This instance 43 // Replace the internal metrics object with a dummy or a mock. This instance
35 // takes ownership of |search_metrics|. 44 // takes ownership of |search_metrics|.
36 void SetSearchMetricsForTesting(GoogleSearchMetrics* search_metrics); 45 void SetSearchMetricsForTesting(GoogleSearchMetrics* search_metrics);
37 46
38 // Register this counter for all notifications we care about. 47 // Register this counter for all notifications we care about.
39 void RegisterForNotificationsInternal(); 48 void RegisterForNotificationsInternal();
40 49
41 // content::NotificationObserver 50 // content::NotificationObserver
42 virtual void Observe(int type, 51 virtual void Observe(int type,
43 const content::NotificationSource& source, 52 const content::NotificationSource& source,
44 const content::NotificationDetails& details) OVERRIDE; 53 const content::NotificationDetails& details) OVERRIDE;
45 54
46 content::NotificationRegistrar registrar_; 55 content::NotificationRegistrar registrar_;
47 scoped_ptr<GoogleSearchMetrics> search_metrics_; 56 scoped_ptr<GoogleSearchMetrics> search_metrics_;
48 57
49 DISALLOW_COPY_AND_ASSIGN(GoogleSearchCounter); 58 DISALLOW_COPY_AND_ASSIGN(GoogleSearchCounter);
50 }; 59 };
51 60
52 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_ 61 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698