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

Side by Side Diff: chrome/renderer/extensions/user_script_slave.cc

Issue 12390076: Attaching a DOM Activity Logger to all extension scripts (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/extensions/user_script_scheduler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/user_script_slave.h" 5 #include "chrome/renderer/extensions/user_script_slave.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/perftimer.h" 12 #include "base/perftimer.h"
13 #include "base/pickle.h" 13 #include "base/pickle.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "chrome/common/extensions/csp_handler.h" 16 #include "chrome/common/extensions/csp_handler.h"
17 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_messages.h" 18 #include "chrome/common/extensions/extension_messages.h"
19 #include "chrome/common/extensions/extension_set.h" 19 #include "chrome/common/extensions/extension_set.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "chrome/renderer/chrome_render_process_observer.h" 21 #include "chrome/renderer/chrome_render_process_observer.h"
22 #include "chrome/renderer/extensions/dom_activity_logger.h"
22 #include "chrome/renderer/extensions/extension_groups.h" 23 #include "chrome/renderer/extensions/extension_groups.h"
23 #include "content/public/renderer/render_thread.h" 24 #include "content/public/renderer/render_thread.h"
24 #include "content/public/renderer/render_view.h" 25 #include "content/public/renderer/render_view.h"
25 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
26 #include "grit/renderer_resources.h" 27 #include "grit/renderer_resources.h"
27 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" 28 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
28 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" 29 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if (script->is_standalone() || script->emulate_greasemonkey()) { 327 if (script->is_standalone() || script->emulate_greasemonkey()) {
327 sources.insert(sources.begin(), 328 sources.insert(sources.begin(),
328 WebScriptSource(WebString::fromUTF8(api_js_.as_string()))); 329 WebScriptSource(WebString::fromUTF8(api_js_.as_string())));
329 } 330 }
330 331
331 // TODO(aa): Can extension_id() ever be empty anymore? 332 // TODO(aa): Can extension_id() ever be empty anymore?
332 if (!script->extension_id().empty()) 333 if (!script->extension_id().empty())
333 isolated_world_id = GetIsolatedWorldIdForExtension(extension, frame); 334 isolated_world_id = GetIsolatedWorldIdForExtension(extension, frame);
334 335
335 PerfTimer exec_timer; 336 PerfTimer exec_timer;
337 DOMActivityLogger::AttachToWorld(
338 isolated_world_id,
339 extension->id(),
340 UserScriptSlave::GetDataSourceURLForFrame(frame),
341 frame->document().title());
336 frame->executeScriptInIsolatedWorld( 342 frame->executeScriptInIsolatedWorld(
337 isolated_world_id, &sources.front(), sources.size(), 343 isolated_world_id, &sources.front(), sources.size(),
338 EXTENSION_GROUP_CONTENT_SCRIPTS); 344 EXTENSION_GROUP_CONTENT_SCRIPTS);
339 UMA_HISTOGRAM_TIMES("Extensions.InjectScriptTime", exec_timer.Elapsed()); 345 UMA_HISTOGRAM_TIMES("Extensions.InjectScriptTime", exec_timer.Elapsed());
340 346
341 for (std::vector<WebScriptSource>::const_iterator iter = sources.begin(); 347 for (std::vector<WebScriptSource>::const_iterator iter = sources.begin();
342 iter != sources.end(); ++iter) { 348 iter != sources.end(); ++iter) {
343 extensions_executing_scripts[extension->id()].insert( 349 extensions_executing_scripts[extension->id()].insert(
344 GURL(iter->url).path()); 350 GURL(iter->url).path());
345 } 351 }
(...skipping 25 matching lines...) Expand all
371 } else if (location == UserScript::DOCUMENT_IDLE) { 377 } else if (location == UserScript::DOCUMENT_IDLE) {
372 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); 378 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts);
373 if (num_scripts) 379 if (num_scripts)
374 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); 380 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed());
375 } else { 381 } else {
376 NOTREACHED(); 382 NOTREACHED();
377 } 383 }
378 } 384 }
379 385
380 } // namespace extensions 386 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/user_script_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698