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 and are sent to the Broker. | 6 // from the BHO and are sent to the Broker. |
7 | 7 |
8 #include "ceee/ie/plugin/bho/events_funnel.h" | 8 #include "ceee/ie/plugin/bho/events_funnel.h" |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "ceee/ie/common/ceee_module_util.h" | 13 #include "ceee/ie/common/ceee_module_util.h" |
14 | 14 |
15 | 15 |
16 EventsFunnel::EventsFunnel(bool keep_broker_alive) | 16 EventsFunnel::EventsFunnel(bool keep_broker_alive) |
Sigurður Ásgeirsson
2010/11/16 18:23:04
IMHO it would it simplify everything to keep an Rp
Vitaly Buka corp
2010/11/18 23:14:21
Done.
| |
17 : keep_broker_alive_(keep_broker_alive) { | 17 : keep_broker_alive_(keep_broker_alive) { |
18 if (keep_broker_alive_) | 18 if (keep_broker_alive_) |
19 ceee_module_util::AddRefModuleWorkerThread(); | 19 ceee_module_util::AddRefBroker(); |
20 } | 20 } |
21 | 21 |
22 EventsFunnel::~EventsFunnel() { | 22 EventsFunnel::~EventsFunnel() { |
23 if (keep_broker_alive_) | 23 if (keep_broker_alive_) |
24 ceee_module_util::ReleaseModuleWorkerThread(); | 24 ceee_module_util::ReleaseBroker(); |
25 } | 25 } |
26 | 26 |
27 HRESULT EventsFunnel::SendEvent(const char* event_name, | 27 HRESULT EventsFunnel::SendEvent(const char* event_name, |
28 const Value& event_args) { | 28 const Value& event_args) { |
29 // Event arguments for FireEventToBroker always need to be stored in a list. | 29 // Event arguments for FireEventToBroker always need to be stored in a list. |
30 std::string event_args_str; | 30 std::string event_args_str; |
31 if (event_args.IsType(Value::TYPE_LIST)) { | 31 if (event_args.IsType(Value::TYPE_LIST)) { |
32 base::JSONWriter::Write(&event_args, false, &event_args_str); | 32 base::JSONWriter::Write(&event_args, false, &event_args_str); |
33 } else { | 33 } else { |
34 ListValue list; | 34 ListValue list; |
35 list.Append(event_args.DeepCopy()); | 35 list.Append(event_args.DeepCopy()); |
36 base::JSONWriter::Write(&list, false, &event_args_str); | 36 base::JSONWriter::Write(&list, false, &event_args_str); |
37 } | 37 } |
38 | 38 |
39 EventsFunnel thread_locker(!keep_broker_alive_); | 39 EventsFunnel thread_locker(!keep_broker_alive_); |
40 ceee_module_util::FireEventToBroker(event_name, event_args_str); | 40 ceee_module_util::FireEventToBroker(event_name, event_args_str); |
41 return S_OK; | 41 return S_OK; |
42 } | 42 } |
OLD | NEW |