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/path_service.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_stream_writer.h" | 19 #include "webkit/chromeos/fileapi/remote_file_stream_writer.h" |
21 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" | 20 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" |
21 #include "webkit/fileapi/external_mount_points.h" | |
22 #include "webkit/fileapi/file_system_file_stream_reader.h" | 22 #include "webkit/fileapi/file_system_file_stream_reader.h" |
23 #include "webkit/fileapi/file_system_operation_context.h" | 23 #include "webkit/fileapi/file_system_operation_context.h" |
24 #include "webkit/fileapi/file_system_url.h" | 24 #include "webkit/fileapi/file_system_url.h" |
25 #include "webkit/fileapi/file_system_util.h" | 25 #include "webkit/fileapi/file_system_util.h" |
26 #include "webkit/fileapi/isolated_context.h" | 26 #include "webkit/fileapi/isolated_context.h" |
27 #include "webkit/fileapi/isolated_file_util.h" | 27 #include "webkit/fileapi/isolated_file_util.h" |
28 #include "webkit/fileapi/local_file_stream_writer.h" | 28 #include "webkit/fileapi/local_file_stream_writer.h" |
29 #include "webkit/fileapi/local_file_system_operation.h" | 29 #include "webkit/fileapi/local_file_system_operation.h" |
30 #include "webkit/glue/webkit_glue.h" | 30 #include "webkit/glue/webkit_glue.h" |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 const char kChromeUIScheme[] = "chrome"; | 34 const char kChromeUIScheme[] = "chrome"; |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 namespace chromeos { | 38 namespace chromeos { |
39 | 39 |
40 // static | 40 // static |
41 bool CrosMountPointProvider::CanHandleURL(const fileapi::FileSystemURL& url) { | 41 bool CrosMountPointProvider::CanHandleURL(const fileapi::FileSystemURL& url) { |
42 if (!url.is_valid()) | 42 if (!url.is_valid()) |
43 return false; | 43 return false; |
44 return url.type() == fileapi::kFileSystemTypeNativeLocal || | 44 return url.type() == fileapi::kFileSystemTypeNativeLocal || |
45 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || | 45 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || |
46 url.type() == fileapi::kFileSystemTypeDrive; | 46 url.type() == fileapi::kFileSystemTypeDrive; |
47 } | 47 } |
48 | 48 |
49 CrosMountPointProvider::CrosMountPointProvider( | 49 CrosMountPointProvider::CrosMountPointProvider( |
50 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) | 50 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
51 scoped_refptr<fileapi::ExternalMountPoints> mount_points, | |
52 fileapi::ExternalMountPoints* system_mount_points) | |
51 : special_storage_policy_(special_storage_policy), | 53 : special_storage_policy_(special_storage_policy), |
52 file_access_permissions_(new FileAccessPermissions()), | 54 file_access_permissions_(new FileAccessPermissions()), |
53 local_file_util_(new fileapi::IsolatedFileUtil()) { | 55 local_file_util_(new fileapi::IsolatedFileUtil()), |
54 FilePath home_path; | 56 mount_points_(mount_points), |
55 if (PathService::Get(base::DIR_HOME, &home_path)) | 57 system_mount_points_(system_mount_points) { |
56 AddLocalMountPoint(home_path.AppendASCII("Downloads")); | |
57 AddLocalMountPoint(FilePath(FILE_PATH_LITERAL("/media/archive"))); | |
58 AddLocalMountPoint(FilePath(FILE_PATH_LITERAL("/media/removable"))); | |
59 AddRestrictedLocalMountPoint(FilePath(FILE_PATH_LITERAL("/usr/share/oem"))); | |
60 } | 58 } |
61 | 59 |
62 CrosMountPointProvider::~CrosMountPointProvider() { | 60 CrosMountPointProvider::~CrosMountPointProvider() { |
63 } | 61 } |
64 | 62 |
65 void CrosMountPointProvider::ValidateFileSystemRoot( | 63 void CrosMountPointProvider::ValidateFileSystemRoot( |
66 const GURL& origin_url, | 64 const GURL& origin_url, |
67 fileapi::FileSystemType type, | 65 fileapi::FileSystemType type, |
68 bool create, | 66 bool create, |
69 const ValidateFileSystemCallback& callback) { | 67 const ValidateFileSystemCallback& callback) { |
70 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); | 68 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); |
71 // Nothing to validate for external filesystem. | 69 // Nothing to validate for external filesystem. |
72 callback.Run(base::PLATFORM_FILE_OK); | 70 callback.Run(base::PLATFORM_FILE_OK); |
73 } | 71 } |
74 | 72 |
75 FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread( | 73 FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread( |
76 const fileapi::FileSystemURL& url, | 74 const fileapi::FileSystemURL& url, |
77 bool create) { | 75 bool create) { |
78 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); | 76 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); |
79 if (!url.is_valid()) | 77 if (!url.is_valid()) |
80 return FilePath(); | 78 return FilePath(); |
81 | 79 |
82 FilePath root_path; | 80 FilePath root_path; |
83 if (!isolated_context()->GetRegisteredPath(url.filesystem_id(), &root_path)) | 81 std::string mount_name = url.filesystem_id(); |
82 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && | |
83 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { | |
84 return FilePath(); | 84 return FilePath(); |
85 } | |
85 | 86 |
86 return root_path.DirName(); | 87 return root_path.DirName(); |
87 } | 88 } |
88 | 89 |
89 bool CrosMountPointProvider::IsAccessAllowed( | 90 bool CrosMountPointProvider::IsAccessAllowed( |
90 const fileapi::FileSystemURL& url) { | 91 const fileapi::FileSystemURL& url) { |
91 if (!CanHandleURL(url)) | 92 if (!CanHandleURL(url)) |
92 return false; | 93 return false; |
93 | 94 |
94 // No extra check is needed for isolated file systems. | 95 // No extra check is needed for isolated file systems. |
(...skipping 26 matching lines...) Expand all Loading... | |
121 | 122 |
122 void CrosMountPointProvider::DeleteFileSystem( | 123 void CrosMountPointProvider::DeleteFileSystem( |
123 const GURL& origin_url, | 124 const GURL& origin_url, |
124 fileapi::FileSystemType type, | 125 fileapi::FileSystemType type, |
125 fileapi::FileSystemContext* context, | 126 fileapi::FileSystemContext* context, |
126 const DeleteFileSystemCallback& callback) { | 127 const DeleteFileSystemCallback& callback) { |
127 NOTREACHED(); | 128 NOTREACHED(); |
128 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 129 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
129 } | 130 } |
130 | 131 |
131 bool CrosMountPointProvider::HasMountPoint(const FilePath& mount_point) { | 132 bool CrosMountPointProvider::HasMountPoint(const FilePath& mount_point) const { |
132 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); | 133 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); |
133 FilePath path; | 134 FilePath path; |
134 const bool valid = isolated_context()->GetRegisteredPath(mount_name, &path); | 135 |
136 const bool valid = mount_points_->GetRegisteredPath(mount_name, &path); | |
135 return valid && path == mount_point; | 137 return valid && path == mount_point; |
136 } | 138 } |
137 | 139 |
138 void CrosMountPointProvider::AddLocalMountPoint(const FilePath& mount_point) { | 140 bool CrosMountPointProvider::AddLocalMountPoint(const FilePath& mount_point) { |
139 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); | 141 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); |
140 isolated_context()->RevokeFileSystem(mount_name); | 142 return mount_points_->RegisterFileSystem( |
141 isolated_context()->RegisterExternalFileSystem( | 143 mount_name, |
142 mount_name, | 144 fileapi::kFileSystemTypeNativeLocal, |
143 fileapi::kFileSystemTypeNativeLocal, | 145 mount_point); |
144 mount_point); | |
145 base::AutoLock locker(mount_point_map_lock_); | |
146 local_to_virtual_map_[mount_point] = mount_point.BaseName(); | |
147 } | 146 } |
148 | 147 |
149 void CrosMountPointProvider::AddRestrictedLocalMountPoint( | 148 bool CrosMountPointProvider::AddRestrictedLocalMountPoint( |
150 const FilePath& mount_point) { | 149 const FilePath& mount_point) { |
151 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); | 150 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); |
152 isolated_context()->RevokeFileSystem(mount_name); | 151 return mount_points_->RegisterFileSystem( |
153 isolated_context()->RegisterExternalFileSystem( | 152 mount_name, |
154 mount_name, | 153 fileapi::kFileSystemTypeRestrictedNativeLocal, |
155 fileapi::kFileSystemTypeRestrictedNativeLocal, | 154 mount_point); |
156 mount_point); | |
157 base::AutoLock locker(mount_point_map_lock_); | |
158 local_to_virtual_map_[mount_point] = mount_point.BaseName(); | |
159 } | 155 } |
160 | 156 |
161 void CrosMountPointProvider::AddRemoteMountPoint( | 157 bool CrosMountPointProvider::AddRemoteMountPoint( |
162 const FilePath& mount_point, | 158 const FilePath& mount_point, |
163 fileapi::RemoteFileSystemProxyInterface* remote_proxy) { | 159 fileapi::RemoteFileSystemProxyInterface* remote_proxy) { |
164 DCHECK(remote_proxy); | 160 DCHECK(remote_proxy); |
165 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); | 161 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); |
166 isolated_context()->RevokeFileSystem(mount_name); | 162 return mount_points_->RegisterRemoteFileSystem(mount_name, |
167 isolated_context()->RegisterExternalFileSystem(mount_name, | |
168 fileapi::kFileSystemTypeDrive, | 163 fileapi::kFileSystemTypeDrive, |
164 remote_proxy, | |
169 mount_point); | 165 mount_point); |
170 base::AutoLock locker(mount_point_map_lock_); | |
171 remote_proxy_map_[mount_name] = remote_proxy; | |
172 local_to_virtual_map_[mount_point] = mount_point.BaseName(); | |
173 } | 166 } |
174 | 167 |
175 void CrosMountPointProvider::RemoveMountPoint(const FilePath& mount_point) { | 168 void CrosMountPointProvider::RemoveMountPoint(const FilePath& mount_point) { |
169 if (!HasMountPoint(mount_point)) | |
170 return; | |
176 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); | 171 std::string mount_name = mount_point.BaseName().AsUTF8Unsafe(); |
177 isolated_context()->RevokeFileSystem(mount_name); | 172 mount_points_->RevokeFileSystem(mount_name); |
178 base::AutoLock locker(mount_point_map_lock_); | |
179 remote_proxy_map_.erase(mount_name); | |
180 local_to_virtual_map_.erase(mount_point); | |
181 } | 173 } |
182 | 174 |
183 void CrosMountPointProvider::GrantFullAccessToExtension( | 175 void CrosMountPointProvider::GrantFullAccessToExtension( |
184 const std::string& extension_id) { | 176 const std::string& extension_id) { |
185 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); | 177 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); |
186 if (!special_storage_policy_->IsFileHandler(extension_id)) | 178 if (!special_storage_policy_->IsFileHandler(extension_id)) |
187 return; | 179 return; |
188 std::vector<fileapi::IsolatedContext::FileInfo> files = | 180 |
189 isolated_context()->GetExternalMountPoints(); | 181 std::vector<fileapi::MountPoints::MountPointInfo> files; |
182 mount_points_->AddMountPointInfosTo(&files); | |
183 system_mount_points_->AddMountPointInfosTo(&files); | |
184 | |
190 for (size_t i = 0; i < files.size(); ++i) { | 185 for (size_t i = 0; i < files.size(); ++i) { |
191 file_access_permissions_->GrantAccessPermission( | 186 file_access_permissions_->GrantAccessPermission( |
192 extension_id, | 187 extension_id, |
193 FilePath::FromUTF8Unsafe(files[i].name)); | 188 FilePath::FromUTF8Unsafe(files[i].name)); |
194 } | 189 } |
195 } | 190 } |
196 | 191 |
197 void CrosMountPointProvider::GrantFileAccessToExtension( | 192 void CrosMountPointProvider::GrantFileAccessToExtension( |
198 const std::string& extension_id, const FilePath& virtual_path) { | 193 const std::string& extension_id, const FilePath& virtual_path) { |
199 // All we care about here is access from extensions for now. | 194 // All we care about here is access from extensions for now. |
200 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); | 195 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); |
201 if (!special_storage_policy_->IsFileHandler(extension_id)) | 196 if (!special_storage_policy_->IsFileHandler(extension_id)) |
202 return; | 197 return; |
203 | 198 |
204 std::string id; | 199 std::string id; |
205 fileapi::FileSystemType type; | 200 fileapi::FileSystemType type; |
206 FilePath path; | 201 FilePath path; |
207 isolated_context()->CrackIsolatedPath(virtual_path, &id, &type, &path); | 202 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &path) && |
203 !system_mount_points_->CrackVirtualPath(virtual_path, | |
204 &id, &type, &path)) { | |
205 return; | |
206 } | |
208 | 207 |
209 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { | 208 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { |
210 LOG(ERROR) << "Can't grant access for restricted mount point"; | 209 LOG(ERROR) << "Can't grant access for restricted mount point"; |
211 return; | 210 return; |
212 } | 211 } |
213 | 212 |
214 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); | 213 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); |
215 } | 214 } |
216 | 215 |
217 void CrosMountPointProvider::RevokeAccessForExtension( | 216 void CrosMountPointProvider::RevokeAccessForExtension( |
218 const std::string& extension_id) { | 217 const std::string& extension_id) { |
219 file_access_permissions_->RevokePermissions(extension_id); | 218 file_access_permissions_->RevokePermissions(extension_id); |
220 } | 219 } |
221 | 220 |
222 std::vector<FilePath> CrosMountPointProvider::GetRootDirectories() const { | 221 std::vector<FilePath> CrosMountPointProvider::GetRootDirectories() const { |
223 std::vector<fileapi::IsolatedContext::FileInfo> files = | 222 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; |
224 isolated_context()->GetExternalMountPoints(); | 223 mount_points_->AddMountPointInfosTo(&mount_points); |
224 system_mount_points_->AddMountPointInfosTo(&mount_points); | |
225 | |
225 std::vector<FilePath> root_dirs; | 226 std::vector<FilePath> root_dirs; |
226 for (size_t i = 0; i < files.size(); ++i) | 227 for (size_t i = 0; i < mount_points.size(); ++i) |
227 root_dirs.push_back(files[i].path); | 228 root_dirs.push_back(mount_points[i].path); |
228 return root_dirs; | 229 return root_dirs; |
229 } | 230 } |
230 | 231 |
231 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileUtil( | 232 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileUtil( |
232 fileapi::FileSystemType type) { | 233 fileapi::FileSystemType type) { |
233 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || | 234 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || |
234 type == fileapi::kFileSystemTypeRestrictedNativeLocal); | 235 type == fileapi::kFileSystemTypeRestrictedNativeLocal); |
235 return local_file_util_.get(); | 236 return local_file_util_.get(); |
236 } | 237 } |
237 | 238 |
238 FilePath CrosMountPointProvider::GetPathForPermissionsCheck( | 239 FilePath CrosMountPointProvider::GetPathForPermissionsCheck( |
239 const FilePath& virtual_path) const { | 240 const FilePath& virtual_path) const { |
240 return virtual_path; | 241 return virtual_path; |
241 } | 242 } |
242 | 243 |
243 fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation( | 244 fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation( |
244 const fileapi::FileSystemURL& url, | 245 const fileapi::FileSystemURL& url, |
245 fileapi::FileSystemContext* context, | 246 fileapi::FileSystemContext* context, |
246 base::PlatformFileError* error_code) const { | 247 base::PlatformFileError* error_code) const { |
248 if (!url.is_valid()) | |
249 return NULL; | |
kinuko
2013/01/10 05:47:31
Please fill *error_code
(Or change this to DCHECK)
tonibarzic
2013/01/11 01:50:04
good catch
Done.
| |
247 if (url.type() == fileapi::kFileSystemTypeDrive) { | 250 if (url.type() == fileapi::kFileSystemTypeDrive) { |
248 base::AutoLock locker(mount_point_map_lock_); | 251 fileapi::RemoteFileSystemProxyInterface* remote_proxy = |
249 RemoteProxyMap::const_iterator found = remote_proxy_map_.find( | 252 GetRemoteProxy(url.filesystem_id()); |
250 url.filesystem_id()); | 253 if (!remote_proxy) |
251 if (found != remote_proxy_map_.end()) { | |
252 return new chromeos::RemoteFileSystemOperation(found->second); | |
253 } else { | |
254 *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND; | |
255 return NULL; | 254 return NULL; |
kinuko
2013/01/10 05:47:31
ditto.
tonibarzic
2013/01/11 01:50:04
Done.
| |
256 } | 255 return new chromeos::RemoteFileSystemOperation(remote_proxy); |
257 } | 256 } |
258 | 257 |
259 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || | 258 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || |
260 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); | 259 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); |
261 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( | 260 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( |
262 new fileapi::FileSystemOperationContext(context)); | 261 new fileapi::FileSystemOperationContext(context)); |
263 return new fileapi::LocalFileSystemOperation(context, | 262 return new fileapi::LocalFileSystemOperation(context, |
264 operation_context.Pass()); | 263 operation_context.Pass()); |
265 } | 264 } |
266 | 265 |
267 webkit_blob::FileStreamReader* CrosMountPointProvider::CreateFileStreamReader( | 266 webkit_blob::FileStreamReader* CrosMountPointProvider::CreateFileStreamReader( |
268 const fileapi::FileSystemURL& url, | 267 const fileapi::FileSystemURL& url, |
269 int64 offset, | 268 int64 offset, |
270 const base::Time& expected_modification_time, | 269 const base::Time& expected_modification_time, |
271 fileapi::FileSystemContext* context) const { | 270 fileapi::FileSystemContext* context) const { |
272 // For now we return a generic Reader implementation which utilizes | 271 // For now we return a generic Reader implementation which utilizes |
273 // CreateSnapshotFile internally (i.e. will download everything first). | 272 // CreateSnapshotFile internally (i.e. will download everything first). |
274 // TODO(satorux,zel): implement more efficient reader for remote cases. | 273 // TODO(satorux,zel): implement more efficient reader for remote cases. |
275 return new fileapi::FileSystemFileStreamReader( | 274 return new fileapi::FileSystemFileStreamReader( |
276 context, url, offset, expected_modification_time); | 275 context, url, offset, expected_modification_time); |
277 } | 276 } |
278 | 277 |
279 fileapi::FileStreamWriter* CrosMountPointProvider::CreateFileStreamWriter( | 278 fileapi::FileStreamWriter* CrosMountPointProvider::CreateFileStreamWriter( |
280 const fileapi::FileSystemURL& url, | 279 const fileapi::FileSystemURL& url, |
281 int64 offset, | 280 int64 offset, |
282 fileapi::FileSystemContext* context) const { | 281 fileapi::FileSystemContext* context) const { |
283 if (!url.is_valid()) | 282 if (!url.is_valid()) |
284 return NULL; | 283 return NULL; |
284 | |
285 if (url.type() == fileapi::kFileSystemTypeDrive) { | 285 if (url.type() == fileapi::kFileSystemTypeDrive) { |
286 base::AutoLock locker(mount_point_map_lock_); | 286 fileapi::RemoteFileSystemProxyInterface* remote_proxy = |
287 RemoteProxyMap::const_iterator found = remote_proxy_map_.find( | 287 GetRemoteProxy(url.filesystem_id()); |
288 url.filesystem_id()); | 288 if (!remote_proxy) |
289 if (found == remote_proxy_map_.end()) | |
290 return NULL; | 289 return NULL; |
291 return new fileapi::RemoteFileStreamWriter(found->second, url, offset); | 290 return new fileapi::RemoteFileStreamWriter(remote_proxy, url, offset); |
292 } | 291 } |
293 | 292 |
294 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) | 293 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) |
295 return NULL; | 294 return NULL; |
296 | 295 |
297 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); | 296 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); |
298 return new fileapi::LocalFileStreamWriter(url.path(), offset); | 297 return new fileapi::LocalFileStreamWriter(url.path(), offset); |
299 } | 298 } |
300 | 299 |
301 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, | 300 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, |
302 FilePath* virtual_path) { | 301 FilePath* virtual_path) { |
303 base::AutoLock locker(mount_point_map_lock_); | 302 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
304 std::map<FilePath, FilePath>::reverse_iterator iter( | 303 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
305 local_to_virtual_map_.upper_bound(filesystem_path)); | |
306 if (iter == local_to_virtual_map_.rend()) | |
307 return false; | |
308 if (iter->first == filesystem_path) { | |
309 *virtual_path = iter->second; | |
310 return true; | |
311 } | |
312 return iter->first.DirName().AppendRelativePath( | |
313 filesystem_path, virtual_path); | |
314 } | 304 } |
315 | 305 |
316 fileapi::IsolatedContext* CrosMountPointProvider::isolated_context() const { | 306 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( |
317 return fileapi::IsolatedContext::GetInstance(); | 307 const std::string& mount_name) const { |
308 fileapi::RemoteFileSystemProxyInterface* proxy = | |
309 mount_points_->GetRemoteFileSystemProxy(mount_name); | |
310 if (proxy) | |
311 return proxy; | |
312 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); | |
318 } | 313 } |
319 | 314 |
320 } // namespace chromeos | 315 } // namespace chromeos |
OLD | NEW |