OLD | NEW |
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 binding for the fileSystem API. |
6 | 6 |
7 var binding = require('binding').Binding.create('fileSystem'); | 7 var binding = require('binding').Binding.create('fileSystem'); |
8 | 8 |
9 var fileSystemNatives = requireNative('file_system_natives'); | 9 var fileSystemNatives = requireNative('file_system_natives'); |
10 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; | 10 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; |
(...skipping 29 matching lines...) Expand all Loading... |
40 var fs = GetIsolatedFileSystem(fileSystemId); | 40 var fs = GetIsolatedFileSystem(fileSystemId); |
41 | 41 |
42 try { | 42 try { |
43 // TODO(koz): fs.root.getFile() makes a trip to the browser process, | 43 // TODO(koz): fs.root.getFile() makes a trip to the browser process, |
44 // but it might be possible avoid that by calling | 44 // but it might be possible avoid that by calling |
45 // WebFrame::createFileEntry(). | 45 // WebFrame::createFileEntry(). |
46 fs.root.getFile(baseName, {}, function(fileEntry) { | 46 fs.root.getFile(baseName, {}, function(fileEntry) { |
47 entryIdManager.registerEntry(id, fileEntry); | 47 entryIdManager.registerEntry(id, fileEntry); |
48 callback(fileEntry); | 48 callback(fileEntry); |
49 }, function(fileError) { | 49 }, function(fileError) { |
50 lastError.set('Error getting fileEntry, code: ' + fileError.code); | 50 lastError.run('Error getting fileEntry, code: ' + fileError.code, |
51 callback(); | 51 callback); |
52 }); | 52 }); |
53 } catch (e) { | 53 } catch (e) { |
54 lastError.set('Error in event handler for onLaunched: ' + e.stack); | 54 lastError.run('Error in event handler for onLaunched: ' + e.stack, |
55 callback(); | 55 callback); |
56 } | 56 } |
57 } | 57 } |
58 }); | 58 }); |
59 } | 59 } |
60 ['getWritableEntry', 'chooseEntry'].forEach(bindFileEntryCallback); | 60 ['getWritableEntry', 'chooseEntry'].forEach(bindFileEntryCallback); |
61 | 61 |
62 apiFunctions.setHandleRequest('getEntryId', function(fileEntry) { | 62 apiFunctions.setHandleRequest('getEntryId', function(fileEntry) { |
63 return entryIdManager.getEntryId(fileEntry); | 63 return entryIdManager.getEntryId(fileEntry); |
64 }); | 64 }); |
65 | 65 |
(...skipping 15 matching lines...) Expand all Loading... |
81 }; | 81 }; |
82 | 82 |
83 fileSystem.chooseFile = function() { | 83 fileSystem.chooseFile = function() { |
84 console.log("chrome.fileSystem.chooseFile is deprecated"); | 84 console.log("chrome.fileSystem.chooseFile is deprecated"); |
85 console.log("Please use chrome.fileSystem.chooseEntry instead"); | 85 console.log("Please use chrome.fileSystem.chooseEntry instead"); |
86 fileSystem.chooseEntry.apply(this, arguments); | 86 fileSystem.chooseEntry.apply(this, arguments); |
87 }; | 87 }; |
88 }); | 88 }); |
89 | 89 |
90 exports.binding = binding.generate(); | 90 exports.binding = binding.generate(); |
OLD | NEW |