OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.Object} | 7 * @extends {WebInspector.Object} |
8 * @param {!WebInspector.Workspace} workspace | 8 * @param {!WebInspector.Workspace} workspace |
9 * @param {!WebInspector.BreakpointManager} breakpointManager | 9 * @param {!WebInspector.BreakpointManager} breakpointManager |
10 * @param {!WebInspector.FileSystemMapping} fileSystemMapping | 10 * @param {!WebInspector.FileSystemMapping} fileSystemMapping |
(...skipping 20 matching lines...) Expand all Loading... |
31 BindingCreated: Symbol("BindingCreated"), | 31 BindingCreated: Symbol("BindingCreated"), |
32 BindingRemoved: Symbol("BindingRemoved") | 32 BindingRemoved: Symbol("BindingRemoved") |
33 }; | 33 }; |
34 | 34 |
35 WebInspector.Persistence.prototype = { | 35 WebInspector.Persistence.prototype = { |
36 /** | 36 /** |
37 * @param {!WebInspector.PersistenceBinding} binding | 37 * @param {!WebInspector.PersistenceBinding} binding |
38 */ | 38 */ |
39 _onBindingCreated: function(binding) | 39 _onBindingCreated: function(binding) |
40 { | 40 { |
41 if (binding.network.isDirty() || binding.fileSystem.isDirty()) { | 41 if (binding.network.isDirty()) { |
42 WebInspector.console.log(WebInspector.UIString("%s can not be persis
ted to file system due to unsaved changes.", binding.network.name())); | 42 WebInspector.console.log(WebInspector.UIString("%s can not be persis
ted to file system due to unsaved changes.", binding.network.name())); |
43 return; | 43 return; |
44 } | 44 } |
| 45 if (binding.fileSystem.isDirty()) |
| 46 binding.network.setWorkingCopy(binding.fileSystem.workingCopy()); |
| 47 |
45 binding.network[WebInspector.Persistence._binding] = binding; | 48 binding.network[WebInspector.Persistence._binding] = binding; |
46 binding.fileSystem[WebInspector.Persistence._binding] = binding; | 49 binding.fileSystem[WebInspector.Persistence._binding] = binding; |
47 | 50 |
48 binding.fileSystem.forceLoadOnCheckContent(); | 51 binding.fileSystem.forceLoadOnCheckContent(); |
49 | 52 |
50 binding.network.addEventListener(WebInspector.UISourceCode.Events.Workin
gCopyCommitted, this._onWorkingCopyCommitted, this); | 53 binding.network.addEventListener(WebInspector.UISourceCode.Events.Workin
gCopyCommitted, this._onWorkingCopyCommitted, this); |
51 binding.fileSystem.addEventListener(WebInspector.UISourceCode.Events.Wor
kingCopyCommitted, this._onWorkingCopyCommitted, this); | 54 binding.fileSystem.addEventListener(WebInspector.UISourceCode.Events.Wor
kingCopyCommitted, this._onWorkingCopyCommitted, this); |
52 | 55 |
53 this._addFilePathBindingPrefixes(binding.fileSystem.url()); | 56 this._addFilePathBindingPrefixes(binding.fileSystem.url()); |
54 | 57 |
55 this._moveBreakpoints(binding.fileSystem, binding.network); | 58 this._moveBreakpoints(binding.fileSystem, binding.network); |
56 this.dispatchEventToListeners(WebInspector.Persistence.Events.BindingCre
ated, binding); | 59 this.dispatchEventToListeners(WebInspector.Persistence.Events.BindingCre
ated, binding); |
57 }, | 60 }, |
58 | 61 |
59 /** | 62 /** |
60 * @param {!WebInspector.PersistenceBinding} binding | 63 * @param {!WebInspector.PersistenceBinding} binding |
61 */ | 64 */ |
62 _onBindingRemoved: function(binding) | 65 _onBindingRemoved: function(binding) |
63 { | 66 { |
| 67 if (binding.network.isDirty()) |
| 68 binding.fileSystem.setWorkingCopy(binding.network.workingCopy()); |
| 69 |
64 binding.network[WebInspector.Persistence._binding] = null; | 70 binding.network[WebInspector.Persistence._binding] = null; |
65 binding.fileSystem[WebInspector.Persistence._binding] = null; | 71 binding.fileSystem[WebInspector.Persistence._binding] = null; |
66 | 72 |
67 binding.network.removeEventListener(WebInspector.UISourceCode.Events.Wor
kingCopyCommitted, this._onWorkingCopyCommitted, this); | 73 binding.network.removeEventListener(WebInspector.UISourceCode.Events.Wor
kingCopyCommitted, this._onWorkingCopyCommitted, this); |
68 binding.fileSystem.removeEventListener(WebInspector.UISourceCode.Events.
WorkingCopyCommitted, this._onWorkingCopyCommitted, this); | 74 binding.fileSystem.removeEventListener(WebInspector.UISourceCode.Events.
WorkingCopyCommitted, this._onWorkingCopyCommitted, this); |
69 | 75 |
70 this._removeFilePathBindingPrefixes(binding.fileSystem.url()); | 76 this._removeFilePathBindingPrefixes(binding.fileSystem.url()); |
71 | 77 |
72 this._copyBreakpoints(binding.network, binding.fileSystem); | 78 this._copyBreakpoints(binding.network, binding.fileSystem); |
73 this.dispatchEventToListeners(WebInspector.Persistence.Events.BindingRem
oved, binding); | 79 this.dispatchEventToListeners(WebInspector.Persistence.Events.BindingRem
oved, binding); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 * @param {!WebInspector.UISourceCode} fileSystem | 242 * @param {!WebInspector.UISourceCode} fileSystem |
237 */ | 243 */ |
238 WebInspector.PersistenceBinding = function(network, fileSystem) | 244 WebInspector.PersistenceBinding = function(network, fileSystem) |
239 { | 245 { |
240 this.network = network; | 246 this.network = network; |
241 this.fileSystem = fileSystem; | 247 this.fileSystem = fileSystem; |
242 }; | 248 }; |
243 | 249 |
244 /** @type {!WebInspector.Persistence} */ | 250 /** @type {!WebInspector.Persistence} */ |
245 WebInspector.persistence; | 251 WebInspector.persistence; |
OLD | NEW |