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

Unified Diff: extensions/browser/extension_function_dispatcher.cc

Issue 2077723002: [Extensions] Short-circuit activity logging if not enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Test Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/event_router.cc ('k') | extensions/browser/extensions_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_function_dispatcher.cc
diff --git a/extensions/browser/extension_function_dispatcher.cc b/extensions/browser/extension_function_dispatcher.cc
index ff0b79a0eaea301b28c86c53c97a4a44b7f2c1bd..b944303ad7315f31102346a3060cbc4d2a5847ba 100644
--- a/extensions/browser/extension_function_dispatcher.cc
+++ b/extensions/browser/extension_function_dispatcher.cc
@@ -54,28 +54,10 @@ namespace {
// called. May be called from any thread.
void NotifyApiFunctionCalled(const std::string& extension_id,
const std::string& api_name,
- std::unique_ptr<base::ListValue> args,
+ const base::ListValue& args,
content::BrowserContext* browser_context) {
- // The ApiActivityMonitor can only be accessed from the main (UI) thread. If
- // we're running on the wrong thread, re-dispatch from the main thread.
- if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- BrowserThread::PostTask(BrowserThread::UI,
- FROM_HERE,
- base::Bind(&NotifyApiFunctionCalled,
- extension_id,
- api_name,
- base::Passed(&args),
- browser_context));
- return;
- }
- // The BrowserContext may become invalid after the task above is posted.
- if (!ExtensionsBrowserClient::Get()->IsValidContext(browser_context))
- return;
-
- ApiActivityMonitor* monitor =
- ExtensionsBrowserClient::Get()->GetApiActivityMonitor(browser_context);
- if (monitor)
- monitor->OnApiFunctionCalled(extension_id, api_name, std::move(args));
+ activity_monitor::OnApiFunctionCalled(browser_context, extension_id, api_name,
+ args);
}
// Separate copy of ExtensionAPI used for IO thread extension functions. We need
@@ -384,8 +366,7 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
&params.arguments,
base::TimeTicks::Now());
if (violation_error.empty()) {
- std::unique_ptr<base::ListValue> args(params.arguments.DeepCopy());
- NotifyApiFunctionCalled(extension->id(), params.name, std::move(args),
+ NotifyApiFunctionCalled(extension->id(), params.name, params.arguments,
static_cast<content::BrowserContext*>(profile_id));
UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls",
function->histogram_value());
@@ -525,11 +506,9 @@ void ExtensionFunctionDispatcher::DispatchWithCallbackInternal(
base::TimeTicks::Now());
if (violation_error.empty()) {
- std::unique_ptr<base::ListValue> args(params.arguments.DeepCopy());
-
// See crbug.com/39178.
ExtensionsBrowserClient::Get()->PermitExternalProtocolHandler();
- NotifyApiFunctionCalled(extension->id(), params.name, std::move(args),
+ NotifyApiFunctionCalled(extension->id(), params.name, params.arguments,
browser_context_);
UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls",
function->histogram_value());
« no previous file with comments | « extensions/browser/event_router.cc ('k') | extensions/browser/extensions_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698