[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / google / google_search_counter.h
blobbe60c6a891a9b0a98e3f284880c9e49066e578fa
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_
6 #define CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_
8 #include "base/memory/singleton.h"
9 #include "components/google/core/browser/google_search_metrics.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
13 // A listener for counting Google searches from various search access points. No
14 // actual search query content is observed. See GoogleSearchMetrics for more
15 // details about these access points.
16 class GoogleSearchCounter : content::NotificationObserver {
17 public:
18 // Initialize the global instance.
19 static void RegisterForNotifications();
21 // Return the singleton instance of GoogleSearchCounter.
22 static GoogleSearchCounter* GetInstance();
24 private:
25 friend struct DefaultSingletonTraits<GoogleSearchCounter>;
26 friend class GoogleSearchCounterTest;
28 GoogleSearchCounter();
29 virtual ~GoogleSearchCounter();
31 void ProcessCommittedEntry(const content::NotificationSource& source,
32 const content::NotificationDetails& details);
34 // Replace the internal metrics object with a dummy or a mock. This instance
35 // takes ownership of |search_metrics|.
36 void SetSearchMetricsForTesting(GoogleSearchMetrics* search_metrics);
38 // Register this counter for all notifications we care about.
39 void RegisterForNotificationsInternal();
41 // content::NotificationObserver
42 virtual void Observe(int type,
43 const content::NotificationSource& source,
44 const content::NotificationDetails& details) OVERRIDE;
46 content::NotificationRegistrar registrar_;
47 scoped_ptr<GoogleSearchMetrics> search_metrics_;
49 DISALLOW_COPY_AND_ASSIGN(GoogleSearchCounter);
52 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_COUNTER_H_