| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "extensions/renderer/api_event_handler.h" | 5 #include "extensions/renderer/api_event_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 context->GetIsolate(), emitter_iter->second.Get(context->GetIsolate()), | 209 context->GetIsolate(), emitter_iter->second.Get(context->GetIsolate()), |
| 210 &emitter); | 210 &emitter); |
| 211 CHECK(emitter); | 211 CHECK(emitter); |
| 212 | 212 |
| 213 if (emitter->GetNumListeners() == 0u) | 213 if (emitter->GetNumListeners() == 0u) |
| 214 return; | 214 return; |
| 215 | 215 |
| 216 // Note: since we only convert the arguments once, if a listener modifies an | 216 // Note: since we only convert the arguments once, if a listener modifies an |
| 217 // object (including an array), other listeners will see that modification. | 217 // object (including an array), other listeners will see that modification. |
| 218 // TODO(devlin): This is how it's always been, but should it be? | 218 // TODO(devlin): This is how it's always been, but should it be? |
| 219 std::unique_ptr<content::V8ValueConverter> converter( | 219 std::unique_ptr<content::V8ValueConverter> converter = |
| 220 content::V8ValueConverter::create()); | 220 content::V8ValueConverter::Create(); |
| 221 | 221 |
| 222 auto massager_iter = data->massagers.find(event_name); | 222 auto massager_iter = data->massagers.find(event_name); |
| 223 if (massager_iter == data->massagers.end()) { | 223 if (massager_iter == data->massagers.end()) { |
| 224 std::vector<v8::Local<v8::Value>> v8_args; | 224 std::vector<v8::Local<v8::Value>> v8_args; |
| 225 v8_args.reserve(args.GetSize()); | 225 v8_args.reserve(args.GetSize()); |
| 226 for (const auto& arg : args) | 226 for (const auto& arg : args) |
| 227 v8_args.push_back(converter->ToV8Value(&arg, context)); | 227 v8_args.push_back(converter->ToV8Value(&arg, context)); |
| 228 emitter->Fire(context, &v8_args, &filter); | 228 emitter->Fire(context, &v8_args, &filter); |
| 229 } else { | 229 } else { |
| 230 v8::Isolate* isolate = context->GetIsolate(); | 230 v8::Isolate* isolate = context->GetIsolate(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 auto iter = data->emitters.find(event_name); | 305 auto iter = data->emitters.find(event_name); |
| 306 DCHECK(iter != data->emitters.end()); | 306 DCHECK(iter != data->emitters.end()); |
| 307 EventEmitter* emitter = nullptr; | 307 EventEmitter* emitter = nullptr; |
| 308 gin::Converter<EventEmitter*>::FromV8( | 308 gin::Converter<EventEmitter*>::FromV8( |
| 309 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter); | 309 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter); |
| 310 CHECK(emitter); | 310 CHECK(emitter); |
| 311 return emitter->GetNumListeners(); | 311 return emitter->GetNumListeners(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace extensions | 314 } // namespace extensions |
| OLD | NEW |