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

Side by Side Diff: extensions/browser/extension_function.cc

Issue 1939413002: [Extensions] Add coarse metrics for extension function performance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/extension_function.h" 5 #include "extensions/browser/extension_function.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/metrics/histogram_macros.h"
13 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
14 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
15 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
19 #include "extensions/browser/extension_function_dispatcher.h" 20 #include "extensions/browser/extension_function_dispatcher.h"
20 #include "extensions/browser/extension_message_filter.h" 21 #include "extensions/browser/extension_message_filter.h"
21 #include "extensions/common/error_utils.h" 22 #include "extensions/common/error_utils.h"
22 #include "extensions/common/extension_api.h" 23 #include "extensions/common/extension_api.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (bad_message_) { 400 if (bad_message_) {
400 type = BAD_MESSAGE; 401 type = BAD_MESSAGE;
401 LOG(ERROR) << "Bad extension message " << name_; 402 LOG(ERROR) << "Bad extension message " << name_;
402 } 403 }
403 404
404 // If results were never set, we send an empty argument list. 405 // If results were never set, we send an empty argument list.
405 if (!results_) 406 if (!results_)
406 results_.reset(new base::ListValue()); 407 results_.reset(new base::ListValue());
407 408
408 response_callback_.Run(type, *results_, GetError(), histogram_value()); 409 response_callback_.Run(type, *results_, GetError(), histogram_value());
410
411 // TODO(devlin): Once we have a baseline metric for how long functions take,
lazyboy 2016/05/03 01:00:01 Addition to the notes, I think referring to the bu
Devlin 2016/05/03 17:03:36 Done.
412 // we can create a handful of buckets and record the function name so that we
413 // can find what the fastest/slowest are.
414 // Note: Certain functions perform actions that are inherantly slow - such as
lazyboy 2016/05/03 01:00:01 nit: inherently
Devlin 2016/05/03 17:03:36 whoops, done.
415 // anything waiting on user action. As such, we can't always assume that a
416 // long execution time equates to a poorly-performing function.
417 UMA_HISTOGRAM_TIMES("Extensions.Functions.TotalExecutionTime",
lazyboy 2016/05/03 01:00:01 Should we also categorize based on |success|? I'd
Devlin 2016/05/03 17:03:36 Sounds reasonable. Done.
418 timer_.Elapsed());
409 } 419 }
410 420
411 void ExtensionFunction::OnRespondingLater(ResponseValue value) { 421 void ExtensionFunction::OnRespondingLater(ResponseValue value) {
412 SendResponse(value->Apply()); 422 SendResponse(value->Apply());
413 } 423 }
414 424
415 UIThreadExtensionFunction::UIThreadExtensionFunction() 425 UIThreadExtensionFunction::UIThreadExtensionFunction()
416 : context_(nullptr), 426 : context_(nullptr),
417 render_frame_host_(nullptr), 427 render_frame_host_(nullptr),
418 delegate_(nullptr) { 428 delegate_(nullptr) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { 569 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() {
560 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) 570 return RespondNow(RunSync() ? ArgumentList(std::move(results_))
561 : Error(error_)); 571 : Error(error_));
562 } 572 }
563 573
564 // static 574 // static
565 bool SyncIOThreadExtensionFunction::ValidationFailure( 575 bool SyncIOThreadExtensionFunction::ValidationFailure(
566 SyncIOThreadExtensionFunction* function) { 576 SyncIOThreadExtensionFunction* function) {
567 return false; 577 return false;
568 } 578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698