OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 fileSystemProvider API. | 5 // Custom binding for the fileSystemProvider API. |
6 | 6 |
7 var binding = require('binding').Binding.create('fileSystemProvider'); | 7 var binding = require('binding').Binding.create('fileSystemProvider'); |
8 var fileSystemProviderNatives = requireNative('file_system_provider'); | 8 var fileSystemProviderNatives = requireNative('file_system_provider'); |
9 var GetDOMError = fileSystemProviderNatives.GetDOMError; | 9 var GetDOMError = fileSystemProviderNatives.GetDOMError; |
10 | 10 |
11 binding.registerCustomHook(function(bindingsAPI) { | 11 binding.registerCustomHook(function(bindingsAPI) { |
12 var apiFunctions = bindingsAPI.apiFunctions; | 12 var apiFunctions = bindingsAPI.apiFunctions; |
13 | 13 |
| 14 apiFunctions.setUpdateArgumentsPostValidate('mount', function() { |
| 15 // Hold onto the error callback or something. |
| 16 }); |
| 17 |
14 apiFunctions.setCustomCallback( | 18 apiFunctions.setCustomCallback( |
15 'mount', | 19 'mount', |
16 function(name, request, response) { | 20 function(name, request, response) { |
17 var domError = null; | 21 var domError = null; |
18 var fileSystemId = null; | 22 var fileSystemId = null; |
19 if (response) { | 23 if (response) { |
20 // Convert a Dictionary to a DomError. | 24 fileSystemId = response[0] |
21 domError = GetDOMError(response[0].name, response[0].message); | 25 if (reponse[1]) { |
22 fileSystemId = response[1] | 26 domError = GetDOMError(response[1].name, response[1].message); |
| 27 response.length = 1; |
| 28 } |
23 } | 29 } |
24 | 30 |
25 if (request.callback) { | 31 var successCallback = request.callback; |
26 request.callback(domError, fileSystemId); | 32 delete request.callback; |
27 request.callback = null; | 33 if (domError && request.failureCallback) |
28 } | 34 request.failureCallback(domError); |
| 35 if (!domError && successCallback) |
| 36 successCallback(fileSystemId) |
29 }); | 37 }); |
30 }); | 38 }); |
31 | 39 |
32 exports.binding = binding.generate(); | 40 exports.binding = binding.generate(); |
OLD | NEW |