Chromium Code Reviews| 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/fileapi/file_system_context.h" | 5 #include "webkit/fileapi/file_system_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 } | 134 } |
| 135 | 135 |
| 136 FileSystemMountPointProvider* FileSystemContext::GetMountPointProvider( | 136 FileSystemMountPointProvider* FileSystemContext::GetMountPointProvider( |
| 137 FileSystemType type) const { | 137 FileSystemType type) const { |
| 138 switch (type) { | 138 switch (type) { |
| 139 case kFileSystemTypeTemporary: | 139 case kFileSystemTypeTemporary: |
| 140 case kFileSystemTypePersistent: | 140 case kFileSystemTypePersistent: |
| 141 case kFileSystemTypeSyncable: | 141 case kFileSystemTypeSyncable: |
| 142 return sandbox_provider_.get(); | 142 return sandbox_provider_.get(); |
| 143 case kFileSystemTypeExternal: | 143 case kFileSystemTypeExternal: |
| 144 case kFileSystemTypeExternalFullPath: | |
| 144 case kFileSystemTypeDrive: | 145 case kFileSystemTypeDrive: |
| 145 case kFileSystemTypeRestrictedNativeLocal: | 146 case kFileSystemTypeRestrictedNativeLocal: |
| 146 return external_provider_.get(); | 147 return external_provider_.get(); |
| 147 case kFileSystemTypeIsolated: | 148 case kFileSystemTypeIsolated: |
| 148 case kFileSystemTypeDragged: | 149 case kFileSystemTypeDragged: |
| 149 case kFileSystemTypeNativeMedia: | 150 case kFileSystemTypeNativeMedia: |
| 150 case kFileSystemTypeDeviceMedia: | 151 case kFileSystemTypeDeviceMedia: |
| 151 return isolated_provider_.get(); | 152 return isolated_provider_.get(); |
| 152 case kFileSystemTypeNativeLocal: | 153 case kFileSystemTypeNativeLocal: |
| 153 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 delete this; | 343 delete this; |
| 343 } | 344 } |
| 344 | 345 |
| 345 FileSystemURL FileSystemContext::CrackFileSystemURL( | 346 FileSystemURL FileSystemContext::CrackFileSystemURL( |
| 346 const FileSystemURL& url) const { | 347 const FileSystemURL& url) const { |
| 347 if (!url.is_valid()) | 348 if (!url.is_valid()) |
| 348 return FileSystemURL(); | 349 return FileSystemURL(); |
| 349 | 350 |
| 350 // The returned value in case there is no crackers which can crack the url. | 351 // The returned value in case there is no crackers which can crack the url. |
| 351 // This is valid situation for non isolated/external file systems. | 352 // This is valid situation for non isolated/external file systems. |
| 352 FileSystemURL result = url; | 353 FileSystemURL current = url; |
| 353 | 354 |
| 354 for (size_t i = 0; i < url_crackers_.size(); ++i) { | 355 // File system may be mounted multiple times (e.g., an isolated filesystem on |
| 355 if (!url_crackers_[i]->HandlesFileSystemMountType(url.type())) | 356 // top of an external filesystem). Hence cracking needs to be iterated. |
| 356 continue; | 357 for (;;) { |
| 357 | 358 FileSystemURL cracked = current; |
| 358 result = url_crackers_[i]->CreateCrackedFileSystemURL(url.origin(), | 359 bool crack_happened = false; |
| 359 url.type(), | 360 for (size_t i = 0; i < url_crackers_.size(); ++i) { |
| 360 url.path()); | 361 if (!url_crackers_[i]->HandlesFileSystemMountType(current.type())) |
| 361 if (result.is_valid()) | 362 continue; |
| 362 return result; | 363 crack_happened = true; |
| 364 cracked = url_crackers_[i]->CrackFileSystemURL(current); | |
| 365 if (cracked.is_valid()) | |
| 366 break; | |
| 367 } | |
| 368 if (!crack_happened) | |
|
kinuko
2013/03/19 20:34:50
nit: if (cracked == current) may be enough
kinaba
2013/03/21 07:35:13
Done.
| |
| 369 break; | |
| 370 current = cracked; | |
| 363 } | 371 } |
| 364 | 372 return current; |
| 365 return result; | |
| 366 } | 373 } |
| 367 | 374 |
| 368 FileSystemFileUtil* FileSystemContext::GetFileUtil( | 375 FileSystemFileUtil* FileSystemContext::GetFileUtil( |
| 369 FileSystemType type) const { | 376 FileSystemType type) const { |
| 370 FileSystemMountPointProvider* mount_point_provider = | 377 FileSystemMountPointProvider* mount_point_provider = |
| 371 GetMountPointProvider(type); | 378 GetMountPointProvider(type); |
| 372 if (!mount_point_provider) | 379 if (!mount_point_provider) |
| 373 return NULL; | 380 return NULL; |
| 374 return mount_point_provider->GetFileUtil(type); | 381 return mount_point_provider->GetFileUtil(type); |
| 375 } | 382 } |
| 376 | 383 |
| 377 } // namespace fileapi | 384 } // namespace fileapi |
| OLD | NEW |