| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 case kFileSystemTypeExternal: | 143 case kFileSystemTypeExternal: |
| 144 case kFileSystemTypeDrive: | 144 case kFileSystemTypeDrive: |
| 145 case kFileSystemTypeRestrictedNativeLocal: | 145 case kFileSystemTypeRestrictedNativeLocal: |
| 146 return external_provider_.get(); | 146 return external_provider_.get(); |
| 147 case kFileSystemTypeIsolated: | 147 case kFileSystemTypeIsolated: |
| 148 case kFileSystemTypeDragged: | 148 case kFileSystemTypeDragged: |
| 149 case kFileSystemTypeNativeMedia: | 149 case kFileSystemTypeNativeMedia: |
| 150 case kFileSystemTypeDeviceMedia: | 150 case kFileSystemTypeDeviceMedia: |
| 151 return isolated_provider_.get(); | 151 return isolated_provider_.get(); |
| 152 case kFileSystemTypeNativeLocal: | 152 case kFileSystemTypeNativeLocal: |
| 153 case kFileSystemTypeNativeForPlatformApp: |
| 153 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
| 154 return external_provider_.get(); | 155 return external_provider_.get(); |
| 155 #else | 156 #else |
| 156 return isolated_provider_.get(); | 157 return isolated_provider_.get(); |
| 157 #endif | 158 #endif |
| 158 default: | 159 default: |
| 159 if (provider_map_.find(type) != provider_map_.end()) | 160 if (provider_map_.find(type) != provider_map_.end()) |
| 160 return provider_map_.find(type)->second; | 161 return provider_map_.find(type)->second; |
| 161 // Fall through. | 162 // Fall through. |
| 162 case kFileSystemTypeUnknown: | 163 case kFileSystemTypeUnknown: |
| (...skipping 179 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 for (size_t i = 0; i < url_crackers_.size(); ++i) { |
| 359 url.type(), | 360 if (!url_crackers_[i]->HandlesFileSystemMountType(current.type())) |
| 360 url.path()); | 361 continue; |
| 361 if (result.is_valid()) | 362 cracked = url_crackers_[i]->CrackFileSystemURL(current); |
| 362 return result; | 363 if (cracked.is_valid()) |
| 364 break; |
| 365 } |
| 366 if (cracked == current) |
| 367 break; |
| 368 current = cracked; |
| 363 } | 369 } |
| 364 | 370 return current; |
| 365 return result; | |
| 366 } | 371 } |
| 367 | 372 |
| 368 FileSystemFileUtil* FileSystemContext::GetFileUtil( | 373 FileSystemFileUtil* FileSystemContext::GetFileUtil( |
| 369 FileSystemType type) const { | 374 FileSystemType type) const { |
| 370 FileSystemMountPointProvider* mount_point_provider = | 375 FileSystemMountPointProvider* mount_point_provider = |
| 371 GetMountPointProvider(type); | 376 GetMountPointProvider(type); |
| 372 if (!mount_point_provider) | 377 if (!mount_point_provider) |
| 373 return NULL; | 378 return NULL; |
| 374 return mount_point_provider->GetFileUtil(type); | 379 return mount_point_provider->GetFileUtil(type); |
| 375 } | 380 } |
| 376 | 381 |
| 377 } // namespace fileapi | 382 } // namespace fileapi |
| OLD | NEW |