| OLD | NEW |
| 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 CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 : public base::RefCountedThreadSafe<EventRouterForwarder> { | 30 : public base::RefCountedThreadSafe<EventRouterForwarder> { |
| 31 public: | 31 public: |
| 32 EventRouterForwarder(); | 32 EventRouterForwarder(); |
| 33 | 33 |
| 34 // Calls | 34 // Calls |
| 35 // DispatchEventToRenderers(event_name, event_args, profile, event_url) | 35 // DispatchEventToRenderers(event_name, event_args, profile, event_url) |
| 36 // on all (original) profiles' EventRouters. | 36 // on all (original) profiles' EventRouters. |
| 37 // May be called on any thread. | 37 // May be called on any thread. |
| 38 void BroadcastEventToRenderers(events::HistogramValue histogram_value, | 38 void BroadcastEventToRenderers(events::HistogramValue histogram_value, |
| 39 const std::string& event_name, | 39 const std::string& event_name, |
| 40 scoped_ptr<base::ListValue> event_args, | 40 std::unique_ptr<base::ListValue> event_args, |
| 41 const GURL& event_url); | 41 const GURL& event_url); |
| 42 | 42 |
| 43 // Calls | 43 // Calls |
| 44 // DispatchEventToExtension(extension_id, event_name, event_args, | 44 // DispatchEventToExtension(extension_id, event_name, event_args, |
| 45 // profile, event_url) | 45 // profile, event_url) |
| 46 // on all (original) profiles' EventRouters. | 46 // on all (original) profiles' EventRouters. |
| 47 // May be called on any thread. | 47 // May be called on any thread. |
| 48 void BroadcastEventToExtension(const std::string& extension_id, | 48 void BroadcastEventToExtension(const std::string& extension_id, |
| 49 events::HistogramValue histogram_value, | 49 events::HistogramValue histogram_value, |
| 50 const std::string& event_name, | 50 const std::string& event_name, |
| 51 scoped_ptr<base::ListValue> event_args, | 51 std::unique_ptr<base::ListValue> event_args, |
| 52 const GURL& event_url); | 52 const GURL& event_url); |
| 53 | 53 |
| 54 // Calls | 54 // Calls |
| 55 // DispatchEventToRenderers(event_name, event_args, | 55 // DispatchEventToRenderers(event_name, event_args, |
| 56 // use_profile_to_restrict_events ? profile : NULL, event_url) | 56 // use_profile_to_restrict_events ? profile : NULL, event_url) |
| 57 // on |profile|'s EventRouter. May be called on any thread. | 57 // on |profile|'s EventRouter. May be called on any thread. |
| 58 void DispatchEventToRenderers(events::HistogramValue histogram_value, | 58 void DispatchEventToRenderers(events::HistogramValue histogram_value, |
| 59 const std::string& event_name, | 59 const std::string& event_name, |
| 60 scoped_ptr<base::ListValue> event_args, | 60 std::unique_ptr<base::ListValue> event_args, |
| 61 void* profile, | 61 void* profile, |
| 62 bool use_profile_to_restrict_events, | 62 bool use_profile_to_restrict_events, |
| 63 const GURL& event_url); | 63 const GURL& event_url); |
| 64 | 64 |
| 65 // Calls | 65 // Calls |
| 66 // DispatchEventToExtension(extension_id, event_name, event_args, | 66 // DispatchEventToExtension(extension_id, event_name, event_args, |
| 67 // use_profile_to_restrict_events ? profile : NULL, event_url) | 67 // use_profile_to_restrict_events ? profile : NULL, event_url) |
| 68 // on |profile|'s EventRouter. May be called on any thread. | 68 // on |profile|'s EventRouter. May be called on any thread. |
| 69 void DispatchEventToExtension(const std::string& extension_id, | 69 void DispatchEventToExtension(const std::string& extension_id, |
| 70 events::HistogramValue histogram_value, | 70 events::HistogramValue histogram_value, |
| 71 const std::string& event_name, | 71 const std::string& event_name, |
| 72 scoped_ptr<base::ListValue> event_args, | 72 std::unique_ptr<base::ListValue> event_args, |
| 73 void* profile, | 73 void* profile, |
| 74 bool use_profile_to_restrict_events, | 74 bool use_profile_to_restrict_events, |
| 75 const GURL& event_url); | 75 const GURL& event_url); |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 // Protected for testing. | 78 // Protected for testing. |
| 79 virtual ~EventRouterForwarder(); | 79 virtual ~EventRouterForwarder(); |
| 80 | 80 |
| 81 // Helper function for {Broadcast,Dispatch}EventTo{Extension,Renderers}. | 81 // Helper function for {Broadcast,Dispatch}EventTo{Extension,Renderers}. |
| 82 // Virtual for testing. | 82 // Virtual for testing. |
| 83 virtual void HandleEvent(const std::string& extension_id, | 83 virtual void HandleEvent(const std::string& extension_id, |
| 84 events::HistogramValue histogram_value, | 84 events::HistogramValue histogram_value, |
| 85 const std::string& event_name, | 85 const std::string& event_name, |
| 86 scoped_ptr<base::ListValue> event_args, | 86 std::unique_ptr<base::ListValue> event_args, |
| 87 void* profile, | 87 void* profile, |
| 88 bool use_profile_to_restrict_events, | 88 bool use_profile_to_restrict_events, |
| 89 const GURL& event_url); | 89 const GURL& event_url); |
| 90 | 90 |
| 91 // Calls DispatchEventToRenderers or DispatchEventToExtension (depending on | 91 // Calls DispatchEventToRenderers or DispatchEventToExtension (depending on |
| 92 // whether extension_id == "" or not) of |profile|'s EventRouter. | 92 // whether extension_id == "" or not) of |profile|'s EventRouter. |
| 93 // |profile| may never be NULL. | 93 // |profile| may never be NULL. |
| 94 // Virtual for testing. | 94 // Virtual for testing. |
| 95 virtual void CallEventRouter(Profile* profile, | 95 virtual void CallEventRouter(Profile* profile, |
| 96 const std::string& extension_id, | 96 const std::string& extension_id, |
| 97 events::HistogramValue histogram_value, | 97 events::HistogramValue histogram_value, |
| 98 const std::string& event_name, | 98 const std::string& event_name, |
| 99 scoped_ptr<base::ListValue> event_args, | 99 std::unique_ptr<base::ListValue> event_args, |
| 100 Profile* restrict_to_profile, | 100 Profile* restrict_to_profile, |
| 101 const GURL& event_url); | 101 const GURL& event_url); |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 friend class base::RefCountedThreadSafe<EventRouterForwarder>; | 104 friend class base::RefCountedThreadSafe<EventRouterForwarder>; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(EventRouterForwarder); | 106 DISALLOW_COPY_AND_ASSIGN(EventRouterForwarder); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace extensions | 109 } // namespace extensions |
| 110 | 110 |
| 111 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_ | 111 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_ |
| OLD | NEW |