} else if (result.status == 'canceled') {
if (callback.oncanceled) {
callback.oncanceled(result.downloadId);
- delete callbacks[result.downloadId];
}
} else if (result.status == 'completed') {
if (callback.oncompleted) {
} else if (result.status == 'error') {
if (callback.onfailed) {
callback.onfailed(result.downloadId, new WebAPIException(result.error));
- delete callbacks[result.downloadId];
}
}
}, 0);
PAUSED: 'PAUSED',
CANCELED: 'CANCELED',
COMPLETED: 'COMPLETED',
- FAILED: 'FAILED'
+ FAILED: 'FAILED',
+ ABANDONED: 'ABANDONED'
};
var DownloadNetworkType = {
this.setListener(nativeParam.downloadId, args.downloadCallback);
}
- var result = native_.callSync('DownloadManager_start', nativeParam);
+ var result = native_.callSync('DownloadManagerStart', nativeParam);
if (native_.isFailure(result)) {
if ('NetworkError' === result.error.name) {
'the identifier does not match any download operation in progress'
);
- var result = native_.callSync('DownloadManager_cancel', nativeParam);
+ var result = native_.callSync('DownloadManagerCancel', nativeParam);
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
'the identifier does not match any download operation in progress'
);
- var result = native_.callSync('DownloadManager_pause', nativeParam);
+ var result = native_.callSync('DownloadManagerPause', nativeParam);
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
}
};
+DownloadManager.prototype.abandon = function() {
+ var args = validator_.validateArgs(arguments, [
+ { name: 'downloadId', type: types_.LONG, nullable: false, optional: false }
+ ]);
+
+ var nativeParam = {
+ downloadId: args.downloadId
+ };
+
+ if (typeof requests[args.downloadId] === 'undefined')
+ throw new WebAPIException(
+ WebAPIException.INVALID_VALUES_ERR,
+ 'the identifier does not match any download operation in progress'
+ );
+
+ var result = native_.callSync('DownloadManagerAbandon', nativeParam);
+
+ if (native_.isFailure(result)) {
+ throw native_.getErrorObject(result);
+ }
+
+ delete callbacks[args.downloadId];
+};
+
DownloadManager.prototype.resume = function() {
var args = validator_.validateArgs(arguments, [
{ name: 'downloadId', type: types_.LONG, nullable: false, optional: false }
'the identifier does not match any download operation in progress'
);
- var result = native_.callSync('DownloadManager_resume', nativeParam);
+ var result = native_.callSync('DownloadManagerResume', nativeParam);
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
'the identifier does not match any download operation in progress'
);
- var result = native_.callSync('DownloadManager_getState', nativeParam);
+ var result = native_.callSync('DownloadManagerGetState', nativeParam);
if (native_.isSuccess(result)) {
return native_.getResultObject(result);
'the identifier does not match any download operation in progress'
);
- var result = native_.callSync('DownloadManager_getMIMEType', nativeParam);
+ var result = native_.callSync('DownloadManagerGetMimeType', nativeParam);
if (native_.isSuccess(result)) {
return native_.getResultObject(result);