| 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/obfuscated_file_util.h" | 5 #include "webkit/fileapi/obfuscated_file_util.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // base::FilePath local_path = GetLocalFilePath(url); | 35 // base::FilePath local_path = GetLocalFilePath(url); |
| 36 // | 36 // |
| 37 // NativeFileUtil::DoSomething(local_path); | 37 // NativeFileUtil::DoSomething(local_path); |
| 38 // file_util::DoAnother(local_path); | 38 // file_util::DoAnother(local_path); |
| 39 // } | 39 // } |
| 40 | 40 |
| 41 namespace fileapi { | 41 namespace fileapi { |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 typedef FileSystemDirectoryDatabase::FileId FileId; | 45 typedef SandboxDirectoryDatabase::FileId FileId; |
| 46 typedef FileSystemDirectoryDatabase::FileInfo FileInfo; | 46 typedef SandboxDirectoryDatabase::FileInfo FileInfo; |
| 47 | 47 |
| 48 const int64 kFlushDelaySeconds = 10 * 60; // 10 minutes | 48 const int64 kFlushDelaySeconds = 10 * 60; // 10 minutes |
| 49 | 49 |
| 50 void InitFileInfo( | 50 void InitFileInfo( |
| 51 FileSystemDirectoryDatabase::FileInfo* file_info, | 51 SandboxDirectoryDatabase::FileInfo* file_info, |
| 52 FileSystemDirectoryDatabase::FileId parent_id, | 52 SandboxDirectoryDatabase::FileId parent_id, |
| 53 const base::FilePath::StringType& file_name) { | 53 const base::FilePath::StringType& file_name) { |
| 54 DCHECK(file_info); | 54 DCHECK(file_info); |
| 55 file_info->parent_id = parent_id; | 55 file_info->parent_id = parent_id; |
| 56 file_info->name = file_name; | 56 file_info->name = file_name; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Costs computed as per crbug.com/86114, based on the LevelDB implementation of | 59 // Costs computed as per crbug.com/86114, based on the LevelDB implementation of |
| 60 // path storage under Linux. It's not clear if that will differ on Windows, on | 60 // path storage under Linux. It's not clear if that will differ on Windows, on |
| 61 // which base::FilePath uses wide chars [since they're converted to UTF-8 for st
orage | 61 // which base::FilePath uses wide chars [since they're converted to UTF-8 for st
orage |
| 62 // anyway], but as long as the cost is high enough that one can't cheat on quota | 62 // anyway], but as long as the cost is high enough that one can't cheat on quota |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 void UpdateUsage( | 83 void UpdateUsage( |
| 84 FileSystemOperationContext* context, | 84 FileSystemOperationContext* context, |
| 85 const FileSystemURL& url, | 85 const FileSystemURL& url, |
| 86 int64 growth) { | 86 int64 growth) { |
| 87 context->update_observers()->Notify( | 87 context->update_observers()->Notify( |
| 88 &FileUpdateObserver::OnUpdate, MakeTuple(url, growth)); | 88 &FileUpdateObserver::OnUpdate, MakeTuple(url, growth)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void TouchDirectory(FileSystemDirectoryDatabase* db, FileId dir_id) { | 91 void TouchDirectory(SandboxDirectoryDatabase* db, FileId dir_id) { |
| 92 DCHECK(db); | 92 DCHECK(db); |
| 93 if (!db->UpdateModificationTime(dir_id, base::Time::Now())) | 93 if (!db->UpdateModificationTime(dir_id, base::Time::Now())) |
| 94 NOTREACHED(); | 94 NOTREACHED(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 const base::FilePath::CharType kTemporaryDirectoryName[] = FILE_PATH_LITERAL("t"
); | 97 const base::FilePath::CharType kTemporaryDirectoryName[] = FILE_PATH_LITERAL("t"
); |
| 98 const base::FilePath::CharType kPersistentDirectoryName[] = FILE_PATH_LITERAL("p
"); | 98 const base::FilePath::CharType kPersistentDirectoryName[] = FILE_PATH_LITERAL("p
"); |
| 99 const base::FilePath::CharType kSyncableDirectoryName[] = FILE_PATH_LITERAL("s")
; | 99 const base::FilePath::CharType kSyncableDirectoryName[] = FILE_PATH_LITERAL("s")
; |
| 100 | 100 |
| 101 } // namespace | 101 } // namespace |
| 102 | 102 |
| 103 using base::PlatformFile; | 103 using base::PlatformFile; |
| 104 using base::PlatformFileError; | 104 using base::PlatformFileError; |
| 105 | 105 |
| 106 class ObfuscatedFileEnumerator | 106 class ObfuscatedFileEnumerator |
| 107 : public FileSystemFileUtil::AbstractFileEnumerator { | 107 : public FileSystemFileUtil::AbstractFileEnumerator { |
| 108 public: | 108 public: |
| 109 ObfuscatedFileEnumerator( | 109 ObfuscatedFileEnumerator( |
| 110 FileSystemDirectoryDatabase* db, | 110 SandboxDirectoryDatabase* db, |
| 111 FileSystemOperationContext* context, | 111 FileSystemOperationContext* context, |
| 112 ObfuscatedFileUtil* obfuscated_file_util, | 112 ObfuscatedFileUtil* obfuscated_file_util, |
| 113 const FileSystemURL& root_url, | 113 const FileSystemURL& root_url, |
| 114 bool recursive) | 114 bool recursive) |
| 115 : db_(db), | 115 : db_(db), |
| 116 context_(context), | 116 context_(context), |
| 117 obfuscated_file_util_(obfuscated_file_util), | 117 obfuscated_file_util_(obfuscated_file_util), |
| 118 origin_(root_url.origin()), | 118 origin_(root_url.origin()), |
| 119 type_(root_url.type()), | 119 type_(root_url.type()), |
| 120 recursive_(recursive), | 120 recursive_(recursive), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 virtual base::Time LastModifiedTime() OVERRIDE { | 164 virtual base::Time LastModifiedTime() OVERRIDE { |
| 165 return current_platform_file_info_.last_modified; | 165 return current_platform_file_info_.last_modified; |
| 166 } | 166 } |
| 167 | 167 |
| 168 virtual bool IsDirectory() OVERRIDE { | 168 virtual bool IsDirectory() OVERRIDE { |
| 169 return current_platform_file_info_.is_directory; | 169 return current_platform_file_info_.is_directory; |
| 170 } | 170 } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 typedef FileSystemDirectoryDatabase::FileId FileId; | 173 typedef SandboxDirectoryDatabase::FileId FileId; |
| 174 typedef FileSystemDirectoryDatabase::FileInfo FileInfo; | 174 typedef SandboxDirectoryDatabase::FileInfo FileInfo; |
| 175 | 175 |
| 176 struct FileRecord { | 176 struct FileRecord { |
| 177 FileId file_id; | 177 FileId file_id; |
| 178 base::FilePath virtual_path; | 178 base::FilePath virtual_path; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 void ProcessRecurseQueue() { | 181 void ProcessRecurseQueue() { |
| 182 while (display_stack_.empty() && !recurse_queue_.empty()) { | 182 while (display_stack_.empty() && !recurse_queue_.empty()) { |
| 183 FileRecord entry = recurse_queue_.front(); | 183 FileRecord entry = recurse_queue_.front(); |
| 184 recurse_queue_.pop(); | 184 recurse_queue_.pop(); |
| 185 if (!db_->ListChildren(entry.file_id, &display_stack_)) { | 185 if (!db_->ListChildren(entry.file_id, &display_stack_)) { |
| 186 display_stack_.clear(); | 186 display_stack_.clear(); |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 current_parent_virtual_path_ = entry.virtual_path; | 189 current_parent_virtual_path_ = entry.virtual_path; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 FileSystemDirectoryDatabase* db_; | 193 SandboxDirectoryDatabase* db_; |
| 194 FileSystemOperationContext* context_; | 194 FileSystemOperationContext* context_; |
| 195 ObfuscatedFileUtil* obfuscated_file_util_; | 195 ObfuscatedFileUtil* obfuscated_file_util_; |
| 196 GURL origin_; | 196 GURL origin_; |
| 197 FileSystemType type_; | 197 FileSystemType type_; |
| 198 bool recursive_; | 198 bool recursive_; |
| 199 | 199 |
| 200 std::queue<FileRecord> recurse_queue_; | 200 std::queue<FileRecord> recurse_queue_; |
| 201 std::vector<FileId> display_stack_; | 201 std::vector<FileId> display_stack_; |
| 202 base::FilePath current_parent_virtual_path_; | 202 base::FilePath current_parent_virtual_path_; |
| 203 | 203 |
| 204 FileId current_file_id_; | 204 FileId current_file_id_; |
| 205 base::PlatformFileInfo current_platform_file_info_; | 205 base::PlatformFileInfo current_platform_file_info_; |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 class ObfuscatedOriginEnumerator | 208 class ObfuscatedOriginEnumerator |
| 209 : public ObfuscatedFileUtil::AbstractOriginEnumerator { | 209 : public ObfuscatedFileUtil::AbstractOriginEnumerator { |
| 210 public: | 210 public: |
| 211 typedef FileSystemOriginDatabase::OriginRecord OriginRecord; | 211 typedef SandboxOriginDatabase::OriginRecord OriginRecord; |
| 212 ObfuscatedOriginEnumerator( | 212 ObfuscatedOriginEnumerator( |
| 213 FileSystemOriginDatabase* origin_database, | 213 SandboxOriginDatabase* origin_database, |
| 214 const base::FilePath& base_file_path) | 214 const base::FilePath& base_file_path) |
| 215 : base_file_path_(base_file_path) { | 215 : base_file_path_(base_file_path) { |
| 216 if (origin_database) | 216 if (origin_database) |
| 217 origin_database->ListAllOrigins(&origins_); | 217 origin_database->ListAllOrigins(&origins_); |
| 218 } | 218 } |
| 219 | 219 |
| 220 virtual ~ObfuscatedOriginEnumerator() {} | 220 virtual ~ObfuscatedOriginEnumerator() {} |
| 221 | 221 |
| 222 // Returns the next origin. Returns empty if there are no more origins. | 222 // Returns the next origin. Returns empty if there are no more origins. |
| 223 virtual GURL Next() OVERRIDE { | 223 virtual GURL Next() OVERRIDE { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 PlatformFileError ObfuscatedFileUtil::Close( | 279 PlatformFileError ObfuscatedFileUtil::Close( |
| 280 FileSystemOperationContext* context, | 280 FileSystemOperationContext* context, |
| 281 base::PlatformFile file) { | 281 base::PlatformFile file) { |
| 282 return NativeFileUtil::Close(file); | 282 return NativeFileUtil::Close(file); |
| 283 } | 283 } |
| 284 | 284 |
| 285 PlatformFileError ObfuscatedFileUtil::EnsureFileExists( | 285 PlatformFileError ObfuscatedFileUtil::EnsureFileExists( |
| 286 FileSystemOperationContext* context, | 286 FileSystemOperationContext* context, |
| 287 const FileSystemURL& url, | 287 const FileSystemURL& url, |
| 288 bool* created) { | 288 bool* created) { |
| 289 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 289 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 290 url.origin(), url.type(), true); | 290 url.origin(), url.type(), true); |
| 291 if (!db) | 291 if (!db) |
| 292 return base::PLATFORM_FILE_ERROR_FAILED; | 292 return base::PLATFORM_FILE_ERROR_FAILED; |
| 293 | 293 |
| 294 FileId file_id; | 294 FileId file_id; |
| 295 if (db->GetFileWithPath(url.path(), &file_id)) { | 295 if (db->GetFileWithPath(url.path(), &file_id)) { |
| 296 FileInfo file_info; | 296 FileInfo file_info; |
| 297 if (!db->GetFileInfo(file_id, &file_info)) { | 297 if (!db->GetFileInfo(file_id, &file_info)) { |
| 298 NOTREACHED(); | 298 NOTREACHED(); |
| 299 return base::PLATFORM_FILE_ERROR_FAILED; | 299 return base::PLATFORM_FILE_ERROR_FAILED; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 324 &FileChangeObserver::OnCreateFile, MakeTuple(url)); | 324 &FileChangeObserver::OnCreateFile, MakeTuple(url)); |
| 325 } | 325 } |
| 326 return error; | 326 return error; |
| 327 } | 327 } |
| 328 | 328 |
| 329 PlatformFileError ObfuscatedFileUtil::CreateDirectory( | 329 PlatformFileError ObfuscatedFileUtil::CreateDirectory( |
| 330 FileSystemOperationContext* context, | 330 FileSystemOperationContext* context, |
| 331 const FileSystemURL& url, | 331 const FileSystemURL& url, |
| 332 bool exclusive, | 332 bool exclusive, |
| 333 bool recursive) { | 333 bool recursive) { |
| 334 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 334 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 335 url.origin(), url.type(), true); | 335 url.origin(), url.type(), true); |
| 336 if (!db) | 336 if (!db) |
| 337 return base::PLATFORM_FILE_ERROR_FAILED; | 337 return base::PLATFORM_FILE_ERROR_FAILED; |
| 338 | 338 |
| 339 // TODO(kinuko): Remove this dirty hack when we fully support directory | 339 // TODO(kinuko): Remove this dirty hack when we fully support directory |
| 340 // operations or clean up the code if we decided not to support directory | 340 // operations or clean up the code if we decided not to support directory |
| 341 // operations. (http://crbug.com/161442) | 341 // operations. (http://crbug.com/161442) |
| 342 if (url.type() == kFileSystemTypeSyncable && | 342 if (url.type() == kFileSystemTypeSyncable && |
| 343 !sync_file_system::IsSyncDirectoryOperationEnabled()) { | 343 !sync_file_system::IsSyncDirectoryOperationEnabled()) { |
| 344 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | 344 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 return base::PLATFORM_FILE_OK; | 397 return base::PLATFORM_FILE_OK; |
| 398 } | 398 } |
| 399 | 399 |
| 400 PlatformFileError ObfuscatedFileUtil::GetFileInfo( | 400 PlatformFileError ObfuscatedFileUtil::GetFileInfo( |
| 401 FileSystemOperationContext* context, | 401 FileSystemOperationContext* context, |
| 402 const FileSystemURL& url, | 402 const FileSystemURL& url, |
| 403 base::PlatformFileInfo* file_info, | 403 base::PlatformFileInfo* file_info, |
| 404 base::FilePath* platform_file_path) { | 404 base::FilePath* platform_file_path) { |
| 405 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 405 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 406 url.origin(), url.type(), false); | 406 url.origin(), url.type(), false); |
| 407 if (!db) | 407 if (!db) |
| 408 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 408 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 409 FileId file_id; | 409 FileId file_id; |
| 410 if (!db->GetFileWithPath(url.path(), &file_id)) | 410 if (!db->GetFileWithPath(url.path(), &file_id)) |
| 411 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 411 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 412 FileInfo local_info; | 412 FileInfo local_info; |
| 413 return GetFileInfoInternal(db, context, | 413 return GetFileInfoInternal(db, context, |
| 414 url.origin(), url.type(), | 414 url.origin(), url.type(), |
| 415 file_id, &local_info, | 415 file_id, &local_info, |
| 416 file_info, platform_file_path); | 416 file_info, platform_file_path); |
| 417 } | 417 } |
| 418 | 418 |
| 419 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 419 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
| 420 ObfuscatedFileUtil::CreateFileEnumerator( | 420 ObfuscatedFileUtil::CreateFileEnumerator( |
| 421 FileSystemOperationContext* context, | 421 FileSystemOperationContext* context, |
| 422 const FileSystemURL& root_url) { | 422 const FileSystemURL& root_url) { |
| 423 return CreateFileEnumerator(context, root_url, false /* recursive */); | 423 return CreateFileEnumerator(context, root_url, false /* recursive */); |
| 424 } | 424 } |
| 425 | 425 |
| 426 PlatformFileError ObfuscatedFileUtil::GetLocalFilePath( | 426 PlatformFileError ObfuscatedFileUtil::GetLocalFilePath( |
| 427 FileSystemOperationContext* context, | 427 FileSystemOperationContext* context, |
| 428 const FileSystemURL& url, | 428 const FileSystemURL& url, |
| 429 base::FilePath* local_path) { | 429 base::FilePath* local_path) { |
| 430 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 430 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 431 url.origin(), url.type(), false); | 431 url.origin(), url.type(), false); |
| 432 if (!db) | 432 if (!db) |
| 433 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 433 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 434 FileId file_id; | 434 FileId file_id; |
| 435 if (!db->GetFileWithPath(url.path(), &file_id)) | 435 if (!db->GetFileWithPath(url.path(), &file_id)) |
| 436 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 436 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 437 FileInfo file_info; | 437 FileInfo file_info; |
| 438 if (!db->GetFileInfo(file_id, &file_info) || file_info.is_directory()) { | 438 if (!db->GetFileInfo(file_id, &file_info) || file_info.is_directory()) { |
| 439 NOTREACHED(); | 439 NOTREACHED(); |
| 440 // Directories have no local file path. | 440 // Directories have no local file path. |
| 441 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 441 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 442 } | 442 } |
| 443 *local_path = DataPathToLocalPath( | 443 *local_path = DataPathToLocalPath( |
| 444 url.origin(), url.type(), file_info.data_path); | 444 url.origin(), url.type(), file_info.data_path); |
| 445 | 445 |
| 446 if (local_path->empty()) | 446 if (local_path->empty()) |
| 447 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 447 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 448 return base::PLATFORM_FILE_OK; | 448 return base::PLATFORM_FILE_OK; |
| 449 } | 449 } |
| 450 | 450 |
| 451 PlatformFileError ObfuscatedFileUtil::Touch( | 451 PlatformFileError ObfuscatedFileUtil::Touch( |
| 452 FileSystemOperationContext* context, | 452 FileSystemOperationContext* context, |
| 453 const FileSystemURL& url, | 453 const FileSystemURL& url, |
| 454 const base::Time& last_access_time, | 454 const base::Time& last_access_time, |
| 455 const base::Time& last_modified_time) { | 455 const base::Time& last_modified_time) { |
| 456 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 456 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 457 url.origin(), url.type(), false); | 457 url.origin(), url.type(), false); |
| 458 if (!db) | 458 if (!db) |
| 459 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 459 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 460 FileId file_id; | 460 FileId file_id; |
| 461 if (!db->GetFileWithPath(url.path(), &file_id)) | 461 if (!db->GetFileWithPath(url.path(), &file_id)) |
| 462 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 462 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 463 | 463 |
| 464 FileInfo file_info; | 464 FileInfo file_info; |
| 465 if (!db->GetFileInfo(file_id, &file_info)) { | 465 if (!db->GetFileInfo(file_id, &file_info)) { |
| 466 NOTREACHED(); | 466 NOTREACHED(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 502 |
| 503 PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile( | 503 PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile( |
| 504 FileSystemOperationContext* context, | 504 FileSystemOperationContext* context, |
| 505 const FileSystemURL& src_url, | 505 const FileSystemURL& src_url, |
| 506 const FileSystemURL& dest_url, | 506 const FileSystemURL& dest_url, |
| 507 bool copy) { | 507 bool copy) { |
| 508 // Cross-filesystem copies and moves should be handled via CopyInForeignFile. | 508 // Cross-filesystem copies and moves should be handled via CopyInForeignFile. |
| 509 DCHECK(src_url.origin() == dest_url.origin()); | 509 DCHECK(src_url.origin() == dest_url.origin()); |
| 510 DCHECK(src_url.type() == dest_url.type()); | 510 DCHECK(src_url.type() == dest_url.type()); |
| 511 | 511 |
| 512 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 512 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 513 src_url.origin(), src_url.type(), true); | 513 src_url.origin(), src_url.type(), true); |
| 514 if (!db) | 514 if (!db) |
| 515 return base::PLATFORM_FILE_ERROR_FAILED; | 515 return base::PLATFORM_FILE_ERROR_FAILED; |
| 516 | 516 |
| 517 FileId src_file_id; | 517 FileId src_file_id; |
| 518 if (!db->GetFileWithPath(src_url.path(), &src_file_id)) | 518 if (!db->GetFileWithPath(src_url.path(), &src_file_id)) |
| 519 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 519 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 520 | 520 |
| 521 FileId dest_file_id; | 521 FileId dest_file_id; |
| 522 bool overwrite = db->GetFileWithPath(dest_url.path(), | 522 bool overwrite = db->GetFileWithPath(dest_url.path(), |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 TouchDirectory(db, dest_file_info.parent_id); | 638 TouchDirectory(db, dest_file_info.parent_id); |
| 639 | 639 |
| 640 UpdateUsage(context, dest_url, growth); | 640 UpdateUsage(context, dest_url, growth); |
| 641 return error; | 641 return error; |
| 642 } | 642 } |
| 643 | 643 |
| 644 PlatformFileError ObfuscatedFileUtil::CopyInForeignFile( | 644 PlatformFileError ObfuscatedFileUtil::CopyInForeignFile( |
| 645 FileSystemOperationContext* context, | 645 FileSystemOperationContext* context, |
| 646 const base::FilePath& src_file_path, | 646 const base::FilePath& src_file_path, |
| 647 const FileSystemURL& dest_url) { | 647 const FileSystemURL& dest_url) { |
| 648 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 648 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 649 dest_url.origin(), dest_url.type(), true); | 649 dest_url.origin(), dest_url.type(), true); |
| 650 if (!db) | 650 if (!db) |
| 651 return base::PLATFORM_FILE_ERROR_FAILED; | 651 return base::PLATFORM_FILE_ERROR_FAILED; |
| 652 | 652 |
| 653 base::PlatformFileInfo src_platform_file_info; | 653 base::PlatformFileInfo src_platform_file_info; |
| 654 if (!file_util::GetFileInfo(src_file_path, &src_platform_file_info)) | 654 if (!file_util::GetFileInfo(src_file_path, &src_platform_file_info)) |
| 655 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 655 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 656 | 656 |
| 657 FileId dest_file_id; | 657 FileId dest_file_id; |
| 658 bool overwrite = db->GetFileWithPath(dest_url.path(), | 658 bool overwrite = db->GetFileWithPath(dest_url.path(), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 716 } |
| 717 | 717 |
| 718 UpdateUsage(context, dest_url, growth); | 718 UpdateUsage(context, dest_url, growth); |
| 719 TouchDirectory(db, dest_file_info.parent_id); | 719 TouchDirectory(db, dest_file_info.parent_id); |
| 720 return base::PLATFORM_FILE_OK; | 720 return base::PLATFORM_FILE_OK; |
| 721 } | 721 } |
| 722 | 722 |
| 723 PlatformFileError ObfuscatedFileUtil::DeleteFile( | 723 PlatformFileError ObfuscatedFileUtil::DeleteFile( |
| 724 FileSystemOperationContext* context, | 724 FileSystemOperationContext* context, |
| 725 const FileSystemURL& url) { | 725 const FileSystemURL& url) { |
| 726 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 726 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 727 url.origin(), url.type(), true); | 727 url.origin(), url.type(), true); |
| 728 if (!db) | 728 if (!db) |
| 729 return base::PLATFORM_FILE_ERROR_FAILED; | 729 return base::PLATFORM_FILE_ERROR_FAILED; |
| 730 FileId file_id; | 730 FileId file_id; |
| 731 if (!db->GetFileWithPath(url.path(), &file_id)) | 731 if (!db->GetFileWithPath(url.path(), &file_id)) |
| 732 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 732 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 733 | 733 |
| 734 FileInfo file_info; | 734 FileInfo file_info; |
| 735 base::PlatformFileInfo platform_file_info; | 735 base::PlatformFileInfo platform_file_info; |
| 736 base::FilePath local_path; | 736 base::FilePath local_path; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 761 | 761 |
| 762 error = NativeFileUtil::DeleteFile(local_path); | 762 error = NativeFileUtil::DeleteFile(local_path); |
| 763 if (base::PLATFORM_FILE_OK != error) | 763 if (base::PLATFORM_FILE_OK != error) |
| 764 LOG(WARNING) << "Leaked a backing file."; | 764 LOG(WARNING) << "Leaked a backing file."; |
| 765 return base::PLATFORM_FILE_OK; | 765 return base::PLATFORM_FILE_OK; |
| 766 } | 766 } |
| 767 | 767 |
| 768 PlatformFileError ObfuscatedFileUtil::DeleteDirectory( | 768 PlatformFileError ObfuscatedFileUtil::DeleteDirectory( |
| 769 FileSystemOperationContext* context, | 769 FileSystemOperationContext* context, |
| 770 const FileSystemURL& url) { | 770 const FileSystemURL& url) { |
| 771 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 771 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 772 url.origin(), url.type(), true); | 772 url.origin(), url.type(), true); |
| 773 if (!db) | 773 if (!db) |
| 774 return base::PLATFORM_FILE_ERROR_FAILED; | 774 return base::PLATFORM_FILE_ERROR_FAILED; |
| 775 | 775 |
| 776 FileId file_id; | 776 FileId file_id; |
| 777 if (!db->GetFileWithPath(url.path(), &file_id)) | 777 if (!db->GetFileWithPath(url.path(), &file_id)) |
| 778 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 778 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 779 FileInfo file_info; | 779 FileInfo file_info; |
| 780 if (!db->GetFileInfo(file_id, &file_info)) { | 780 if (!db->GetFileInfo(file_id, &file_info)) { |
| 781 NOTREACHED(); | 781 NOTREACHED(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 807 *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE; | 807 *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE; |
| 808 } | 808 } |
| 809 return webkit_blob::ScopedFile(); | 809 return webkit_blob::ScopedFile(); |
| 810 } | 810 } |
| 811 | 811 |
| 812 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 812 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
| 813 ObfuscatedFileUtil::CreateFileEnumerator( | 813 ObfuscatedFileUtil::CreateFileEnumerator( |
| 814 FileSystemOperationContext* context, | 814 FileSystemOperationContext* context, |
| 815 const FileSystemURL& root_url, | 815 const FileSystemURL& root_url, |
| 816 bool recursive) { | 816 bool recursive) { |
| 817 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 817 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 818 root_url.origin(), root_url.type(), false); | 818 root_url.origin(), root_url.type(), false); |
| 819 if (!db) { | 819 if (!db) { |
| 820 return scoped_ptr<AbstractFileEnumerator>(new EmptyFileEnumerator()); | 820 return scoped_ptr<AbstractFileEnumerator>(new EmptyFileEnumerator()); |
| 821 } | 821 } |
| 822 return scoped_ptr<AbstractFileEnumerator>( | 822 return scoped_ptr<AbstractFileEnumerator>( |
| 823 new ObfuscatedFileEnumerator(db, context, this, root_url, recursive)); | 823 new ObfuscatedFileEnumerator(db, context, this, root_url, recursive)); |
| 824 } | 824 } |
| 825 | 825 |
| 826 bool ObfuscatedFileUtil::IsDirectoryEmpty( | 826 bool ObfuscatedFileUtil::IsDirectoryEmpty( |
| 827 FileSystemOperationContext* context, | 827 FileSystemOperationContext* context, |
| 828 const FileSystemURL& url) { | 828 const FileSystemURL& url) { |
| 829 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 829 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 830 url.origin(), url.type(), false); | 830 url.origin(), url.type(), false); |
| 831 if (!db) | 831 if (!db) |
| 832 return true; // Not a great answer, but it's what others do. | 832 return true; // Not a great answer, but it's what others do. |
| 833 FileId file_id; | 833 FileId file_id; |
| 834 if (!db->GetFileWithPath(url.path(), &file_id)) | 834 if (!db->GetFileWithPath(url.path(), &file_id)) |
| 835 return true; // Ditto. | 835 return true; // Ditto. |
| 836 FileInfo file_info; | 836 FileInfo file_info; |
| 837 if (!db->GetFileInfo(file_id, &file_info)) { | 837 if (!db->GetFileInfo(file_id, &file_info)) { |
| 838 DCHECK(!file_id); | 838 DCHECK(!file_id); |
| 839 // It's the root directory and the database hasn't been initialized yet. | 839 // It's the root directory and the database hasn't been initialized yet. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 case kFileSystemTypeSyncable: | 943 case kFileSystemTypeSyncable: |
| 944 return kSyncableDirectoryName; | 944 return kSyncableDirectoryName; |
| 945 case kFileSystemTypeUnknown: | 945 case kFileSystemTypeUnknown: |
| 946 default: | 946 default: |
| 947 return base::FilePath::StringType(); | 947 return base::FilePath::StringType(); |
| 948 } | 948 } |
| 949 } | 949 } |
| 950 | 950 |
| 951 ObfuscatedFileUtil::AbstractOriginEnumerator* | 951 ObfuscatedFileUtil::AbstractOriginEnumerator* |
| 952 ObfuscatedFileUtil::CreateOriginEnumerator() { | 952 ObfuscatedFileUtil::CreateOriginEnumerator() { |
| 953 std::vector<FileSystemOriginDatabase::OriginRecord> origins; | 953 std::vector<SandboxOriginDatabase::OriginRecord> origins; |
| 954 | 954 |
| 955 InitOriginDatabase(false); | 955 InitOriginDatabase(false); |
| 956 return new ObfuscatedOriginEnumerator( | 956 return new ObfuscatedOriginEnumerator( |
| 957 origin_database_.get(), file_system_directory_); | 957 origin_database_.get(), file_system_directory_); |
| 958 } | 958 } |
| 959 | 959 |
| 960 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( | 960 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( |
| 961 const GURL& origin, FileSystemType type) { | 961 const GURL& origin, FileSystemType type) { |
| 962 std::string type_string = GetFileSystemTypeString(type); | 962 std::string type_string = GetFileSystemTypeString(type); |
| 963 if (type_string.empty()) { | 963 if (type_string.empty()) { |
| 964 LOG(WARNING) << "Unknown filesystem type requested:" << type; | 964 LOG(WARNING) << "Unknown filesystem type requested:" << type; |
| 965 return true; | 965 return true; |
| 966 } | 966 } |
| 967 std::string key = | 967 std::string key = |
| 968 UTF16ToUTF8(webkit_base::GetOriginIdentifierFromURL(origin)) + | 968 UTF16ToUTF8(webkit_base::GetOriginIdentifierFromURL(origin)) + |
| 969 type_string; | 969 type_string; |
| 970 DirectoryMap::iterator iter = directories_.find(key); | 970 DirectoryMap::iterator iter = directories_.find(key); |
| 971 if (iter != directories_.end()) { | 971 if (iter != directories_.end()) { |
| 972 FileSystemDirectoryDatabase* database = iter->second; | 972 SandboxDirectoryDatabase* database = iter->second; |
| 973 directories_.erase(iter); | 973 directories_.erase(iter); |
| 974 delete database; | 974 delete database; |
| 975 } | 975 } |
| 976 | 976 |
| 977 PlatformFileError error = base::PLATFORM_FILE_OK; | 977 PlatformFileError error = base::PLATFORM_FILE_OK; |
| 978 base::FilePath path = GetDirectoryForOriginAndType(origin, type, false, &error
); | 978 base::FilePath path = GetDirectoryForOriginAndType(origin, type, false, &error
); |
| 979 if (path.empty() || error == base::PLATFORM_FILE_ERROR_NOT_FOUND) | 979 if (path.empty() || error == base::PLATFORM_FILE_ERROR_NOT_FOUND) |
| 980 return true; | 980 return true; |
| 981 return FileSystemDirectoryDatabase::DestroyDatabase(path); | 981 return SandboxDirectoryDatabase::DestroyDatabase(path); |
| 982 } | 982 } |
| 983 | 983 |
| 984 // static | 984 // static |
| 985 int64 ObfuscatedFileUtil::ComputeFilePathCost(const base::FilePath& path) { | 985 int64 ObfuscatedFileUtil::ComputeFilePathCost(const base::FilePath& path) { |
| 986 return UsageForPath(VirtualPath::BaseName(path).value().size()); | 986 return UsageForPath(VirtualPath::BaseName(path).value().size()); |
| 987 } | 987 } |
| 988 | 988 |
| 989 PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal( | 989 PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal( |
| 990 FileSystemDirectoryDatabase* db, | 990 SandboxDirectoryDatabase* db, |
| 991 FileSystemOperationContext* context, | 991 FileSystemOperationContext* context, |
| 992 const GURL& origin, | 992 const GURL& origin, |
| 993 FileSystemType type, | 993 FileSystemType type, |
| 994 FileId file_id, | 994 FileId file_id, |
| 995 FileInfo* local_info, | 995 FileInfo* local_info, |
| 996 base::PlatformFileInfo* file_info, | 996 base::PlatformFileInfo* file_info, |
| 997 base::FilePath* platform_file_path) { | 997 base::FilePath* platform_file_path) { |
| 998 DCHECK(db); | 998 DCHECK(db); |
| 999 DCHECK(context); | 999 DCHECK(context); |
| 1000 DCHECK(file_info); | 1000 DCHECK(file_info); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 PlatformFileError ObfuscatedFileUtil::CreateFile( | 1039 PlatformFileError ObfuscatedFileUtil::CreateFile( |
| 1040 FileSystemOperationContext* context, | 1040 FileSystemOperationContext* context, |
| 1041 const base::FilePath& src_file_path, | 1041 const base::FilePath& src_file_path, |
| 1042 const GURL& dest_origin, | 1042 const GURL& dest_origin, |
| 1043 FileSystemType dest_type, | 1043 FileSystemType dest_type, |
| 1044 FileInfo* dest_file_info, int file_flags, PlatformFile* handle) { | 1044 FileInfo* dest_file_info, int file_flags, PlatformFile* handle) { |
| 1045 if (handle) | 1045 if (handle) |
| 1046 *handle = base::kInvalidPlatformFileValue; | 1046 *handle = base::kInvalidPlatformFileValue; |
| 1047 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 1047 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 1048 dest_origin, dest_type, true); | 1048 dest_origin, dest_type, true); |
| 1049 | 1049 |
| 1050 PlatformFileError error = base::PLATFORM_FILE_OK; | 1050 PlatformFileError error = base::PLATFORM_FILE_OK; |
| 1051 base::FilePath root = GetDirectoryForOriginAndType(dest_origin, dest_type, fal
se, | 1051 base::FilePath root = GetDirectoryForOriginAndType(dest_origin, dest_type, fal
se, |
| 1052 &error); | 1052 &error); |
| 1053 if (error != base::PLATFORM_FILE_OK) | 1053 if (error != base::PLATFORM_FILE_OK) |
| 1054 return error; | 1054 return error; |
| 1055 | 1055 |
| 1056 base::FilePath dest_local_path; | 1056 base::FilePath dest_local_path; |
| 1057 error = GenerateNewLocalPath(db, context, dest_origin, dest_type, | 1057 error = GenerateNewLocalPath(db, context, dest_origin, dest_type, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 base::FilePath root = GetDirectoryForOriginAndType(origin, type, false, &error
); | 1123 base::FilePath root = GetDirectoryForOriginAndType(origin, type, false, &error
); |
| 1124 if (error != base::PLATFORM_FILE_OK) | 1124 if (error != base::PLATFORM_FILE_OK) |
| 1125 return base::FilePath(); | 1125 return base::FilePath(); |
| 1126 return root.Append(data_path); | 1126 return root.Append(data_path); |
| 1127 } | 1127 } |
| 1128 | 1128 |
| 1129 // TODO(ericu): How to do the whole validation-without-creation thing? | 1129 // TODO(ericu): How to do the whole validation-without-creation thing? |
| 1130 // We may not have quota even to create the database. | 1130 // We may not have quota even to create the database. |
| 1131 // Ah, in that case don't even get here? | 1131 // Ah, in that case don't even get here? |
| 1132 // Still doesn't answer the quota issue, though. | 1132 // Still doesn't answer the quota issue, though. |
| 1133 FileSystemDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase( | 1133 SandboxDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase( |
| 1134 const GURL& origin, FileSystemType type, bool create) { | 1134 const GURL& origin, FileSystemType type, bool create) { |
| 1135 std::string type_string = GetFileSystemTypeString(type); | 1135 std::string type_string = GetFileSystemTypeString(type); |
| 1136 if (type_string.empty()) { | 1136 if (type_string.empty()) { |
| 1137 LOG(WARNING) << "Unknown filesystem type requested:" << type; | 1137 LOG(WARNING) << "Unknown filesystem type requested:" << type; |
| 1138 return NULL; | 1138 return NULL; |
| 1139 } | 1139 } |
| 1140 std::string key = | 1140 std::string key = |
| 1141 UTF16ToUTF8(webkit_base::GetOriginIdentifierFromURL(origin)) + | 1141 UTF16ToUTF8(webkit_base::GetOriginIdentifierFromURL(origin)) + |
| 1142 type_string; | 1142 type_string; |
| 1143 DirectoryMap::iterator iter = directories_.find(key); | 1143 DirectoryMap::iterator iter = directories_.find(key); |
| 1144 if (iter != directories_.end()) { | 1144 if (iter != directories_.end()) { |
| 1145 MarkUsed(); | 1145 MarkUsed(); |
| 1146 return iter->second; | 1146 return iter->second; |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 PlatformFileError error = base::PLATFORM_FILE_OK; | 1149 PlatformFileError error = base::PLATFORM_FILE_OK; |
| 1150 base::FilePath path = GetDirectoryForOriginAndType(origin, type, create, &erro
r); | 1150 base::FilePath path = GetDirectoryForOriginAndType(origin, type, create, &erro
r); |
| 1151 if (error != base::PLATFORM_FILE_OK) { | 1151 if (error != base::PLATFORM_FILE_OK) { |
| 1152 LOG(WARNING) << "Failed to get origin+type directory: " << path.value(); | 1152 LOG(WARNING) << "Failed to get origin+type directory: " << path.value(); |
| 1153 return NULL; | 1153 return NULL; |
| 1154 } | 1154 } |
| 1155 MarkUsed(); | 1155 MarkUsed(); |
| 1156 FileSystemDirectoryDatabase* database = new FileSystemDirectoryDatabase(path); | 1156 SandboxDirectoryDatabase* database = new SandboxDirectoryDatabase(path); |
| 1157 directories_[key] = database; | 1157 directories_[key] = database; |
| 1158 return database; | 1158 return database; |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin( | 1161 base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin( |
| 1162 const GURL& origin, bool create, base::PlatformFileError* error_code) { | 1162 const GURL& origin, bool create, base::PlatformFileError* error_code) { |
| 1163 if (!InitOriginDatabase(create)) { | 1163 if (!InitOriginDatabase(create)) { |
| 1164 if (error_code) { | 1164 if (error_code) { |
| 1165 *error_code = create ? | 1165 *error_code = create ? |
| 1166 base::PLATFORM_FILE_ERROR_FAILED : | 1166 base::PLATFORM_FILE_ERROR_FAILED : |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 bool ObfuscatedFileUtil::InitOriginDatabase(bool create) { | 1236 bool ObfuscatedFileUtil::InitOriginDatabase(bool create) { |
| 1237 if (!origin_database_) { | 1237 if (!origin_database_) { |
| 1238 if (!create && !file_util::DirectoryExists(file_system_directory_)) | 1238 if (!create && !file_util::DirectoryExists(file_system_directory_)) |
| 1239 return false; | 1239 return false; |
| 1240 if (!file_util::CreateDirectory(file_system_directory_)) { | 1240 if (!file_util::CreateDirectory(file_system_directory_)) { |
| 1241 LOG(WARNING) << "Failed to create FileSystem directory: " << | 1241 LOG(WARNING) << "Failed to create FileSystem directory: " << |
| 1242 file_system_directory_.value(); | 1242 file_system_directory_.value(); |
| 1243 return false; | 1243 return false; |
| 1244 } | 1244 } |
| 1245 origin_database_.reset( | 1245 origin_database_.reset( |
| 1246 new FileSystemOriginDatabase(file_system_directory_)); | 1246 new SandboxOriginDatabase(file_system_directory_)); |
| 1247 } | 1247 } |
| 1248 return true; | 1248 return true; |
| 1249 } | 1249 } |
| 1250 | 1250 |
| 1251 PlatformFileError ObfuscatedFileUtil::GenerateNewLocalPath( | 1251 PlatformFileError ObfuscatedFileUtil::GenerateNewLocalPath( |
| 1252 FileSystemDirectoryDatabase* db, | 1252 SandboxDirectoryDatabase* db, |
| 1253 FileSystemOperationContext* context, | 1253 FileSystemOperationContext* context, |
| 1254 const GURL& origin, | 1254 const GURL& origin, |
| 1255 FileSystemType type, | 1255 FileSystemType type, |
| 1256 base::FilePath* local_path) { | 1256 base::FilePath* local_path) { |
| 1257 DCHECK(local_path); | 1257 DCHECK(local_path); |
| 1258 int64 number; | 1258 int64 number; |
| 1259 if (!db || !db->GetNextInteger(&number)) | 1259 if (!db || !db->GetNextInteger(&number)) |
| 1260 return base::PLATFORM_FILE_ERROR_FAILED; | 1260 return base::PLATFORM_FILE_ERROR_FAILED; |
| 1261 | 1261 |
| 1262 PlatformFileError error = base::PLATFORM_FILE_OK; | 1262 PlatformFileError error = base::PLATFORM_FILE_OK; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1280 return base::PLATFORM_FILE_OK; | 1280 return base::PLATFORM_FILE_OK; |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 PlatformFileError ObfuscatedFileUtil::CreateOrOpenInternal( | 1283 PlatformFileError ObfuscatedFileUtil::CreateOrOpenInternal( |
| 1284 FileSystemOperationContext* context, | 1284 FileSystemOperationContext* context, |
| 1285 const FileSystemURL& url, int file_flags, | 1285 const FileSystemURL& url, int file_flags, |
| 1286 PlatformFile* file_handle, bool* created) { | 1286 PlatformFile* file_handle, bool* created) { |
| 1287 DCHECK(!(file_flags & (base::PLATFORM_FILE_DELETE_ON_CLOSE | | 1287 DCHECK(!(file_flags & (base::PLATFORM_FILE_DELETE_ON_CLOSE | |
| 1288 base::PLATFORM_FILE_HIDDEN | base::PLATFORM_FILE_EXCLUSIVE_READ | | 1288 base::PLATFORM_FILE_HIDDEN | base::PLATFORM_FILE_EXCLUSIVE_READ | |
| 1289 base::PLATFORM_FILE_EXCLUSIVE_WRITE))); | 1289 base::PLATFORM_FILE_EXCLUSIVE_WRITE))); |
| 1290 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 1290 SandboxDirectoryDatabase* db = GetDirectoryDatabase( |
| 1291 url.origin(), url.type(), true); | 1291 url.origin(), url.type(), true); |
| 1292 if (!db) | 1292 if (!db) |
| 1293 return base::PLATFORM_FILE_ERROR_FAILED; | 1293 return base::PLATFORM_FILE_ERROR_FAILED; |
| 1294 FileId file_id; | 1294 FileId file_id; |
| 1295 if (!db->GetFileWithPath(url.path(), &file_id)) { | 1295 if (!db->GetFileWithPath(url.path(), &file_id)) { |
| 1296 // The file doesn't exist. | 1296 // The file doesn't exist. |
| 1297 if (!(file_flags & (base::PLATFORM_FILE_CREATE | | 1297 if (!(file_flags & (base::PLATFORM_FILE_CREATE | |
| 1298 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_ALWAYS))) | 1298 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_ALWAYS))) |
| 1299 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 1299 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 1300 FileId parent_id; | 1300 FileId parent_id; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 // If truncating we need to update the usage. | 1356 // If truncating we need to update the usage. |
| 1357 if (error == base::PLATFORM_FILE_OK && delta) { | 1357 if (error == base::PLATFORM_FILE_OK && delta) { |
| 1358 UpdateUsage(context, url, delta); | 1358 UpdateUsage(context, url, delta); |
| 1359 context->change_observers()->Notify( | 1359 context->change_observers()->Notify( |
| 1360 &FileChangeObserver::OnModifyFile, MakeTuple(url)); | 1360 &FileChangeObserver::OnModifyFile, MakeTuple(url)); |
| 1361 } | 1361 } |
| 1362 return error; | 1362 return error; |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 } // namespace fileapi | 1365 } // namespace fileapi |
| OLD | NEW |