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

Side by Side Diff: webkit/tools/test_shell/simple_file_system.cc

Issue 12084077: FileSystem mods: Changes to snapshot file creation to remove dependencies on blobs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "webkit/tools/test_shell/simple_file_system.h" 5 #include "webkit/tools/test_shell/simple_file_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 GetNewOperation(url)->ReadDirectory(url, ReadDirectoryHandler(callbacks)); 233 GetNewOperation(url)->ReadDirectory(url, ReadDirectoryHandler(callbacks));
234 } 234 }
235 235
236 WebFileWriter* SimpleFileSystem::createFileWriter( 236 WebFileWriter* SimpleFileSystem::createFileWriter(
237 const WebURL& path, WebFileWriterClient* client) { 237 const WebURL& path, WebFileWriterClient* client) {
238 return new SimpleFileWriter(path, client, file_system_context_.get()); 238 return new SimpleFileWriter(path, client, file_system_context_.get());
239 } 239 }
240 240
241 void SimpleFileSystem::createSnapshotFileAndReadMetadata( 241 void SimpleFileSystem::createSnapshotFileAndReadMetadata(
242 const WebURL& path,
243 WebFileSystemCallbacks* callbacks) {
244 FileSystemURL url(file_system_context()->CrackURL(path));
245 if (!HasFilePermission(url, FILE_PERMISSION_READ)) {
246 callbacks->didFail(WebKit::WebFileErrorSecurity);
247 return;
248 }
249 GetNewOperation(url)->CreateSnapshotFile(
250 url, SnapshotFileHandler(callbacks));
251 }
252
253 // DEPRECATED
254 void SimpleFileSystem::createSnapshotFileAndReadMetadata(
242 const WebURL& blobURL, 255 const WebURL& blobURL,
243 const WebURL& path, 256 const WebURL& path,
244 WebFileSystemCallbacks* callbacks) { 257 WebFileSystemCallbacks* callbacks) {
245 FileSystemURL url(file_system_context()->CrackURL(path)); 258 FileSystemURL url(file_system_context()->CrackURL(path));
246 if (!HasFilePermission(url, FILE_PERMISSION_READ)) { 259 if (!HasFilePermission(url, FILE_PERMISSION_READ)) {
247 callbacks->didFail(WebKit::WebFileErrorSecurity); 260 callbacks->didFail(WebKit::WebFileErrorSecurity);
248 return; 261 return;
249 } 262 }
250 GetNewOperation(url)->CreateSnapshotFile( 263 GetNewOperation(url)->CreateSnapshotFile(
251 url, SnapshotFileHandler(blobURL, callbacks)); 264 url, SnapshotFileHandler_Deprecated(blobURL, callbacks));
252 } 265 }
253 266
254 // static 267 // static
255 void SimpleFileSystem::InitializeOnIOThread( 268 void SimpleFileSystem::InitializeOnIOThread(
256 webkit_blob::BlobStorageController* blob_storage_controller) { 269 webkit_blob::BlobStorageController* blob_storage_controller) {
257 g_io_thread = MessageLoop::current(); 270 g_io_thread = MessageLoop::current();
258 g_blob_storage_controller = blob_storage_controller; 271 g_blob_storage_controller = blob_storage_controller;
259 } 272 }
260 273
261 // static 274 // static
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 AsWeakPtr(), base::Unretained(callbacks)); 313 AsWeakPtr(), base::Unretained(callbacks));
301 } 314 }
302 315
303 FileSystemContext::DeleteFileSystemCallback 316 FileSystemContext::DeleteFileSystemCallback
304 SimpleFileSystem::DeleteFileSystemHandler(WebFileSystemCallbacks* callbacks) { 317 SimpleFileSystem::DeleteFileSystemHandler(WebFileSystemCallbacks* callbacks) {
305 return base::Bind(&SimpleFileSystem::DidDeleteFileSystem, 318 return base::Bind(&SimpleFileSystem::DidDeleteFileSystem,
306 AsWeakPtr(), callbacks); 319 AsWeakPtr(), callbacks);
307 } 320 }
308 321
309 FileSystemOperation::SnapshotFileCallback 322 FileSystemOperation::SnapshotFileCallback
310 SimpleFileSystem::SnapshotFileHandler(const GURL& blob_url, 323 SimpleFileSystem::SnapshotFileHandler(
311 WebFileSystemCallbacks* callbacks) { 324 WebFileSystemCallbacks* callbacks) {
312 return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile, 325 return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile,
326 AsWeakPtr(), base::Unretained(callbacks));
327 }
328
329 FileSystemOperation::SnapshotFileCallback
330 SimpleFileSystem::SnapshotFileHandler_Deprecated(
331 const GURL& blob_url,
332 WebFileSystemCallbacks* callbacks) {
333 return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile_Deprecated,
313 AsWeakPtr(), blob_url, base::Unretained(callbacks)); 334 AsWeakPtr(), blob_url, base::Unretained(callbacks));
314 } 335 }
315 336
316 void SimpleFileSystem::DidFinish(WebFileSystemCallbacks* callbacks, 337 void SimpleFileSystem::DidFinish(WebFileSystemCallbacks* callbacks,
317 base::PlatformFileError result) { 338 base::PlatformFileError result) {
318 if (result == base::PLATFORM_FILE_OK) 339 if (result == base::PLATFORM_FILE_OK)
319 callbacks->didSucceed(); 340 callbacks->didSucceed();
320 else 341 else
321 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); 342 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
322 } 343 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 void SimpleFileSystem::DidDeleteFileSystem( 398 void SimpleFileSystem::DidDeleteFileSystem(
378 WebFileSystemCallbacks* callbacks, 399 WebFileSystemCallbacks* callbacks,
379 base::PlatformFileError result) { 400 base::PlatformFileError result) {
380 if (result == base::PLATFORM_FILE_OK) 401 if (result == base::PLATFORM_FILE_OK)
381 callbacks->didSucceed(); 402 callbacks->didSucceed();
382 else 403 else
383 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); 404 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
384 } 405 }
385 406
386 void SimpleFileSystem::DidCreateSnapshotFile( 407 void SimpleFileSystem::DidCreateSnapshotFile(
408 WebFileSystemCallbacks* callbacks,
409 base::PlatformFileError result,
410 const base::PlatformFileInfo& info,
411 const FilePath& platform_path,
412 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
413 if (result == base::PLATFORM_FILE_OK) {
414 WebFileInfo web_file_info;
415 web_file_info.length = info.size;
416 web_file_info.modificationTime = info.last_modified.ToDoubleT();
417 web_file_info.type = info.is_directory ?
418 WebFileInfo::TypeDirectory : WebFileInfo::TypeFile;
419 web_file_info.platformPath =
420 webkit_base::FilePathToWebString(platform_path);
421 //callbacks->didCreateSnapshotFile(web_file_info);
michaeln 2013/01/30 23:32:24 ditto
422 } else {
423 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
424 }
425 }
426
427 void SimpleFileSystem::DidCreateSnapshotFile_Deprecated(
387 const GURL& blob_url, 428 const GURL& blob_url,
388 WebFileSystemCallbacks* callbacks, 429 WebFileSystemCallbacks* callbacks,
389 base::PlatformFileError result, 430 base::PlatformFileError result,
390 const base::PlatformFileInfo& info, 431 const base::PlatformFileInfo& info,
391 const FilePath& platform_path, 432 const FilePath& platform_path,
392 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 433 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
393 DCHECK(g_io_thread); 434 DCHECK(g_io_thread);
394 if (result == base::PLATFORM_FILE_OK) { 435 if (result == base::PLATFORM_FILE_OK) {
395 g_io_thread->PostTask( 436 g_io_thread->PostTask(
396 FROM_HERE, 437 FROM_HERE,
397 base::Bind(&RegisterBlob, blob_url, platform_path)); 438 base::Bind(&RegisterBlob, blob_url, platform_path));
398 } 439 }
399 DidGetMetadata(callbacks, result, info, platform_path); 440 DidGetMetadata(callbacks, result, info, platform_path);
400 } 441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698