| 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/fileapi/isolated_mount_point_provider.h" | 5 #include "webkit/fileapi/isolated_mount_point_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 13 #include "base/task_runner.h" |
| 13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 14 #include "webkit/blob/local_file_reader.h" | 15 #include "webkit/blob/local_file_reader.h" |
| 15 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 16 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 16 #include "webkit/fileapi/file_system_file_reader.h" | 17 #include "webkit/fileapi/file_system_file_reader.h" |
| 17 #include "webkit/fileapi/file_system_operation.h" | 18 #include "webkit/fileapi/file_system_operation.h" |
| 18 #include "webkit/fileapi/file_system_types.h" | 19 #include "webkit/fileapi/file_system_types.h" |
| 19 #include "webkit/fileapi/file_system_util.h" | 20 #include "webkit/fileapi/file_system_util.h" |
| 20 #include "webkit/fileapi/isolated_context.h" | 21 #include "webkit/fileapi/isolated_context.h" |
| 21 #include "webkit/fileapi/isolated_file_util.h" | 22 #include "webkit/fileapi/isolated_file_util.h" |
| 22 #include "webkit/fileapi/native_file_util.h" | 23 #include "webkit/fileapi/native_file_util.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, &root, &path)) | 89 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, &root, &path)) |
| 89 return FilePath(); | 90 return FilePath(); |
| 90 return path; | 91 return path; |
| 91 } | 92 } |
| 92 | 93 |
| 93 FileSystemOperationInterface* | 94 FileSystemOperationInterface* |
| 94 IsolatedMountPointProvider::CreateFileSystemOperation( | 95 IsolatedMountPointProvider::CreateFileSystemOperation( |
| 95 const GURL& origin_url, | 96 const GURL& origin_url, |
| 96 FileSystemType file_system_type, | 97 FileSystemType file_system_type, |
| 97 const FilePath& virtual_path, | 98 const FilePath& virtual_path, |
| 98 base::MessageLoopProxy* file_proxy, | 99 base::TaskRunner* task_runner, |
| 99 FileSystemContext* context) const { | 100 FileSystemContext* context) const { |
| 100 return new FileSystemOperation(file_proxy, context); | 101 return new FileSystemOperation(task_runner, context); |
| 101 } | 102 } |
| 102 | 103 |
| 103 webkit_blob::FileReader* IsolatedMountPointProvider::CreateFileReader( | 104 webkit_blob::FileReader* IsolatedMountPointProvider::CreateFileReader( |
| 104 const GURL& url, | 105 const GURL& url, |
| 105 int64 offset, | 106 int64 offset, |
| 106 base::MessageLoopProxy* file_proxy, | 107 base::TaskRunner* task_runner, |
| 107 FileSystemContext* context) const { | 108 FileSystemContext* context) const { |
| 108 GURL origin_url; | 109 GURL origin_url; |
| 109 FileSystemType file_system_type = kFileSystemTypeUnknown; | 110 FileSystemType file_system_type = kFileSystemTypeUnknown; |
| 110 FilePath virtual_path; | 111 FilePath virtual_path; |
| 111 if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &virtual_path)) | 112 if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &virtual_path)) |
| 112 return NULL; | 113 return NULL; |
| 113 std::string fsid; | 114 std::string fsid; |
| 114 FilePath path; | 115 FilePath path; |
| 115 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) | 116 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) |
| 116 return NULL; | 117 return NULL; |
| 117 if (path.empty()) | 118 if (path.empty()) |
| 118 return NULL; | 119 return NULL; |
| 119 return new webkit_blob::LocalFileReader( | 120 return new webkit_blob::LocalFileReader( |
| 120 file_proxy, path, offset, base::Time()); | 121 task_runner, path, offset, base::Time()); |
| 121 } | 122 } |
| 122 | 123 |
| 123 IsolatedContext* IsolatedMountPointProvider::isolated_context() const { | 124 IsolatedContext* IsolatedMountPointProvider::isolated_context() const { |
| 124 return IsolatedContext::GetInstance(); | 125 return IsolatedContext::GetInstance(); |
| 125 } | 126 } |
| 126 | 127 |
| 127 } // namespace fileapi | 128 } // namespace fileapi |
| OLD | NEW |