| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 context->GetIsolate(), emitter_iter->second.Get(context->GetIsolate()), | 214 context->GetIsolate(), emitter_iter->second.Get(context->GetIsolate()), |
| 215 &emitter); | 215 &emitter); |
| 216 CHECK(emitter); | 216 CHECK(emitter); |
| 217 | 217 |
| 218 if (emitter->GetNumListeners() == 0u) | 218 if (emitter->GetNumListeners() == 0u) |
| 219 return; | 219 return; |
| 220 | 220 |
| 221 // Note: since we only convert the arguments once, if a listener modifies an | 221 // Note: since we only convert the arguments once, if a listener modifies an |
| 222 // object (including an array), other listeners will see that modification. | 222 // object (including an array), other listeners will see that modification. |
| 223 // TODO(devlin): This is how it's always been, but should it be? | 223 // TODO(devlin): This is how it's always been, but should it be? |
| 224 std::unique_ptr<content::V8ValueConverter> converter( | 224 std::unique_ptr<content::V8ValueConverter> converter = |
| 225 content::V8ValueConverter::create()); | 225 content::V8ValueConverter::Create(); |
| 226 | 226 |
| 227 auto massager_iter = data->massagers.find(event_name); | 227 auto massager_iter = data->massagers.find(event_name); |
| 228 if (massager_iter == data->massagers.end()) { | 228 if (massager_iter == data->massagers.end()) { |
| 229 std::vector<v8::Local<v8::Value>> v8_args; | 229 std::vector<v8::Local<v8::Value>> v8_args; |
| 230 v8_args.reserve(args.GetSize()); | 230 v8_args.reserve(args.GetSize()); |
| 231 for (const auto& arg : args) | 231 for (const auto& arg : args) |
| 232 v8_args.push_back(converter->ToV8Value(&arg, context)); | 232 v8_args.push_back(converter->ToV8Value(&arg, context)); |
| 233 emitter->Fire(context, &v8_args, &filter); | 233 emitter->Fire(context, &v8_args, &filter); |
| 234 } else { | 234 } else { |
| 235 v8::Isolate* isolate = context->GetIsolate(); | 235 v8::Isolate* isolate = context->GetIsolate(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 auto iter = data->emitters.find(event_name); | 326 auto iter = data->emitters.find(event_name); |
| 327 DCHECK(iter != data->emitters.end()); | 327 DCHECK(iter != data->emitters.end()); |
| 328 EventEmitter* emitter = nullptr; | 328 EventEmitter* emitter = nullptr; |
| 329 gin::Converter<EventEmitter*>::FromV8( | 329 gin::Converter<EventEmitter*>::FromV8( |
| 330 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter); | 330 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter); |
| 331 CHECK(emitter); | 331 CHECK(emitter); |
| 332 return emitter->GetNumListeners(); | 332 return emitter->GetNumListeners(); |
| 333 } | 333 } |
| 334 | 334 |
| 335 } // namespace extensions | 335 } // namespace extensions |
| OLD | NEW |