[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef EXTENSIONS_RENDERER_SCRIPTS_RUN_INFO_H_ |
| 6 | #define EXTENSIONS_RENDERER_SCRIPTS_RUN_INFO_H_ |
| 7 | |
avi | 2d124c0 | 2015-12-23 06:36:42 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | |
[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 10 | #include <map> |
| 11 | #include <set> |
| 12 | #include <string> |
| 13 | |
[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 14 | #include "base/macros.h" |
| 15 | #include "base/timer/elapsed_timer.h" |
| 16 | #include "extensions/common/user_script.h" |
| 17 | |
rdevlin.cronin | 3ae4a3201 | 2015-06-30 17:43:19 | [diff] [blame] | 18 | namespace content { |
| 19 | class RenderFrame; |
[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | namespace extensions { |
| 23 | |
| 24 | // A struct containing information about a script run. |
| 25 | struct ScriptsRunInfo { |
| 26 | // Map of extensions IDs to the executing script paths. |
| 27 | typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap; |
| 28 | |
rdevlin.cronin | 3ae4a3201 | 2015-06-30 17:43:19 | [diff] [blame] | 29 | ScriptsRunInfo(content::RenderFrame* render_frame, |
| 30 | UserScript::RunLocation location); |
[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 31 | ~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; |
kozyatinskiy | c8bc9a58 | 2015-03-06 09:33:41 | [diff] [blame] | 37 | // The number of blocked JS scripts injected. |
| 38 | size_t num_blocking_js; |
[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 39 | // A map of extension ids to executing script paths. |
| 40 | ExecutingScriptsMap executing_scripts; |
catmullings | d4faad4f | 2016-09-08 19:55:30 | [diff] [blame] | 41 | // A map of extension ids to injected stylesheet paths. |
| 42 | ExecutingScriptsMap injected_stylesheets; |
[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 43 | // The elapsed time since the ScriptsRunInfo was constructed. |
| 44 | base::ElapsedTimer timer; |
| 45 | |
rdevlin.cronin | 6fba7ec | 2016-06-24 16:15:05 | [diff] [blame] | 46 | // 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] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 49 | |
Kunihiko Sakamoto | cf8f3b58 | 2017-08-29 02:40:21 | [diff] [blame] | 50 | static void LogLongInjectionTaskTime(UserScript::RunLocation run_location, |
| 51 | const base::TimeDelta& elapsed); |
| 52 | |
[email protected] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 53 | private: |
rdevlin.cronin | 3ae4a3201 | 2015-06-30 17:43:19 | [diff] [blame] | 54 | // 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] | c11e659 | 2014-06-27 17:07:34 | [diff] [blame] | 65 | DISALLOW_COPY_AND_ASSIGN(ScriptsRunInfo); |
| 66 | }; |
| 67 | |
| 68 | } // namespace extensions |
| 69 | |
| 70 | #endif // EXTENSIONS_RENDERER_SCRIPTS_RUN_INFO_H_ |