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

Side by Side Diff: chrome/test/data/extensions/api_test/file_system_provider/big_file/test.js

Issue 318563002: [fsp] Introduce BufferingFileStreamReader to read files in bigger chunks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @type {DOMFileSystem} 8 * @type {DOMFileSystem}
9 */ 9 */
10 var fileSystem = null; 10 var fileSystem = null;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 */ 97 */
98 function onReadFileRequested(options, onSuccess, onError) { 98 function onReadFileRequested(options, onSuccess, onError) {
99 var filePath = openedFiles[options.openRequestId]; 99 var filePath = openedFiles[options.openRequestId];
100 if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { 100 if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) {
101 onError('INVALID_OPERATION'); // enum ProviderError. 101 onError('INVALID_OPERATION'); // enum ProviderError.
102 return; 102 return;
103 } 103 }
104 104
105 if (filePath == '/' + TESTING_6GB_FILE.name) { 105 if (filePath == '/' + TESTING_6GB_FILE.name) {
106 if (options.offset < TESTING_TEXT_OFFSET || 106 if (options.offset < TESTING_TEXT_OFFSET ||
107 options.offset + options.length > 107 options.offset >= TESTING_TEXT_OFFSET + TESTING_TEXT.length) {
108 TESTING_TEXT_OFFSET + TESTING_TEXT.length) {
109 console.error('Reading from a wrong location in the file!'); 108 console.error('Reading from a wrong location in the file!');
110 onError('INVALID_FAILED'); // enum ProviderError. 109 onError('FAILED'); // enum ProviderError.
111 return; 110 return;
112 } 111 }
113 112
114 var buffer = TESTING_TEXT.substr( 113 var buffer = TESTING_TEXT.substr(
115 options.offset - TESTING_TEXT_OFFSET, options.length); 114 options.offset - TESTING_TEXT_OFFSET, options.length);
116 var reader = new FileReader(); 115 var reader = new FileReader();
117 reader.onload = function(e) { 116 reader.onload = function(e) {
118 onSuccess(e.target.result, false /* hasMore */); 117 onSuccess(e.target.result, false /* hasMore */);
119 }; 118 };
120 reader.readAsArrayBuffer(new Blob([buffer])); 119 reader.readAsArrayBuffer(new Blob([buffer]));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 }, 184 },
186 function(error) { 185 function(error) {
187 chrome.test.fail(error.name); 186 chrome.test.fail(error.name);
188 }); 187 });
189 } 188 }
190 ]); 189 ]);
191 } 190 }
192 191
193 // Setup and run all of the test cases. 192 // Setup and run all of the test cases.
194 setUp(runTests); 193 setUp(runTests);
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698