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

Side by Side Diff: components/omnibox/browser/omnibox_event_global_tracker.h

Issue 1278433002: Eliminate OmniboxMetricsProvider listening to notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@componentize_omnibox
Patch Set: Rebase Created 5 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 IOS_CHROME_BROWSER_OMNIBOX_OMNIBOX_EVENT_GLOBAL_TRACKER_H_ 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EVENT_GLOBAL_TRACKER_H_
6 #define IOS_CHROME_BROWSER_OMNIBOX_OMNIBOX_EVENT_GLOBAL_TRACKER_H_ 6 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EVENT_GLOBAL_TRACKER_H_
7 7
8 #include "base/callback_list.h" 8 #include "base/callback_list.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 11
12 template <typename T> 12 template <typename T>
13 struct DefaultSingletonTraits; 13 struct DefaultSingletonTraits;
14 14
15 struct OmniboxLog; 15 struct OmniboxLog;
16 16
17 // Omnibox code tracks events on a per-BrowserState basis, but there are 17 // Omnibox code tracks events on a per-user-context basis, but there are
18 // several clients who need to observe these events for all BrowserStates. 18 // several clients who need to observe these events for all user contexts
19 // This class serves as an intermediary to bridge the gap: omnibox code calls 19 // (e.g., all Profiles in the //chrome embedder). This class serves as an
20 // the OmniboxEventGlobalTracker singleton on an event of interest, and it 20 // intermediary to bridge the gap: omnibox code calls the
21 // then forwards the event to its registered observers. 21 // OmniboxEventGlobalTracker singleton on an event of interest, and it then
22 // forwards the event to its registered observers.
22 class OmniboxEventGlobalTracker { 23 class OmniboxEventGlobalTracker {
23 public: 24 public:
24 typedef base::Callback<void(OmniboxLog*)> OnURLOpenedCallback; 25 typedef base::Callback<void(OmniboxLog*)> OnURLOpenedCallback;
25 26
26 // Returns the instance of OmniboxEventGlobalTracker. 27 // Returns the instance of OmniboxEventGlobalTracker.
27 static OmniboxEventGlobalTracker* GetInstance(); 28 static OmniboxEventGlobalTracker* GetInstance();
28 29
29 // Registers |cb| to be invoked when user open an URL from the omnibox. 30 // Registers |cb| to be invoked when user open an URL from the omnibox.
30 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> 31 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription>
31 RegisterCallback(const OnURLOpenedCallback& cb); 32 RegisterCallback(const OnURLOpenedCallback& cb);
32 33
33 // Called to notify all registered callbacks that an URL was opened from 34 // Called to notify all registered callbacks that an URL was opened from
34 // the omnibox. 35 // the omnibox.
35 void OnURLOpened(OmniboxLog* log); 36 void OnURLOpened(OmniboxLog* log);
36 37
37 private: 38 private:
38 friend struct DefaultSingletonTraits<OmniboxEventGlobalTracker>; 39 friend struct DefaultSingletonTraits<OmniboxEventGlobalTracker>;
39 40
40 OmniboxEventGlobalTracker(); 41 OmniboxEventGlobalTracker();
41 ~OmniboxEventGlobalTracker(); 42 ~OmniboxEventGlobalTracker();
42 43
43 base::CallbackList<void(OmniboxLog*)> on_url_opened_callback_list_; 44 base::CallbackList<void(OmniboxLog*)> on_url_opened_callback_list_;
44 45
45 DISALLOW_COPY_AND_ASSIGN(OmniboxEventGlobalTracker); 46 DISALLOW_COPY_AND_ASSIGN(OmniboxEventGlobalTracker);
46 }; 47 };
47 48
48 #endif // IOS_CHROME_BROWSER_OMNIBOX_OMNIBOX_EVENT_GLOBAL_TRACKER_H_ 49 #endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EVENT_GLOBAL_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698