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

Unified Diff: chrome/common/extensions/docs/examples/api/fileSystemProvider/basic/background.js

Issue 1138503005: Fix examples for File System Provider API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/api/fileSystemProvider/basic/background.js
diff --git a/chrome/common/extensions/docs/examples/api/fileSystemProvider/basic/background.js b/chrome/common/extensions/docs/examples/api/fileSystemProvider/basic/background.js
index f95a098f6d8f0b27ff4906819b72a86c6989b611..be1b1a2e487063c99509f7f1036e6454b8d15c3d 100644
--- a/chrome/common/extensions/docs/examples/api/fileSystemProvider/basic/background.js
+++ b/chrome/common/extensions/docs/examples/api/fileSystemProvider/basic/background.js
@@ -10,7 +10,7 @@ var SHORT_CONTENTS = 'Just another example.';
var LONGER_CONTENTS = 'It works!\nEverything gets displayed correctly.';
var METADATA = {
- '/': {isDirectory: true, name: '/', size: 0,
+ '/': {isDirectory: true, name: '', size: 0,
modificationTime: MODIFICATION_DATE},
'/file1.txt': {isDirectory: false, name: 'file1.txt',
size: LONGER_CONTENTS.length, modificationTime: MODIFICATION_DATE,
@@ -99,21 +99,37 @@ function onReadFileRequested(options, onSuccess, onError) {
onSuccess(buffer, false /* Last call. */);
}
-// Mount the file system.
-chrome.runtime.onInstalled.addListener(function(details) {
+function onMountRequested(onSuccess, onError) {
chrome.fileSystemProvider.mount(
{fileSystemId: 'sample-file-system', displayName: 'Sample File System'},
- function() {},
- function() { console.error('Failed to mount.'); });
-});
+ function() {
+ if (chrome.runtime.lastError) {
+ onError(chrome.runtime.lastError.message);
+ console.error('Failed to mount because of: ' +
+ chrome.runtime.lastError.message);
+ }
+ });
not at google - send to devlin 2015/05/18 20:00:54 do you want to call onSuccess anywhere here, and b
mtomasz 2015/05/19 00:42:54 Good catch, done.
+}
+
+function onUnmountRequested(options, onSuccess, onError) {
+ chrome.fileSystemProvider.unmount(
+ {fileSystemId: options.fileSystemId},
+ function() {
+ if (chrome.runtime.lastError) {
+ onError(chrome.runtime.lastError.message);
+ console.error('Failed to unmount because of: ' +
+ chrome.runtime.lastError.message);
+ }
+ });
+}
chrome.fileSystemProvider.onGetMetadataRequested.addListener(
onGetMetadataRequested);
chrome.fileSystemProvider.onReadDirectoryRequested.addListener(
onReadDirectoryRequested);
-chrome.fileSystemProvider.onOpenFileRequested.addListener(
- onOpenFileRequested);
+chrome.fileSystemProvider.onOpenFileRequested.addListener(onOpenFileRequested);
chrome.fileSystemProvider.onCloseFileRequested.addListener(
onCloseFileRequested);
-chrome.fileSystemProvider.onReadFileRequested.addListener(
- onReadFileRequested);
+chrome.fileSystemProvider.onReadFileRequested.addListener(onReadFileRequested);
+chrome.fileSystemProvider.onMountRequested.addListener(onMountRequested);
+chrome.fileSystemProvider.onUnmountRequested.addListener(onUnmountRequested);

Powered by Google App Engine
This is Rietveld 408576698