| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 using WebKit::WebFileWriterClient; | 38 using WebKit::WebFileWriterClient; |
| 39 using WebKit::WebFrame; | 39 using WebKit::WebFrame; |
| 40 using WebKit::WebSecurityOrigin; | 40 using WebKit::WebSecurityOrigin; |
| 41 using WebKit::WebString; | 41 using WebKit::WebString; |
| 42 using WebKit::WebURL; | 42 using WebKit::WebURL; |
| 43 using WebKit::WebVector; | 43 using WebKit::WebVector; |
| 44 | 44 |
| 45 using webkit_blob::BlobData; | 45 using webkit_blob::BlobData; |
| 46 using webkit_blob::BlobStorageController; | 46 using webkit_blob::BlobStorageController; |
| 47 using fileapi::FileSystemContext; | 47 using fileapi::FileSystemContext; |
| 48 using fileapi::FileSystemOperationInterface; | 48 using fileapi::FileSystemOperation; |
| 49 using fileapi::FileSystemTaskRunners; | 49 using fileapi::FileSystemTaskRunners; |
| 50 using fileapi::FileSystemURL; | 50 using fileapi::FileSystemURL; |
| 51 | 51 |
| 52 namespace { | 52 namespace { |
| 53 MessageLoop* g_io_thread; | 53 MessageLoop* g_io_thread; |
| 54 webkit_blob::BlobStorageController* g_blob_storage_controller; | 54 webkit_blob::BlobStorageController* g_blob_storage_controller; |
| 55 | 55 |
| 56 void RegisterBlob(const GURL& blob_url, const FilePath& file_path) { | 56 void RegisterBlob(const GURL& blob_url, const FilePath& file_path) { |
| 57 DCHECK(g_blob_storage_controller); | 57 DCHECK(g_blob_storage_controller); |
| 58 | 58 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 g_blob_storage_controller = NULL; | 262 g_blob_storage_controller = NULL; |
| 263 } | 263 } |
| 264 | 264 |
| 265 bool SimpleFileSystem::HasFilePermission( | 265 bool SimpleFileSystem::HasFilePermission( |
| 266 const fileapi::FileSystemURL& url, FilePermission permission) { | 266 const fileapi::FileSystemURL& url, FilePermission permission) { |
| 267 // Disallow writing on isolated file system, otherwise return ok. | 267 // Disallow writing on isolated file system, otherwise return ok. |
| 268 return (url.type() != fileapi::kFileSystemTypeIsolated || | 268 return (url.type() != fileapi::kFileSystemTypeIsolated || |
| 269 permission == FILE_PERMISSION_READ); | 269 permission == FILE_PERMISSION_READ); |
| 270 } | 270 } |
| 271 | 271 |
| 272 FileSystemOperationInterface* SimpleFileSystem::GetNewOperation( | 272 FileSystemOperation* SimpleFileSystem::GetNewOperation( |
| 273 const fileapi::FileSystemURL& url) { | 273 const fileapi::FileSystemURL& url) { |
| 274 return file_system_context_->CreateFileSystemOperation(url); | 274 return file_system_context_->CreateFileSystemOperation(url); |
| 275 } | 275 } |
| 276 | 276 |
| 277 FileSystemOperationInterface::StatusCallback | 277 FileSystemOperation::StatusCallback |
| 278 SimpleFileSystem::FinishHandler(WebFileSystemCallbacks* callbacks) { | 278 SimpleFileSystem::FinishHandler(WebFileSystemCallbacks* callbacks) { |
| 279 return base::Bind(&SimpleFileSystem::DidFinish, | 279 return base::Bind(&SimpleFileSystem::DidFinish, |
| 280 AsWeakPtr(), base::Unretained(callbacks)); | 280 AsWeakPtr(), base::Unretained(callbacks)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 FileSystemOperationInterface::ReadDirectoryCallback | 283 FileSystemOperation::ReadDirectoryCallback |
| 284 SimpleFileSystem::ReadDirectoryHandler(WebFileSystemCallbacks* callbacks) { | 284 SimpleFileSystem::ReadDirectoryHandler(WebFileSystemCallbacks* callbacks) { |
| 285 return base::Bind(&SimpleFileSystem::DidReadDirectory, | 285 return base::Bind(&SimpleFileSystem::DidReadDirectory, |
| 286 AsWeakPtr(), base::Unretained(callbacks)); | 286 AsWeakPtr(), base::Unretained(callbacks)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 FileSystemOperationInterface::GetMetadataCallback | 289 FileSystemOperation::GetMetadataCallback |
| 290 SimpleFileSystem::GetMetadataHandler(WebFileSystemCallbacks* callbacks) { | 290 SimpleFileSystem::GetMetadataHandler(WebFileSystemCallbacks* callbacks) { |
| 291 return base::Bind(&SimpleFileSystem::DidGetMetadata, | 291 return base::Bind(&SimpleFileSystem::DidGetMetadata, |
| 292 AsWeakPtr(), base::Unretained(callbacks)); | 292 AsWeakPtr(), base::Unretained(callbacks)); |
| 293 } | 293 } |
| 294 | 294 |
| 295 FileSystemContext::OpenFileSystemCallback | 295 FileSystemContext::OpenFileSystemCallback |
| 296 SimpleFileSystem::OpenFileSystemHandler(WebFileSystemCallbacks* callbacks) { | 296 SimpleFileSystem::OpenFileSystemHandler(WebFileSystemCallbacks* callbacks) { |
| 297 return base::Bind(&SimpleFileSystem::DidOpenFileSystem, | 297 return base::Bind(&SimpleFileSystem::DidOpenFileSystem, |
| 298 AsWeakPtr(), base::Unretained(callbacks)); | 298 AsWeakPtr(), base::Unretained(callbacks)); |
| 299 } | 299 } |
| 300 | 300 |
| 301 FileSystemContext::DeleteFileSystemCallback | 301 FileSystemContext::DeleteFileSystemCallback |
| 302 SimpleFileSystem::DeleteFileSystemHandler(WebFileSystemCallbacks* callbacks) { | 302 SimpleFileSystem::DeleteFileSystemHandler(WebFileSystemCallbacks* callbacks) { |
| 303 return base::Bind(&SimpleFileSystem::DidDeleteFileSystem, | 303 return base::Bind(&SimpleFileSystem::DidDeleteFileSystem, |
| 304 AsWeakPtr(), callbacks); | 304 AsWeakPtr(), callbacks); |
| 305 } | 305 } |
| 306 | 306 |
| 307 FileSystemOperationInterface::SnapshotFileCallback | 307 FileSystemOperation::SnapshotFileCallback |
| 308 SimpleFileSystem::SnapshotFileHandler(const GURL& blob_url, | 308 SimpleFileSystem::SnapshotFileHandler(const GURL& blob_url, |
| 309 WebFileSystemCallbacks* callbacks) { | 309 WebFileSystemCallbacks* callbacks) { |
| 310 return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile, | 310 return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile, |
| 311 AsWeakPtr(), blob_url, base::Unretained(callbacks)); | 311 AsWeakPtr(), blob_url, base::Unretained(callbacks)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void SimpleFileSystem::DidFinish(WebFileSystemCallbacks* callbacks, | 314 void SimpleFileSystem::DidFinish(WebFileSystemCallbacks* callbacks, |
| 315 base::PlatformFileError result) { | 315 base::PlatformFileError result) { |
| 316 if (result == base::PLATFORM_FILE_OK) | 316 if (result == base::PLATFORM_FILE_OK) |
| 317 callbacks->didSucceed(); | 317 callbacks->didSucceed(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 const FilePath& platform_path, | 389 const FilePath& platform_path, |
| 390 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 390 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { |
| 391 DCHECK(g_io_thread); | 391 DCHECK(g_io_thread); |
| 392 if (result == base::PLATFORM_FILE_OK) { | 392 if (result == base::PLATFORM_FILE_OK) { |
| 393 g_io_thread->PostTask( | 393 g_io_thread->PostTask( |
| 394 FROM_HERE, | 394 FROM_HERE, |
| 395 base::Bind(&RegisterBlob, blob_url, platform_path)); | 395 base::Bind(&RegisterBlob, blob_url, platform_path)); |
| 396 } | 396 } |
| 397 DidGetMetadata(callbacks, result, info, platform_path); | 397 DidGetMetadata(callbacks, result, info, platform_path); |
| 398 } | 398 } |
| OLD | NEW |