OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Common base class for funnels of Chrome Extension events that originate | 5 // Common base class for funnels of Chrome Extension events that originate |
6 // from the BHO. | 6 // from the BHO. |
7 | 7 |
8 #ifndef CEEE_IE_PLUGIN_BHO_EVENTS_FUNNEL_H_ | 8 #ifndef CEEE_IE_PLUGIN_BHO_EVENTS_FUNNEL_H_ |
9 #define CEEE_IE_PLUGIN_BHO_EVENTS_FUNNEL_H_ | 9 #define CEEE_IE_PLUGIN_BHO_EVENTS_FUNNEL_H_ |
10 | 10 |
11 #include <windows.h> | 11 #include <windows.h> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/scoped_ptr.h" |
14 | 15 |
15 class Value; | 16 class Value; |
16 | 17 |
| 18 class BrokerRpcClient; |
| 19 |
17 // Defines a base class for sending events to the Broker. | 20 // Defines a base class for sending events to the Broker. |
18 class EventsFunnel { | 21 class EventsFunnel { |
19 protected: | 22 protected: |
20 // @param keep_broker_alive If true broker will be alive during | 23 EventsFunnel(); |
21 // lifetime of this funnel, otherwise only during SendEvent. | |
22 explicit EventsFunnel(bool keep_broker_alive); | |
23 virtual ~EventsFunnel(); | 24 virtual ~EventsFunnel(); |
24 | 25 |
25 // Send the given event to the Broker. | 26 // Send the given event to the Broker. |
26 // @param event_name The name of the event. | 27 // @param event_name The name of the event. |
27 // @param event_args The arguments to be sent with the event. | 28 // @param event_args The arguments to be sent with the event. |
28 // protected virtual for testability... | 29 // protected virtual for testability... |
29 virtual HRESULT SendEvent(const char* event_name, const Value& event_args); | 30 virtual HRESULT SendEvent(const char* event_name, const Value& event_args); |
30 | 31 |
| 32 protected: |
| 33 virtual HRESULT SendEventToBroker(const char* event_name, |
| 34 const char* event_args); |
| 35 |
31 private: | 36 private: |
32 // If true constructor/destructor of class increments/decrements ref counter | 37 // Pointer to broker client. If is not NULL attempt to connect was performed |
33 // of broker thread. Otherwise SendEvent does it for every event. | 38 // and new attempts are not nessesary. |
34 const bool keep_broker_alive_; | 39 scoped_ptr<BrokerRpcClient> broker_rpc_client_; |
35 DISALLOW_COPY_AND_ASSIGN(EventsFunnel); | 40 DISALLOW_COPY_AND_ASSIGN(EventsFunnel); |
36 }; | 41 }; |
37 | 42 |
38 #endif // CEEE_IE_PLUGIN_BHO_EVENTS_FUNNEL_H_ | 43 #endif // CEEE_IE_PLUGIN_BHO_EVENTS_FUNNEL_H_ |
OLD | NEW |