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

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

Issue 2102383002: [Extensions] Add metrics for API binding generation time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mark's Created 4 years, 5 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/module_system.h" 5 #include "extensions/renderer/module_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/metrics/histogram_macros.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/timer/elapsed_timer.h"
13 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
14 #include "content/public/renderer/render_frame.h" 16 #include "content/public/renderer/render_frame.h"
15 #include "content/public/renderer/render_view.h" 17 #include "content/public/renderer/render_view.h"
16 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
17 #include "extensions/common/extensions_client.h" 19 #include "extensions/common/extensions_client.h"
18 #include "extensions/renderer/console.h" 20 #include "extensions/renderer/console.h"
19 #include "extensions/renderer/safe_builtins.h" 21 #include "extensions/renderer/safe_builtins.h"
20 #include "extensions/renderer/script_context.h" 22 #include "extensions/renderer/script_context.h"
21 #include "extensions/renderer/script_context_set.h" 23 #include "extensions/renderer/script_context_set.h"
22 #include "extensions/renderer/v8_helpers.h" 24 #include "extensions/renderer/v8_helpers.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 v8::Local<v8::Name> property, 374 v8::Local<v8::Name> property,
373 const v8::PropertyCallbackInfo<v8::Value>& info) { 375 const v8::PropertyCallbackInfo<v8::Value>& info) {
374 LazyFieldGetterInner(property.As<v8::String>(), info, &ModuleSystem::Require); 376 LazyFieldGetterInner(property.As<v8::String>(), info, &ModuleSystem::Require);
375 } 377 }
376 378
377 // static 379 // static
378 void ModuleSystem::LazyFieldGetterInner( 380 void ModuleSystem::LazyFieldGetterInner(
379 v8::Local<v8::String> property, 381 v8::Local<v8::String> property,
380 const v8::PropertyCallbackInfo<v8::Value>& info, 382 const v8::PropertyCallbackInfo<v8::Value>& info,
381 RequireFunction require_function) { 383 RequireFunction require_function) {
384 base::ElapsedTimer timer;
382 CHECK(!info.Data().IsEmpty()); 385 CHECK(!info.Data().IsEmpty());
383 CHECK(info.Data()->IsObject()); 386 CHECK(info.Data()->IsObject());
384 v8::Isolate* isolate = info.GetIsolate(); 387 v8::Isolate* isolate = info.GetIsolate();
385 v8::HandleScope handle_scope(isolate); 388 v8::HandleScope handle_scope(isolate);
386 v8::Local<v8::Object> parameters = v8::Local<v8::Object>::Cast(info.Data()); 389 v8::Local<v8::Object> parameters = v8::Local<v8::Object>::Cast(info.Data());
387 // This context should be the same as context()->v8_context(). 390 // This context should be the same as context()->v8_context().
388 v8::Local<v8::Context> context = parameters->CreationContext(); 391 v8::Local<v8::Context> context = parameters->CreationContext();
389 v8::Local<v8::Object> global(context->Global()); 392 v8::Local<v8::Object> global(context->Global());
390 v8::Local<v8::Value> module_system_value; 393 v8::Local<v8::Value> module_system_value;
391 if (!GetPrivate(context, global, kModuleSystem, &module_system_value) || 394 if (!GetPrivate(context, global, kModuleSystem, &module_system_value) ||
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // returned every time a certain API is accessed. 456 // returned every time a certain API is accessed.
454 v8::Local<v8::Value> val = info.This(); 457 v8::Local<v8::Value> val = info.This();
455 if (val->IsObject()) { 458 if (val->IsObject()) {
456 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(val); 459 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(val);
457 object->Delete(context, property); 460 object->Delete(context, property);
458 SetProperty(context, object, property, new_field); 461 SetProperty(context, object, property, new_field);
459 } else { 462 } else {
460 NOTREACHED(); 463 NOTREACHED();
461 } 464 }
462 info.GetReturnValue().Set(new_field); 465 info.GetReturnValue().Set(new_field);
466
467 UMA_HISTOGRAM_TIMES("Extensions.ApiBindingGenerationTime", timer.Elapsed());
463 } 468 }
464 469
465 void ModuleSystem::SetLazyField(v8::Local<v8::Object> object, 470 void ModuleSystem::SetLazyField(v8::Local<v8::Object> object,
466 const std::string& field, 471 const std::string& field,
467 const std::string& module_name, 472 const std::string& module_name,
468 const std::string& module_field) { 473 const std::string& module_field) {
469 SetLazyField( 474 SetLazyField(
470 object, field, module_name, module_field, &ModuleSystem::LazyFieldGetter); 475 object, field, module_name, module_field, &ModuleSystem::LazyFieldGetter);
471 } 476 }
472 477
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 756
752 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { 757 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) {
753 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); 758 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name);
754 if (existing_handler != native_handler_map_.end()) { 759 if (existing_handler != native_handler_map_.end()) {
755 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); 760 clobbered_native_handlers_.push_back(std::move(existing_handler->second));
756 native_handler_map_.erase(existing_handler); 761 native_handler_map_.erase(existing_handler);
757 } 762 }
758 } 763 }
759 764
760 } // namespace extensions 765 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698