OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 /** | 5 /** |
6 * Wallpaper file system quota. | 6 * Wallpaper file system quota. |
7 */ | 7 */ |
8 /** @const */ var WallpaperQuota = 1024 * 1024 * 100; | 8 /** @const */ var WallpaperQuota = 1024 * 1024 * 100; |
9 | 9 |
10 var wallpaperDirectories = null; | 10 var wallpaperDirectories = null; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 requestDir: function(dirName, success, failure) { | 51 requestDir: function(dirName, success, failure) { |
52 if (dirName != Constants.WallpaperDirNameEnum.ORIGINAL && | 52 if (dirName != Constants.WallpaperDirNameEnum.ORIGINAL && |
53 dirName != Constants.WallpaperDirNameEnum.THUMBNAIL) { | 53 dirName != Constants.WallpaperDirNameEnum.THUMBNAIL) { |
54 console.error('Error: Unknow directory name.'); | 54 console.error('Error: Unknow directory name.'); |
55 var e = new Error(); | 55 var e = new Error(); |
56 e.code = FileError.NOT_FOUND_ERR; | 56 e.code = FileError.NOT_FOUND_ERR; |
57 failure(e); | 57 failure(e); |
58 return; | 58 return; |
59 } | 59 } |
60 var self = this; | 60 var self = this; |
61 window.webkitRequestFileSystem(window.PERSISTENT, WallpaperQuota, | 61 window.webkitRequestFileSystem( |
62 function(fs) { | 62 window.PERSISTENT, WallpaperQuota, function(fs) { |
63 fs.root.getDirectory(dirName, {create: true}, function(dirEntry) { | 63 fs.root.getDirectory(dirName, {create: true}, function(dirEntry) { |
64 self.wallpaperDirs_[dirName] = dirEntry; | 64 self.wallpaperDirs_[dirName] = dirEntry; |
65 success(dirEntry); | 65 success(dirEntry); |
66 }, failure); | 66 }, failure); |
67 }, failure); | 67 }, failure); |
68 }, | 68 }, |
69 | 69 |
70 /** | 70 /** |
71 * Gets DirectoryEntry associated with dirName from cache. If not in cache try | 71 * Gets DirectoryEntry associated with dirName from cache. If not in cache try |
72 * to request it from FileSystem. | 72 * to request it from FileSystem. |
73 * @param {string} dirName The directory name of requested directory entry. | 73 * @param {string} dirName The directory name of requested directory entry. |
74 * @param {function(DirectoryEntry):void} success Call success with requested | 74 * @param {function(DirectoryEntry):void} success Call success with requested |
75 * DirectoryEntry. | 75 * DirectoryEntry. |
76 * @param {function(e):void} failure Call failure when failed to get the | 76 * @param {function(e):void} failure Call failure when failed to get the |
77 * requested directory. | 77 * requested directory. |
78 */ | 78 */ |
79 getDirectory: function(dirName, success, failure) { | 79 getDirectory: function(dirName, success, failure) { |
80 if (this.wallpaperDirs[dirName]) | 80 if (this.wallpaperDirs[dirName]) |
81 success(this.wallpaperDirs[dirName]); | 81 success(this.wallpaperDirs[dirName]); |
82 else | 82 else |
83 this.requestDir(dirName, success, failure); | 83 this.requestDir(dirName, success, failure); |
84 } | 84 } |
85 }; | 85 }; |
OLD | NEW |