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/browser/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "webkit/browser/chromeos/fileapi/cros_mount_point_provider.h" |
6 | 6 |
7 #include "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void CrosMountPointProvider::ValidateFileSystemRoot( | 93 void CrosMountPointProvider::ValidateFileSystemRoot( |
94 const GURL& origin_url, | 94 const GURL& origin_url, |
95 fileapi::FileSystemType type, | 95 fileapi::FileSystemType type, |
96 bool create, | 96 bool create, |
97 const ValidateFileSystemCallback& callback) { | 97 const ValidateFileSystemCallback& callback) { |
98 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); | 98 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); |
99 // Nothing to validate for external filesystem. | 99 // Nothing to validate for external filesystem. |
100 callback.Run(base::PLATFORM_FILE_OK); | 100 callback.Run(base::PLATFORM_FILE_OK); |
101 } | 101 } |
102 | 102 |
103 base::FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread( | |
104 const fileapi::FileSystemURL& url, | |
105 bool create) { | |
106 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); | |
107 if (!url.is_valid()) | |
108 return base::FilePath(); | |
109 | |
110 base::FilePath root_path; | |
111 std::string mount_name = url.filesystem_id(); | |
112 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && | |
113 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { | |
114 return base::FilePath(); | |
115 } | |
116 | |
117 return root_path.DirName(); | |
118 } | |
119 | |
120 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() { | 103 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() { |
121 // No quota support. | 104 // No quota support. |
122 return NULL; | 105 return NULL; |
123 } | 106 } |
124 | 107 |
125 void CrosMountPointProvider::DeleteFileSystem( | 108 void CrosMountPointProvider::DeleteFileSystem( |
126 const GURL& origin_url, | 109 const GURL& origin_url, |
127 fileapi::FileSystemType type, | 110 fileapi::FileSystemType type, |
128 fileapi::FileSystemContext* context, | 111 fileapi::FileSystemContext* context, |
129 const DeleteFileSystemCallback& callback) { | 112 const DeleteFileSystemCallback& callback) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND; | 264 *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND; |
282 return NULL; | 265 return NULL; |
283 } | 266 } |
284 return new chromeos::RemoteFileSystemOperation(remote_proxy); | 267 return new chromeos::RemoteFileSystemOperation(remote_proxy); |
285 } | 268 } |
286 | 269 |
287 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || | 270 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || |
288 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); | 271 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); |
289 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( | 272 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( |
290 new fileapi::FileSystemOperationContext(context)); | 273 new fileapi::FileSystemOperationContext(context)); |
| 274 operation_context->set_root_path(GetFileSystemRootPath(url)); |
291 return new fileapi::LocalFileSystemOperation(context, | 275 return new fileapi::LocalFileSystemOperation(context, |
292 operation_context.Pass()); | 276 operation_context.Pass()); |
293 } | 277 } |
294 | 278 |
295 scoped_ptr<webkit_blob::FileStreamReader> | 279 scoped_ptr<webkit_blob::FileStreamReader> |
296 CrosMountPointProvider::CreateFileStreamReader( | 280 CrosMountPointProvider::CreateFileStreamReader( |
297 const fileapi::FileSystemURL& url, | 281 const fileapi::FileSystemURL& url, |
298 int64 offset, | 282 int64 offset, |
299 const base::Time& expected_modification_time, | 283 const base::Time& expected_modification_time, |
300 fileapi::FileSystemContext* context) const { | 284 fileapi::FileSystemContext* context) const { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 332 |
349 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( | 333 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( |
350 const std::string& mount_name) const { | 334 const std::string& mount_name) const { |
351 fileapi::RemoteFileSystemProxyInterface* proxy = | 335 fileapi::RemoteFileSystemProxyInterface* proxy = |
352 mount_points_->GetRemoteFileSystemProxy(mount_name); | 336 mount_points_->GetRemoteFileSystemProxy(mount_name); |
353 if (proxy) | 337 if (proxy) |
354 return proxy; | 338 return proxy; |
355 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); | 339 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); |
356 } | 340 } |
357 | 341 |
| 342 base::FilePath CrosMountPointProvider::GetFileSystemRootPath( |
| 343 const fileapi::FileSystemURL& url) const { |
| 344 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); |
| 345 if (!url.is_valid()) |
| 346 return base::FilePath(); |
| 347 |
| 348 base::FilePath root_path; |
| 349 std::string mount_name = url.filesystem_id(); |
| 350 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && |
| 351 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { |
| 352 return base::FilePath(); |
| 353 } |
| 354 |
| 355 return root_path.DirName(); |
| 356 } |
| 357 |
358 } // namespace chromeos | 358 } // namespace chromeos |
OLD | NEW |