blob: 2d133fc67af184651d01d051fdfccbe0e8ab3b31 [file] [log] [blame]
[email protected]c11e6592014-06-27 17:07:341// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef EXTENSIONS_RENDERER_SCRIPTS_RUN_INFO_H_
6#define EXTENSIONS_RENDERER_SCRIPTS_RUN_INFO_H_
7
avi2d124c02015-12-23 06:36:428#include <stddef.h>
9
[email protected]c11e6592014-06-27 17:07:3410#include <map>
11#include <set>
12#include <string>
13
[email protected]c11e6592014-06-27 17:07:3414#include "base/macros.h"
15#include "base/timer/elapsed_timer.h"
16#include "extensions/common/user_script.h"
17
rdevlin.cronin3ae4a32012015-06-30 17:43:1918namespace content {
19class RenderFrame;
[email protected]c11e6592014-06-27 17:07:3420}
21
22namespace extensions {
23
24// A struct containing information about a script run.
25struct ScriptsRunInfo {
26 // Map of extensions IDs to the executing script paths.
27 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap;
28
rdevlin.cronin3ae4a32012015-06-30 17:43:1929 ScriptsRunInfo(content::RenderFrame* render_frame,
30 UserScript::RunLocation location);
[email protected]c11e6592014-06-27 17:07:3431 ~ScriptsRunInfo();
32
33 // The number of CSS scripts injected.
34 size_t num_css;
35 // The number of JS scripts injected.
36 size_t num_js;
kozyatinskiyc8bc9a582015-03-06 09:33:4137 // The number of blocked JS scripts injected.
38 size_t num_blocking_js;
[email protected]c11e6592014-06-27 17:07:3439 // A map of extension ids to executing script paths.
40 ExecutingScriptsMap executing_scripts;
catmullingsd4faad4f2016-09-08 19:55:3041 // A map of extension ids to injected stylesheet paths.
42 ExecutingScriptsMap injected_stylesheets;
[email protected]c11e6592014-06-27 17:07:3443 // The elapsed time since the ScriptsRunInfo was constructed.
44 base::ElapsedTimer timer;
45
rdevlin.cronin6fba7ec2016-06-24 16:15:0546 // Log information about a given script run. If |send_script_activity| is
47 // true, this also informs the browser of the script run.
48 void LogRun(bool send_script_activity);
[email protected]c11e6592014-06-27 17:07:3449
Kunihiko Sakamotocf8f3b582017-08-29 02:40:2150 static void LogLongInjectionTaskTime(UserScript::RunLocation run_location,
51 const base::TimeDelta& elapsed);
52
[email protected]c11e6592014-06-27 17:07:3453 private:
rdevlin.cronin3ae4a32012015-06-30 17:43:1954 // The routinig id to use to notify the browser of any injections. Since the
55 // frame may be deleted in injection, we don't hold on to a reference to it
56 // directly.
57 int routing_id_;
58
59 // The run location at which injection is happening.
60 UserScript::RunLocation run_location_;
61
62 // The url of the frame, preserved for the same reason as the routing id.
63 GURL frame_url_;
64
[email protected]c11e6592014-06-27 17:07:3465 DISALLOW_COPY_AND_ASSIGN(ScriptsRunInfo);
66};
67
68} // namespace extensions
69
70#endif // EXTENSIONS_RENDERER_SCRIPTS_RUN_INFO_H_