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/sequenced_task_runner.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_file_reader.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 return NULL; | 237 return NULL; |
238 | 238 |
239 return &(iter->second); | 239 return &(iter->second); |
240 } | 240 } |
241 | 241 |
242 fileapi::FileSystemOperationInterface* | 242 fileapi::FileSystemOperationInterface* |
243 CrosMountPointProvider::CreateFileSystemOperation( | 243 CrosMountPointProvider::CreateFileSystemOperation( |
244 const GURL& origin_url, | 244 const GURL& origin_url, |
245 fileapi::FileSystemType file_system_type, | 245 fileapi::FileSystemType file_system_type, |
246 const FilePath& virtual_path, | 246 const FilePath& virtual_path, |
247 base::MessageLoopProxy* file_proxy, | 247 base::TaskRunner* task_runner, |
248 fileapi::FileSystemContext* context) const { | 248 fileapi::FileSystemContext* context) const { |
249 const MountPoint* mount_point = GetMountPoint(virtual_path); | 249 const MountPoint* mount_point = GetMountPoint(virtual_path); |
250 if (mount_point && mount_point->location == REMOTE) | 250 if (mount_point && mount_point->location == REMOTE) |
251 return new chromeos::RemoteFileSystemOperation(mount_point->remote_proxy); | 251 return new chromeos::RemoteFileSystemOperation(mount_point->remote_proxy); |
252 | 252 |
253 return new fileapi::FileSystemOperation(file_proxy, context); | 253 return new fileapi::FileSystemOperation(task_runner, context); |
254 } | 254 } |
255 | 255 |
256 webkit_blob::FileReader* CrosMountPointProvider::CreateFileReader( | 256 webkit_blob::FileReader* CrosMountPointProvider::CreateFileReader( |
257 const GURL& url, | 257 const GURL& url, |
258 int64 offset, | 258 int64 offset, |
259 base::MessageLoopProxy* file_proxy, | 259 base::SequencedTaskRunner* task_runner, |
260 fileapi::FileSystemContext* context) const { | 260 fileapi::FileSystemContext* context) const { |
261 // For now we return a generic Reader implementation which utilizes | 261 // For now we return a generic Reader implementation which utilizes |
262 // CreateSnapshotFile internally (i.e. will download everything first). | 262 // CreateSnapshotFile internally (i.e. will download everything first). |
263 // TODO(satorux,zel): implement more efficient reader for remote cases. | 263 // TODO(satorux,zel): implement more efficient reader for remote cases. |
264 return new fileapi::FileSystemFileReader(file_proxy, context, url, offset); | 264 return new fileapi::FileSystemFileReader(task_runner, context, url, offset); |
265 } | 265 } |
266 | 266 |
267 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, | 267 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, |
268 FilePath* virtual_path) { | 268 FilePath* virtual_path) { |
269 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); | 269 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); |
270 iter != mount_point_map_.end(); | 270 iter != mount_point_map_.end(); |
271 ++iter) { | 271 ++iter) { |
272 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first); | 272 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first); |
273 *virtual_path = FilePath(iter->first); | 273 *virtual_path = FilePath(iter->first); |
274 if (mount_prefix == filesystem_path) { | 274 if (mount_prefix == filesystem_path) { |
275 return true; | 275 return true; |
276 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { | 276 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { |
277 return true; | 277 return true; |
278 } | 278 } |
279 } | 279 } |
280 return false; | 280 return false; |
281 } | 281 } |
282 | 282 |
283 } // namespace chromeos | 283 } // namespace chromeos |
OLD | NEW |