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

Side by Side Diff: Source/devtools/front_end/sdk/DebuggerScriptMapping.js

Issue 299443016: DevTools: Decouple debugger model from UI entities (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge DebuggerScriptMapping into DebuggerWorkspaceBinding Created 6 years, 4 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /**
32 * @constructor
33 * @param {!WebInspector.DebuggerModel} debuggerModel
34 * @param {!WebInspector.Workspace} workspace
35 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding
36 */
37 WebInspector.DebuggerScriptMapping = function(debuggerModel, workspace, networkW orkspaceBinding)
38 {
39 this._defaultMapping = new WebInspector.DefaultScriptMapping(debuggerModel, workspace);
40 this._resourceMapping = new WebInspector.ResourceScriptMapping(debuggerModel , workspace);
41 this._compilerMapping = new WebInspector.CompilerScriptMapping(debuggerModel , workspace, networkWorkspaceBinding);
42
43 /** @type {!WebInspector.LiveEditSupport} */
44 this._liveEditSupport = new WebInspector.LiveEditSupport(debuggerModel.targe t(), WebInspector.workspace);
45
46 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScrip tSource, this._parsedScriptSource, this);
47 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToPar seScriptSource, this._parsedScriptSource, this);
48 }
49
50 WebInspector.DebuggerScriptMapping.prototype = {
51 /**
52 * @param {!WebInspector.Event} event
53 */
54 _parsedScriptSource: function(event)
55 {
56 var script = /** @type {!WebInspector.Script} */ (event.data);
57 this._defaultMapping.addScript(script);
58
59 if (script.isSnippet()) {
60 WebInspector.scriptSnippetModel.addScript(script);
61 return;
62 }
63
64 this._resourceMapping.addScript(script);
65
66 if (WebInspector.settings.jsSourceMapsEnabled.get())
67 this._compilerMapping.addScript(script);
68 },
69
70 dispose: function()
71 {
72 this._compilerMapping.dispose();
73 this._resourceMapping.dispose();
74 this._defaultMapping.dispose();
75 },
76
77 /**
78 * @return {!WebInspector.LiveEditSupport}
79 */
80 liveEditSupport: function()
81 {
82 return this._liveEditSupport;
83 }
84 }
85
86 /**
87 * @constructor
88 * @implements {WebInspector.TargetManager.Observer}
89 */
90 WebInspector.DebuggerScriptMapping.Registry = function()
91 {
92 /** @type {!Map.<!WebInspector.Target, !WebInspector.DebuggerScriptMapping>} */
93 this._targetToMapping = new Map();
94
95 WebInspector.targetManager.observeTargets(this);
96 }
97
98 WebInspector.DebuggerScriptMapping.Registry.prototype = {
99 /**
100 * @param {!WebInspector.Target} target
101 */
102 targetAdded: function(target)
103 {
104 var mapping = new WebInspector.DebuggerScriptMapping(target.debuggerMo del, WebInspector.workspace, WebInspector.networkWorkspaceBinding);
105 this._targetToMapping.put(target, mapping);
106 },
107
108 /**
109 * @param {!WebInspector.Target} target
110 */
111 targetRemoved: function(target)
112 {
113 var mapping = this._targetToMapping.remove(target);
114 mapping.dispose();
115 },
116
117 /**
118 * @param {?WebInspector.Target} target
119 * @return {?WebInspector.DebuggerScriptMapping}
120 */
121 instance: function(target)
122 {
123 if (!target)
124 return null;
125 return this._targetToMapping.get(target) || null;
126 }
127 }
128
129 WebInspector.DebuggerScriptMapping.registry = new WebInspector.DebuggerScriptMap ping.Registry();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698