| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.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" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 18 #include "webkit/chromeos/fileapi/file_access_permissions.h" | 18 #include "webkit/chromeos/fileapi/file_access_permissions.h" |
| 19 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 19 #include "webkit/fileapi/file_system_operation.h" | 20 #include "webkit/fileapi/file_system_operation.h" |
| 20 #include "webkit/fileapi/file_system_util.h" | 21 #include "webkit/fileapi/file_system_util.h" |
| 21 #include "webkit/fileapi/native_file_util.h" | 22 #include "webkit/fileapi/native_file_util.h" |
| 22 #include "webkit/glue/webkit_glue.h" | 23 #include "webkit/glue/webkit_glue.h" |
| 23 | 24 |
| 24 namespace chromeos { | 25 namespace chromeos { |
| 25 | 26 |
| 26 typedef struct { | 27 typedef struct { |
| 27 const char* local_root_path; | 28 const char* local_root_path; |
| 28 const char* web_root_path; | 29 const char* web_root_path; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 178 |
| 178 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileUtil() { | 179 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileUtil() { |
| 179 return local_file_util_.get(); | 180 return local_file_util_.get(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 fileapi::FileSystemOperationInterface* | 183 fileapi::FileSystemOperationInterface* |
| 183 CrosMountPointProvider::CreateFileSystemOperation( | 184 CrosMountPointProvider::CreateFileSystemOperation( |
| 184 const GURL& origin_url, | 185 const GURL& origin_url, |
| 185 fileapi::FileSystemType file_system_type, | 186 fileapi::FileSystemType file_system_type, |
| 186 const FilePath& virtual_path, | 187 const FilePath& virtual_path, |
| 188 scoped_ptr<fileapi::FileSystemCallbackDispatcher> dispatcher, |
| 187 base::MessageLoopProxy* file_proxy, | 189 base::MessageLoopProxy* file_proxy, |
| 188 fileapi::FileSystemContext* context) const { | 190 fileapi::FileSystemContext* context) const { |
| 189 // TODO(satorux,zel): instantiate appropriate FileSystemOperation that | 191 // TODO(satorux,zel): instantiate appropriate FileSystemOperation that |
| 190 // implements async/remote operations. | 192 // implements async/remote operations. |
| 191 return new fileapi::FileSystemOperation(file_proxy, context); | 193 return new fileapi::FileSystemOperation( |
| 194 dispatcher.Pass(), file_proxy, context); |
| 192 } | 195 } |
| 193 | 196 |
| 194 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, | 197 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, |
| 195 FilePath* virtual_path) { | 198 FilePath* virtual_path) { |
| 196 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); | 199 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); |
| 197 iter != mount_point_map_.end(); | 200 iter != mount_point_map_.end(); |
| 198 ++iter) { | 201 ++iter) { |
| 199 FilePath mount_prefix = iter->second.Append(iter->first); | 202 FilePath mount_prefix = iter->second.Append(iter->first); |
| 200 *virtual_path = FilePath(iter->first); | 203 *virtual_path = FilePath(iter->first); |
| 201 if (mount_prefix == filesystem_path) { | 204 if (mount_prefix == filesystem_path) { |
| 202 return true; | 205 return true; |
| 203 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { | 206 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { |
| 204 return true; | 207 return true; |
| 205 } | 208 } |
| 206 } | 209 } |
| 207 return false; | 210 return false; |
| 208 } | 211 } |
| 209 | 212 |
| 210 } // namespace chromeos | 213 } // namespace chromeos |
| OLD | NEW |