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 syncFileSystem API. | 5 // Custom binding for the syncFileSystem API. |
6 | 6 |
7 var binding = require('binding').Binding.create('syncFileSystem'); | 7 var binding = require('binding').Binding.create('syncFileSystem'); |
8 | 8 |
9 var eventBindings = require('event_bindings'); | 9 var eventBindings = require('event_bindings'); |
10 var fileSystemNatives = requireNative('file_system_natives'); | 10 var fileSystemNatives = requireNative('file_system_natives'); |
11 var syncFileSystemNatives = requireNative('sync_file_system'); | 11 var syncFileSystemNatives = requireNative('sync_file_system'); |
12 | 12 |
13 binding.registerCustomHook(function(bindingsAPI) { | 13 binding.registerCustomHook(function(bindingsAPI) { |
14 var apiFunctions = bindingsAPI.apiFunctions; | 14 var apiFunctions = bindingsAPI.apiFunctions; |
15 | 15 |
16 // Functions which take in an [instanceOf=FileEntry]. | 16 // Functions which take in an [instanceOf=FileEntry]. |
17 function bindFileEntryFunction(functionName) { | 17 function bindFileEntryFunction(functionName) { |
18 apiFunctions.setUpdateArgumentsPostValidate( | 18 apiFunctions.setUpdateArgumentsPostValidate( |
19 functionName, function(entry, callback) { | 19 functionName, function(entry, callback) { |
20 var fileSystemUrl = entry.toURL(); | 20 var fileSystemUrl = entry.toURL(); |
21 return [fileSystemUrl, callback]; | 21 return [fileSystemUrl, callback]; |
22 }); | 22 }); |
23 } | 23 } |
24 $Array.forEach(['getFileStatus'], bindFileEntryFunction); | 24 $Array.forEach(['getFileStatus'], bindFileEntryFunction); |
25 | 25 |
26 // Functions which take in an [instanceOf=EntryArray]. | 26 // Functions which take in a FileEntry array. |
27 function bindFileEntryArrayFunction(functionName) { | 27 function bindFileEntryArrayFunction(functionName) { |
28 apiFunctions.setUpdateArgumentsPostValidate( | 28 apiFunctions.setUpdateArgumentsPostValidate( |
29 functionName, function(entries, callback) { | 29 functionName, function(entries, callback) { |
30 var fileSystemUrlArray = []; | 30 var fileSystemUrlArray = []; |
31 for (var i=0; i < entries.length; i++) { | 31 for (var i=0; i < entries.length; i++) { |
32 $Array.push(fileSystemUrlArray, entries[i].toURL()); | 32 $Array.push(fileSystemUrlArray, entries[i].toURL()); |
33 } | 33 } |
34 return [fileSystemUrlArray, callback]; | 34 return [fileSystemUrlArray, callback]; |
35 }); | 35 }); |
36 } | 36 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 fileInfo.fileEntry = fileEntry; | 100 fileInfo.fileEntry = fileEntry; |
101 fileInfo.status = args[1]; | 101 fileInfo.status = args[1]; |
102 if (fileInfo.status == "synced") { | 102 if (fileInfo.status == "synced") { |
103 fileInfo.action = args[2]; | 103 fileInfo.action = args[2]; |
104 fileInfo.direction = args[3]; | 104 fileInfo.direction = args[3]; |
105 } | 105 } |
106 dispatch([fileInfo]); | 106 dispatch([fileInfo]); |
107 }); | 107 }); |
108 | 108 |
109 exports.binding = binding.generate(); | 109 exports.binding = binding.generate(); |
OLD | NEW |