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