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

Side by Side Diff: chrome/renderer/resources/extensions/file_system_custom_bindings.js

Issue 12632004: Revert 186643 - Caused a 10% regression on SunSpider benchmark (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Custom binding for the fileSystem API. 5 // Custom bindings for the fileSystem API.
6 6
7 var binding = require('binding').Binding.create('fileSystem'); 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
8
9 var fileSystemNatives = requireNative('file_system_natives'); 8 var fileSystemNatives = requireNative('file_system_natives');
10 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; 9 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem;
11 var lastError = require('lastError'); 10 var lastError = require('lastError');
12 var entryIdManager = require('entryIdManager'); 11 var entryIdManager = require('entryIdManager');
13 12
14 binding.registerCustomHook(function(bindingsAPI) { 13 chromeHidden.registerCustomHook('fileSystem', function(bindingsAPI) {
15 var apiFunctions = bindingsAPI.apiFunctions; 14 var apiFunctions = bindingsAPI.apiFunctions;
16 var fileSystem = bindingsAPI.compiledApi;
17
18 function bindFileEntryFunction(functionName) { 15 function bindFileEntryFunction(functionName) {
19 apiFunctions.setUpdateArgumentsPostValidate( 16 apiFunctions.setUpdateArgumentsPostValidate(
20 functionName, function(fileEntry, callback) { 17 functionName, function(fileEntry, callback) {
21 var fileSystemName = fileEntry.filesystem.name; 18 var fileSystemName = fileEntry.filesystem.name;
22 var relativePath = fileEntry.fullPath.slice(1); 19 var relativePath = fileEntry.fullPath.slice(1);
23 return [fileSystemName, relativePath, callback]; 20 return [fileSystemName, relativePath, callback];
24 }); 21 });
25 } 22 }
26 ['getDisplayPath', 'getWritableEntry', 'isWritableEntry'] 23 ['getDisplayPath', 'getWritableEntry', 'isWritableEntry']
27 .forEach(bindFileEntryFunction); 24 .forEach(bindFileEntryFunction);
(...skipping 12 matching lines...) Expand all
40 var fs = GetIsolatedFileSystem(fileSystemId); 37 var fs = GetIsolatedFileSystem(fileSystemId);
41 38
42 try { 39 try {
43 // TODO(koz): fs.root.getFile() makes a trip to the browser process, 40 // TODO(koz): fs.root.getFile() makes a trip to the browser process,
44 // but it might be possible avoid that by calling 41 // but it might be possible avoid that by calling
45 // WebFrame::createFileEntry(). 42 // WebFrame::createFileEntry().
46 fs.root.getFile(baseName, {}, function(fileEntry) { 43 fs.root.getFile(baseName, {}, function(fileEntry) {
47 entryIdManager.registerEntry(id, fileEntry); 44 entryIdManager.registerEntry(id, fileEntry);
48 callback(fileEntry); 45 callback(fileEntry);
49 }, function(fileError) { 46 }, function(fileError) {
50 lastError.run('Error getting fileEntry, code: ' + fileError.code, 47 lastError.set('Error getting fileEntry, code: ' + fileError.code);
51 callback); 48 callback();
52 }); 49 });
53 } catch (e) { 50 } catch (e) {
54 lastError.run('Error in event handler for onLaunched: ' + e.stack, 51 lastError.set('Error in event handler for onLaunched: ' + e.stack);
55 callback); 52 callback();
56 } 53 }
57 } 54 }
58 }); 55 });
59 } 56 }
60 ['getWritableEntry', 'chooseEntry'].forEach(bindFileEntryCallback); 57 ['getWritableEntry', 'chooseEntry'].forEach(bindFileEntryCallback);
61 58
62 apiFunctions.setHandleRequest('getEntryId', function(fileEntry) { 59 apiFunctions.setHandleRequest('getEntryId', function(fileEntry) {
63 return entryIdManager.getEntryId(fileEntry); 60 return entryIdManager.getEntryId(fileEntry);
64 }); 61 });
65 62
66 apiFunctions.setHandleRequest('getEntryById', function(id) { 63 apiFunctions.setHandleRequest('getEntryById', function(id) {
67 return entryIdManager.getEntryById(id); 64 return entryIdManager.getEntryById(id);
68 }); 65 });
69 66
70 // TODO(benwells): Remove these deprecated versions of the functions. 67 // TODO(benwells): Remove these deprecated versions of the functions.
71 fileSystem.getWritableFileEntry = function() { 68 chrome.fileSystem.getWritableFileEntry = function() {
72 console.log("chrome.fileSystem.getWritableFileEntry is deprecated"); 69 console.log("chrome.fileSystem.getWritableFileEntry is deprecated");
73 console.log("Please use chrome.fileSystem.getWritableEntry instead"); 70 console.log("Please use chrome.fileSystem.getWritableEntry instead");
74 fileSystem.getWritableEntry.apply(this, arguments); 71 chrome.fileSystem.getWritableEntry.apply(this, arguments);
75 }; 72 };
76 73
77 fileSystem.isWritableFileEntry = function() { 74 chrome.fileSystem.isWritableFileEntry = function() {
78 console.log("chrome.fileSystem.isWritableFileEntry is deprecated"); 75 console.log("chrome.fileSystem.isWritableFileEntry is deprecated");
79 console.log("Please use chrome.fileSystem.isWritableEntry instead"); 76 console.log("Please use chrome.fileSystem.isWritableEntry instead");
80 fileSystem.isWritableEntry.apply(this, arguments); 77 chrome.fileSystem.isWritableEntry.apply(this, arguments);
81 }; 78 };
82 79
83 fileSystem.chooseFile = function() { 80 chrome.fileSystem.chooseFile = function() {
84 console.log("chrome.fileSystem.chooseFile is deprecated"); 81 console.log("chrome.fileSystem.chooseFile is deprecated");
85 console.log("Please use chrome.fileSystem.chooseEntry instead"); 82 console.log("Please use chrome.fileSystem.chooseEntry instead");
86 fileSystem.chooseEntry.apply(this, arguments); 83 chrome.fileSystem.chooseEntry.apply(this, arguments);
87 }; 84 };
88 }); 85 });
89
90 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698