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 var sendRequest = require('sendRequest'); | 8 var sendRequest = require('sendRequest'); |
9 | 9 |
10 var getFileBindingsForApi = | 10 var getFileBindingsForApi = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 this.definition.parameters, {}); | 44 this.definition.parameters, {}); |
45 return id; | 45 return id; |
46 }); | 46 }); |
47 | 47 |
48 apiFunctions.setHandleRequest('isRestorable', | 48 apiFunctions.setHandleRequest('isRestorable', |
49 function(id, callback) { | 49 function(id, callback) { |
50 var savedEntry = entryIdManager.getEntryById(id); | 50 var savedEntry = entryIdManager.getEntryById(id); |
51 if (savedEntry) { | 51 if (savedEntry) { |
52 sendRequest.safeCallbackApply( | 52 sendRequest.safeCallbackApply( |
53 'fileSystem.isRestorable', | 53 'fileSystem.isRestorable', |
54 {'stack': sendRequest.getExtensionStackTrace()}, | 54 {}, |
55 callback, | 55 callback, |
56 [true]); | 56 [true]); |
57 } else { | 57 } else { |
58 sendRequest.sendRequest( | 58 sendRequest.sendRequest( |
59 this.name, [id, callback], this.definition.parameters, {}); | 59 this.name, [id, callback], this.definition.parameters, {}); |
60 } | 60 } |
61 }); | 61 }); |
62 | 62 |
63 apiFunctions.setUpdateArgumentsPostValidate('restoreEntry', | 63 apiFunctions.setUpdateArgumentsPostValidate('restoreEntry', |
64 function(id, callback) { | 64 function(id, callback) { |
65 var savedEntry = entryIdManager.getEntryById(id); | 65 var savedEntry = entryIdManager.getEntryById(id); |
66 if (savedEntry) { | 66 if (savedEntry) { |
67 // We already have a file entry for this id so pass it to the callback and | 67 // We already have a file entry for this id so pass it to the callback and |
68 // send a request to the browser to move it to the back of the LRU. | 68 // send a request to the browser to move it to the back of the LRU. |
69 sendRequest.safeCallbackApply( | 69 sendRequest.safeCallbackApply( |
70 'fileSystem.restoreEntry', | 70 'fileSystem.restoreEntry', |
71 {'stack': sendRequest.getExtensionStackTrace()}, | 71 {}, |
72 callback, | 72 callback, |
73 [savedEntry]); | 73 [savedEntry]); |
74 return [id, false, null]; | 74 return [id, false, null]; |
75 } else { | 75 } else { |
76 // Ask the browser process for a new file entry for this id, to be passed | 76 // Ask the browser process for a new file entry for this id, to be passed |
77 // to |callback|. | 77 // to |callback|. |
78 return [id, true, callback]; | 78 return [id, true, callback]; |
79 } | 79 } |
80 }); | 80 }); |
81 | 81 |
(...skipping 12 matching lines...) Expand all Loading... |
94 | 94 |
95 fileSystem.chooseFile = function() { | 95 fileSystem.chooseFile = function() { |
96 console.log("chrome.fileSystem.chooseFile is deprecated"); | 96 console.log("chrome.fileSystem.chooseFile is deprecated"); |
97 console.log("Please use chrome.fileSystem.chooseEntry instead"); | 97 console.log("Please use chrome.fileSystem.chooseEntry instead"); |
98 $Function.apply(fileSystem.chooseEntry, this, arguments); | 98 $Function.apply(fileSystem.chooseEntry, this, arguments); |
99 }; | 99 }; |
100 }); | 100 }); |
101 | 101 |
102 exports.bindFileEntryCallback = bindFileEntryCallback; | 102 exports.bindFileEntryCallback = bindFileEntryCallback; |
103 exports.binding = binding.generate(); | 103 exports.binding = binding.generate(); |
OLD | NEW |