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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (!per_context_data) | 63 if (!per_context_data) |
64 return nullptr; | 64 return nullptr; |
65 auto* data = static_cast<APIEventPerContextData*>( | 65 auto* data = static_cast<APIEventPerContextData*>( |
66 per_context_data->GetUserData(kExtensionAPIEventPerContextKey)); | 66 per_context_data->GetUserData(kExtensionAPIEventPerContextKey)); |
67 | 67 |
68 if (!data && should_create) { | 68 if (!data && should_create) { |
69 auto api_data = | 69 auto api_data = |
70 base::MakeUnique<APIEventPerContextData>(context->GetIsolate()); | 70 base::MakeUnique<APIEventPerContextData>(context->GetIsolate()); |
71 data = api_data.get(); | 71 data = api_data.get(); |
72 per_context_data->SetUserData(kExtensionAPIEventPerContextKey, | 72 per_context_data->SetUserData(kExtensionAPIEventPerContextKey, |
73 api_data.release()); | 73 std::move(api_data)); |
74 } | 74 } |
75 | 75 |
76 return data; | 76 return data; |
77 } | 77 } |
78 | 78 |
79 void DispatchEvent(const v8::FunctionCallbackInfo<v8::Value>& info) { | 79 void DispatchEvent(const v8::FunctionCallbackInfo<v8::Value>& info) { |
80 v8::Isolate* isolate = info.GetIsolate(); | 80 v8::Isolate* isolate = info.GetIsolate(); |
81 v8::HandleScope handle_scope(isolate); | 81 v8::HandleScope handle_scope(isolate); |
82 if (info.Length() != 1 || !info[0]->IsArray()) { | 82 if (info.Length() != 1 || !info[0]->IsArray()) { |
83 NOTREACHED(); | 83 NOTREACHED(); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 auto iter = data->emitters.find(event_name); | 301 auto iter = data->emitters.find(event_name); |
302 DCHECK(iter != data->emitters.end()); | 302 DCHECK(iter != data->emitters.end()); |
303 EventEmitter* emitter = nullptr; | 303 EventEmitter* emitter = nullptr; |
304 gin::Converter<EventEmitter*>::FromV8( | 304 gin::Converter<EventEmitter*>::FromV8( |
305 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter); | 305 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter); |
306 CHECK(emitter); | 306 CHECK(emitter); |
307 return emitter->GetNumListeners(); | 307 return emitter->GetNumListeners(); |
308 } | 308 } |
309 | 309 |
310 } // namespace extensions | 310 } // namespace extensions |
OLD | NEW |