Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: extensions/renderer/api_event_handler.cc

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/api_request_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // object (including an array), other listeners will see that modification. 213 // object (including an array), other listeners will see that modification.
214 // TODO(devlin): This is how it's always been, but should it be? 214 // TODO(devlin): This is how it's always been, but should it be?
215 std::unique_ptr<content::V8ValueConverter> converter( 215 std::unique_ptr<content::V8ValueConverter> converter(
216 content::V8ValueConverter::create()); 216 content::V8ValueConverter::create());
217 217
218 auto massager_iter = data->massagers.find(event_name); 218 auto massager_iter = data->massagers.find(event_name);
219 if (massager_iter == data->massagers.end()) { 219 if (massager_iter == data->massagers.end()) {
220 std::vector<v8::Local<v8::Value>> v8_args; 220 std::vector<v8::Local<v8::Value>> v8_args;
221 v8_args.reserve(args.GetSize()); 221 v8_args.reserve(args.GetSize());
222 for (const auto& arg : args) 222 for (const auto& arg : args)
223 v8_args.push_back(converter->ToV8Value(&arg, context)); 223 v8_args.push_back(converter->ToV8Value(arg.get(), context));
224 emitter->Fire(context, &v8_args, &filter); 224 emitter->Fire(context, &v8_args, &filter);
225 } else { 225 } else {
226 v8::Isolate* isolate = context->GetIsolate(); 226 v8::Isolate* isolate = context->GetIsolate();
227 v8::HandleScope handle_scope(isolate); 227 v8::HandleScope handle_scope(isolate);
228 v8::Local<v8::Function> massager = massager_iter->second.Get(isolate); 228 v8::Local<v8::Function> massager = massager_iter->second.Get(isolate);
229 v8::Local<v8::Value> v8_args = converter->ToV8Value(&args, context); 229 v8::Local<v8::Value> v8_args = converter->ToV8Value(&args, context);
230 DCHECK(!v8_args.IsEmpty()); 230 DCHECK(!v8_args.IsEmpty());
231 DCHECK(v8_args->IsArray()); 231 DCHECK(v8_args->IsArray());
232 232
233 // Curry in the native dispatch function. Some argument massagers take 233 // Curry in the native dispatch function. Some argument massagers take
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/api_request_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698