| 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/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "webkit/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" |
| 11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 19 #include "webkit/chromeos/fileapi/file_access_permissions.h" | 19 #include "webkit/chromeos/fileapi/file_access_permissions.h" |
| 20 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" | 20 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" |
| 21 #include "webkit/fileapi/file_system_file_reader.h" |
| 21 #include "webkit/fileapi/file_system_operation.h" | 22 #include "webkit/fileapi/file_system_operation.h" |
| 22 #include "webkit/fileapi/file_system_util.h" | 23 #include "webkit/fileapi/file_system_util.h" |
| 23 #include "webkit/fileapi/native_file_util.h" | 24 #include "webkit/fileapi/native_file_util.h" |
| 24 #include "webkit/glue/webkit_glue.h" | 25 #include "webkit/glue/webkit_glue.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 const char kChromeUIScheme[] = "chrome"; | 29 const char kChromeUIScheme[] = "chrome"; |
| 29 | 30 |
| 30 // Returns the home directory path, or an empty string if the home directory | 31 // Returns the home directory path, or an empty string if the home directory |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 const FilePath& virtual_path, | 246 const FilePath& virtual_path, |
| 246 base::MessageLoopProxy* file_proxy, | 247 base::MessageLoopProxy* file_proxy, |
| 247 fileapi::FileSystemContext* context) const { | 248 fileapi::FileSystemContext* context) const { |
| 248 const MountPoint* mount_point = GetMountPoint(virtual_path); | 249 const MountPoint* mount_point = GetMountPoint(virtual_path); |
| 249 if (mount_point && mount_point->location == REMOTE) | 250 if (mount_point && mount_point->location == REMOTE) |
| 250 return new chromeos::RemoteFileSystemOperation(mount_point->remote_proxy); | 251 return new chromeos::RemoteFileSystemOperation(mount_point->remote_proxy); |
| 251 | 252 |
| 252 return new fileapi::FileSystemOperation(file_proxy, context); | 253 return new fileapi::FileSystemOperation(file_proxy, context); |
| 253 } | 254 } |
| 254 | 255 |
| 256 webkit_blob::FileReader* CrosMountPointProvider::CreateFileReader( |
| 257 const GURL& url, |
| 258 int64 offset, |
| 259 base::MessageLoopProxy* file_proxy, |
| 260 fileapi::FileSystemContext* context) const { |
| 261 // For now we return a generic Reader implementation which utilizes |
| 262 // CreateSnapshotFile internally (i.e. will download everything first). |
| 263 // TODO(satorux,zel): implement more efficient reader for remote cases. |
| 264 return new fileapi::FileSystemFileReader(file_proxy, context, url, offset); |
| 265 } |
| 266 |
| 255 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, | 267 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, |
| 256 FilePath* virtual_path) { | 268 FilePath* virtual_path) { |
| 257 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); | 269 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); |
| 258 iter != mount_point_map_.end(); | 270 iter != mount_point_map_.end(); |
| 259 ++iter) { | 271 ++iter) { |
| 260 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first); | 272 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first); |
| 261 *virtual_path = FilePath(iter->first); | 273 *virtual_path = FilePath(iter->first); |
| 262 if (mount_prefix == filesystem_path) { | 274 if (mount_prefix == filesystem_path) { |
| 263 return true; | 275 return true; |
| 264 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { | 276 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { |
| 265 return true; | 277 return true; |
| 266 } | 278 } |
| 267 } | 279 } |
| 268 return false; | 280 return false; |
| 269 } | 281 } |
| 270 | 282 |
| 271 } // namespace chromeos | 283 } // namespace chromeos |
| OLD | NEW |