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

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

Issue 50703013: fileSystemProvider: First cut at implementing fileSystemProvider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: switch to two-callback approach Created 7 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Custom binding for the fileSystemProvider API.
6
7 var binding = require('binding').Binding.create('fileSystemProvider');
8 var fileSystemProviderNatives = requireNative('file_system_provider');
9 var GetDOMError = fileSystemProviderNatives.GetDOMError;
10
11 binding.registerCustomHook(function(bindingsAPI) {
12 var apiFunctions = bindingsAPI.apiFunctions;
13
14 apiFunctions.setUpdateArgumentsPostValidate(
15 'mount',
16 function(displayName, successCallback, errorCallback) {
17 // Piggyback the error callback onto the success callback,
18 // so we can use the error callback later.
satorux1 2013/11/07 07:37:02 kalman: I took another look at other APIs, but cou
not at google - send to devlin 2013/11/07 15:58:05 I think the piggybacking trick is fine for now. Wh
satorux1 2013/11/08 02:25:54 Thanks. Promise-based APIs sound good. Added trail
19 successCallback.errorCallback = errorCallback;
20 return [displayName, successCallback];
21 });
22
23 apiFunctions.setCustomCallback(
24 'mount',
25 function(name, request, response) {
26 var fileSystemId = null;
27 var domError = null;
28 if (request.callback && response) {
29 fileSystemId = response[0];
30 // DOMError is present only if mount() failed.
31 if (response[1]) {
32 // Convert a Dictionary to a DOMError.
33 domError = GetDOMError(response[1].name, response[1].message);
34 response.length = 1;
35 }
36
37 var successCallback = request.callback;
38 var errorCallback = request.callback.errorCallback;
39 delete request.callback;
40
41 if (domError)
42 errorCallback(domError);
43 else
44 successCallback(fileSystemId);
45 }
46 });
47 });
48
49 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698