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

Side by Side Diff: chrome/browser/extensions/extension_event_router_forwarder.h

Issue 10696208: Move ExtensionEventRouter and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed bug + latest master Created 8 years, 5 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
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_FORWARDER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_FORWARDER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "content/public/browser/browser_thread.h"
14
15 class GURL;
16
17 // This class forwards events to ExtensionEventRouters.
18 // The advantages of this class over direct usage of ExtensionEventRouters are:
19 // - this class is thread-safe, you can call the functions from UI and IO
20 // thread.
21 // - the class can handle if a profile is deleted between the time of sending
22 // the event from the IO thread to the UI thread.
23 // - this class can be used in contexts that are not governed by a profile, e.g.
24 // by system URLRequestContexts. In these cases the |restrict_to_profile|
25 // parameter remains NULL and events are broadcasted to all profiles.
26 class ExtensionEventRouterForwarder
27 : public base::RefCountedThreadSafe<ExtensionEventRouterForwarder> {
28 public:
29 ExtensionEventRouterForwarder();
30
31 // Calls
32 // DispatchEventToRenderers(event_name, event_args, profile, event_url)
33 // on all (original) profiles' ExtensionEventRouters.
34 // May be called on any thread.
35 void BroadcastEventToRenderers(const std::string& event_name,
36 const std::string& event_args,
37 const GURL& event_url);
38
39 // Calls
40 // DispatchEventToExtension(extension_id, event_name, event_args,
41 // profile, event_url)
42 // on all (original) profiles' ExtensionEventRouters.
43 // May be called on any thread.
44 void BroadcastEventToExtension(const std::string& extension_id,
45 const std::string& event_name,
46 const std::string& event_args,
47 const GURL& event_url);
48
49 // Calls
50 // DispatchEventToRenderers(event_name, event_args,
51 // use_profile_to_restrict_events ? profile : NULL, event_url)
52 // on |profile|'s ExtensionEventRouter. May be called on any thread.
53 void DispatchEventToRenderers(const std::string& event_name,
54 const std::string& event_args,
55 void* profile,
56 bool use_profile_to_restrict_events,
57 const GURL& event_url);
58
59 // Calls
60 // DispatchEventToExtension(extension_id, event_name, event_args,
61 // use_profile_to_restrict_events ? profile : NULL, event_url)
62 // on |profile|'s ExtensionEventRouter. May be called on any thread.
63 void DispatchEventToExtension(const std::string& extension_id,
64 const std::string& event_name,
65 const std::string& event_args,
66 void* profile,
67 bool use_profile_to_restrict_events,
68 const GURL& event_url);
69
70 protected:
71 // Protected for testing.
72 virtual ~ExtensionEventRouterForwarder();
73
74 // Helper function for {Broadcast,Dispatch}EventTo{Extension,Renderers}.
75 // Virtual for testing.
76 virtual void HandleEvent(const std::string& extension_id,
77 const std::string& event_name,
78 const std::string& event_args,
79 void* profile,
80 bool use_profile_to_restrict_events,
81 const GURL& event_url);
82
83 // Calls DispatchEventToRenderers or DispatchEventToExtension (depending on
84 // whether extension_id == "" or not) of |profile|'s ExtensionEventRouter.
85 // |profile| may never be NULL.
86 // Virtual for testing.
87 virtual void CallExtensionEventRouter(Profile* profile,
88 const std::string& extension_id,
89 const std::string& event_name,
90 const std::string& event_args,
91 Profile* restrict_to_profile,
92 const GURL& event_url);
93
94 private:
95 friend class base::RefCountedThreadSafe<ExtensionEventRouterForwarder>;
96
97 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouterForwarder);
98 };
99
100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_FORWARDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_event_router.cc ('k') | chrome/browser/extensions/extension_event_router_forwarder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698