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

Side by Side Diff: extensions/browser/event_router.h

Issue 823703004: Tracking push events for lucid sleep (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Version 2 with NotificationService Created 5 years, 11 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 (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 EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 5 #ifndef EXTENSIONS_BROWSER_EVENT_ROUTER_H_
6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // the base name of the event (e.g. adding an event listener for event name 64 // the base name of the event (e.g. adding an event listener for event name
65 // "foo.onBar/123" will trigger observers registered for "foo.onBar"). 65 // "foo.onBar/123" will trigger observers registered for "foo.onBar").
66 class Observer { 66 class Observer {
67 public: 67 public:
68 // Called when a listener is added. 68 // Called when a listener is added.
69 virtual void OnListenerAdded(const EventListenerInfo& details) {} 69 virtual void OnListenerAdded(const EventListenerInfo& details) {}
70 // Called when a listener is removed. 70 // Called when a listener is removed.
71 virtual void OnListenerRemoved(const EventListenerInfo& details) {} 71 virtual void OnListenerRemoved(const EventListenerInfo& details) {}
72 }; 72 };
73 73
74 // Struct that is sent along with a NOTIFICATION_EXTENSION_MESSAGE_DISPATCHED.
75 // |event_name_| is the name of the event being dispatched and |message_id_|
76 // is a unique identifier associated with the message sent to the extension
77 // renderer. |extension_id_| is the id of the extension that the message is
78 // being dispatched to.
79 struct DispatchDetails {
80 DispatchDetails(const std::string& extension_id,
81 const std::string& event_name,
82 int message_id);
83 ~DispatchDetails();
84
85 const std::string extension_id_;
86 const std::string event_name_;
87 const int message_id_;
88 };
89
74 // Gets the EventRouter for |browser_context|. 90 // Gets the EventRouter for |browser_context|.
75 // Shorthand for ExtensionSystem::Get(browser_context)->event_router(); it's 91 // Shorthand for ExtensionSystem::Get(browser_context)->event_router(); it's
76 // a very common operation. 92 // a very common operation.
77 static EventRouter* Get(content::BrowserContext* browser_context); 93 static EventRouter* Get(content::BrowserContext* browser_context);
78 94
79 // Converts event names like "foo.onBar/123" into "foo.onBar". Event names 95 // Converts event names like "foo.onBar/123" into "foo.onBar". Event names
80 // without a "/" are returned unchanged. 96 // without a "/" are returned unchanged.
81 static std::string GetBaseEventName(const std::string& full_event_name); 97 static std::string GetBaseEventName(const std::string& full_event_name);
82 98
83 // Sends an event via ipc_sender to the given extension. Can be called on any 99 // Sends an event via ipc_sender to the given extension. Can be called on any
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 const std::string event_name; 399 const std::string event_name;
384 400
385 const std::string extension_id; 401 const std::string extension_id;
386 const GURL listener_url; 402 const GURL listener_url;
387 content::BrowserContext* browser_context; 403 content::BrowserContext* browser_context;
388 }; 404 };
389 405
390 } // namespace extensions 406 } // namespace extensions
391 407
392 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 408 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698