Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 | 12 |
| 13 class GURL; | |
| 13 class Profile; | 14 class Profile; |
| 14 | 15 |
| 15 // For now, this just forwards events from the IO thread to the | 16 // For now, this just forwards events from the IO thread to the |
| 16 // ExtensionEventRouter on the UI thread. | 17 // ExtensionEventRouter on the UI thread. |
| 17 // TODO(mpcomplete): eventually I want this to have its own copy of the event | 18 // TODO(mpcomplete): eventually I want this to have its own copy of the event |
| 18 // listeners so it can bypass the jump to the UI thread. | 19 // listeners so it can bypass the jump to the UI thread. |
| 19 class ExtensionIOEventRouter | 20 class ExtensionIOEventRouter |
| 20 : public base::RefCountedThreadSafe<ExtensionIOEventRouter> { | 21 : public base::RefCountedThreadSafe<ExtensionIOEventRouter> { |
| 21 public: | 22 public: |
| 22 explicit ExtensionIOEventRouter(Profile* profile); | 23 explicit ExtensionIOEventRouter(Profile* profile); |
| 23 ~ExtensionIOEventRouter(); | 24 ~ExtensionIOEventRouter(); |
| 24 | 25 |
| 25 void DestroyingProfile() { profile_ = NULL; } | 26 void DestroyingProfile() { profile_ = NULL; } |
| 26 | 27 |
| 27 // Dispatch the named event to every extension listening to that event. | 28 // Dispatch the named event to every extension listening to that event. |
| 28 void DispatchEventToExtension(const std::string& extension_id, | 29 void DispatchEventToExtension(const std::string& extension_id, |
| 29 const std::string& event_name, | 30 const std::string& event_name, |
| 30 const std::string& event_args) const; | 31 const std::string& event_args) const; |
| 31 | 32 |
| 33 // Same as above, except the event is send to all extensions that have | |
|
Bernhard Bauer
2011/02/22 13:13:53
Nit: "sent".
| |
| 34 // sufficient permissions. | |
| 35 void DispatchEventToRenderers(const std::string& event_name, | |
| 36 const std::string& event_args, | |
| 37 const GURL& event_url) const; | |
| 38 | |
| 32 private: | 39 private: |
| 33 void DispatchEventOnUIThread(const std::string& extension_id, | 40 void DispatchEventOnUIThread(const std::string& extension_id, |
| 34 const std::string& event_name, | 41 const std::string& event_name, |
| 35 const std::string& event_args) const; | 42 const std::string& event_args) const; |
| 36 | 43 |
| 44 void DispatchEventToRenderersOnUIThread( | |
| 45 const std::string& event_name, | |
| 46 const std::string& event_args, | |
| 47 const GURL& event_url) const; | |
| 48 | |
| 37 Profile* profile_; | 49 Profile* profile_; |
| 38 | 50 |
| 39 DISALLOW_COPY_AND_ASSIGN(ExtensionIOEventRouter); | 51 DISALLOW_COPY_AND_ASSIGN(ExtensionIOEventRouter); |
| 40 }; | 52 }; |
| 41 | 53 |
| 42 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_ |
| OLD | NEW |