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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js

Issue 1422463007: DevTools: use inotify to pick changes on the filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 * @constructor 32 * @constructor
33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager 33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager
34 * @param {!WebInspector.Workspace} workspace 34 * @param {!WebInspector.Workspace} workspace
35 */ 35 */
36 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace) 36 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace)
37 { 37 {
38 this._isolatedFileSystemManager = isolatedFileSystemManager; 38 this._isolatedFileSystemManager = isolatedFileSystemManager;
39 this._workspace = workspace; 39 this._workspace = workspace;
40 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemAdded, this._fileSystemAdded, this); 40 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemAdded, this._fileSystemAdded, this);
41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this); 41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this);
42 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemFileChanged, this._fileSystemFileChanged, this);
42 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */ 43 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */
43 this._boundFileSystems = new Map(); 44 this._boundFileSystems = new Map();
44 45
45 /** @type {!Object.<number, function(!Array.<string>)>} */ 46 /** @type {!Object.<number, function(!Array.<string>)>} */
46 this._callbacks = {}; 47 this._callbacks = {};
47 /** @type {!Object.<number, !WebInspector.Progress>} */ 48 /** @type {!Object.<number, !WebInspector.Progress>} */
48 this._progresses = {}; 49 this._progresses = {};
49 50
50 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingTotalWorkCalculated, this._onIndexingTotalWorkCalculated, this); 51 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingTotalWorkCalculated, this._onIndexingTotalWorkCalculated, this);
51 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingWorked, this._onIndexingWorked, this); 52 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingWorked, this._onIndexingWorked, this);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 */ 92 */
92 _fileSystemRemoved: function(event) 93 _fileSystemRemoved: function(event)
93 { 94 {
94 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); 95 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data);
95 var boundFileSystem = this._boundFileSystems.get(fileSystem.normalizedPa th()); 96 var boundFileSystem = this._boundFileSystems.get(fileSystem.normalizedPa th());
96 boundFileSystem.dispose(); 97 boundFileSystem.dispose();
97 this._boundFileSystems.remove(fileSystem.normalizedPath()); 98 this._boundFileSystems.remove(fileSystem.normalizedPath());
98 }, 99 },
99 100
100 /** 101 /**
102 * @param {!WebInspector.Event} event
103 */
104 _fileSystemFileChanged: function(event)
105 {
106 var path = /** @type {string} */ (event.data);
107 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(path) ;
108 for (var key of this._boundFileSystems.keys()) {
109 if (!normalizedPath.startsWith(key))
110 continue;
111 this._boundFileSystems.get(key)._fileChanged(normalizedPath.substr(k ey.length + 1));
112 }
113 },
114
115 /**
101 * @param {string} projectId 116 * @param {string} projectId
102 * @return {string} 117 * @return {string}
103 */ 118 */
104 fileSystemPath: function(projectId) 119 fileSystemPath: function(projectId)
105 { 120 {
106 var fileSystemPath = projectId.substr("filesystem:".length); 121 var fileSystemPath = projectId.substr("filesystem:".length);
107 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(fileS ystemPath); 122 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(fileS ystemPath);
108 return projectId.substr("filesystem:".length); 123 return projectId.substr("filesystem:".length);
109 }, 124 },
110 125
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 { 241 {
227 WebInspector.Object.call(this); 242 WebInspector.Object.call(this);
228 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; 243 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding;
229 this._fileSystem = isolatedFileSystem; 244 this._fileSystem = isolatedFileSystem;
230 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ "; 245 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ ";
231 this._fileSystemProjectURL = "filesystem:" + this._fileSystem.normalizedPath (); 246 this._fileSystemProjectURL = "filesystem:" + this._fileSystem.normalizedPath ();
232 this._workspace = workspace; 247 this._workspace = workspace;
233 248
234 this._projectId = WebInspector.FileSystemWorkspaceBinding.projectId(this._fi leSystem.path()); 249 this._projectId = WebInspector.FileSystemWorkspaceBinding.projectId(this._fi leSystem.path());
235 console.assert(!this._workspace.project(this._projectId)); 250 console.assert(!this._workspace.project(this._projectId));
236 this._workspace.addProject(this._projectId, this); 251 this._project = this._workspace.addProject(this._projectId, this);
237 this.populate(); 252 this.populate();
238 } 253 }
239 254
240 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { 255 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
241 /** 256 /**
242 * @override 257 * @override
243 * @return {string} 258 * @return {string}
244 */ 259 */
245 type: function() 260 type: function()
246 { 261 {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 }, 625 },
611 626
612 /** 627 /**
613 * @param {string} path 628 * @param {string} path
614 */ 629 */
615 _removeFile: function(path) 630 _removeFile: function(path)
616 { 631 {
617 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRe moved, path); 632 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRe moved, path);
618 }, 633 },
619 634
635 /**
636 * @param {string} path
637 */
638 _fileChanged: function(path)
639 {
640 var uiSourceCode = this._project.uiSourceCode(path);
641 if (!uiSourceCode) {
642 this._addFile(path);
643 return;
644 }
645 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileCh anged, path);
646 },
647
620 dispose: function() 648 dispose: function()
621 { 649 {
622 this._workspace.removeProject(this._projectId); 650 this._workspace.removeProject(this._projectId);
623 }, 651 },
624 652
625 __proto__: WebInspector.Object.prototype 653 __proto__: WebInspector.Object.prototype
626 } 654 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698