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

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

Issue 2740143002: Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Comment Updates Created 3 years, 9 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
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // object (including an array), other listeners will see that modification. 150 // object (including an array), other listeners will see that modification.
151 // TODO(devlin): This is how it's always been, but should it be? 151 // TODO(devlin): This is how it's always been, but should it be?
152 std::unique_ptr<content::V8ValueConverter> converter( 152 std::unique_ptr<content::V8ValueConverter> converter(
153 content::V8ValueConverter::create()); 153 content::V8ValueConverter::create());
154 154
155 auto massager_iter = data->massagers.find(event_name); 155 auto massager_iter = data->massagers.find(event_name);
156 if (massager_iter == data->massagers.end()) { 156 if (massager_iter == data->massagers.end()) {
157 std::vector<v8::Local<v8::Value>> v8_args; 157 std::vector<v8::Local<v8::Value>> v8_args;
158 v8_args.reserve(args.GetSize()); 158 v8_args.reserve(args.GetSize());
159 for (const auto& arg : args) 159 for (const auto& arg : args)
160 v8_args.push_back(converter->ToV8Value(arg.get(), context)); 160 v8_args.push_back(converter->ToV8Value(&arg, context));
161 emitter->Fire(context, &v8_args); 161 emitter->Fire(context, &v8_args);
162 } else { 162 } else {
163 v8::Isolate* isolate = context->GetIsolate(); 163 v8::Isolate* isolate = context->GetIsolate();
164 v8::HandleScope handle_scope(isolate); 164 v8::HandleScope handle_scope(isolate);
165 v8::Local<v8::Function> massager = massager_iter->second.Get(isolate); 165 v8::Local<v8::Function> massager = massager_iter->second.Get(isolate);
166 v8::Local<v8::Value> v8_args = converter->ToV8Value(&args, context); 166 v8::Local<v8::Value> v8_args = converter->ToV8Value(&args, context);
167 DCHECK(!v8_args.IsEmpty()); 167 DCHECK(!v8_args.IsEmpty());
168 DCHECK(v8_args->IsArray()); 168 DCHECK(v8_args->IsArray());
169 169
170 // Curry in the native dispatch function. Some argument massagers take 170 // Curry in the native dispatch function. Some argument massagers take
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 auto iter = data->emitters.find(event_name); 232 auto iter = data->emitters.find(event_name);
233 DCHECK(iter != data->emitters.end()); 233 DCHECK(iter != data->emitters.end());
234 EventEmitter* emitter = nullptr; 234 EventEmitter* emitter = nullptr;
235 gin::Converter<EventEmitter*>::FromV8( 235 gin::Converter<EventEmitter*>::FromV8(
236 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter); 236 context->GetIsolate(), iter->second.Get(context->GetIsolate()), &emitter);
237 CHECK(emitter); 237 CHECK(emitter);
238 return emitter->listeners()->size(); 238 return emitter->listeners()->size();
239 } 239 }
240 240
241 } // namespace extensions 241 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698