Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_callback_factory.h" | 9 #include "base/memory/scoped_callback_factory.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( | 543 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( |
| 544 sandbox_file_util_->CreateFileEnumerator(&context, FilePath())); | 544 sandbox_file_util_->CreateFileEnumerator(&context, FilePath())); |
| 545 | 545 |
| 546 FilePath file_path_each; | 546 FilePath file_path_each; |
| 547 int64 usage = 0; | 547 int64 usage = 0; |
| 548 | 548 |
| 549 // TODO(ericu): This could be made much more efficient if the | 549 // TODO(ericu): This could be made much more efficient if the |
| 550 // AbstractFileEnumerator also had an interface to tell you the size of the | 550 // AbstractFileEnumerator also had an interface to tell you the size of the |
| 551 // file. ObfuscatedFileSystemFileEnumerator has already looked up the data, | 551 // file. ObfuscatedFileSystemFileEnumerator has already looked up the data, |
| 552 // and it's a big waste to look it up again. The other implementers could | 552 // and it's a big waste to look it up again. The other implementers could |
| 553 // easily add it on-demand, so as not to waste time when it's not needed. | 553 // easily add it on-demand, so as not to waste time when it's not needed. |
|
kinuko
2011/08/25 09:28:49
Can we remove this TODO now?!
ericu
2011/08/25 18:29:30
Yes. [It was a little inaccurate anyway--we've al
tzik
2011/08/26 02:41:53
Done.
| |
| 554 while (!(file_path_each = enumerator->Next()).empty()) { | 554 while (!(file_path_each = enumerator->Next()).empty()) { |
| 555 base::PlatformFileInfo file_info; | 555 base::PlatformFileInfo file_info; |
| 556 FilePath platform_file_path; | 556 FilePath platform_file_path; |
| 557 if (!enumerator->IsDirectory()) { | 557 usage += enumerator->Size(); |
| 558 base::PlatformFileError error = sandbox_file_util_->GetFileInfo( | |
| 559 &context, file_path_each, &file_info, &platform_file_path); | |
| 560 if (error != base::PLATFORM_FILE_OK) | |
| 561 NOTREACHED(); | |
| 562 else | |
| 563 usage += file_info.size; | |
| 564 } | |
| 565 usage += ObfuscatedFileSystemFileUtil::ComputeFilePathCost(file_path_each); | 558 usage += ObfuscatedFileSystemFileUtil::ComputeFilePathCost(file_path_each); |
| 566 } | 559 } |
| 567 // This clears the dirty flag too. | 560 // This clears the dirty flag too. |
| 568 FileSystemUsageCache::UpdateUsage(usage_file_path, usage); | 561 FileSystemUsageCache::UpdateUsage(usage_file_path, usage); |
| 569 return usage; | 562 return usage; |
| 570 } | 563 } |
| 571 | 564 |
| 572 void SandboxMountPointProvider::NotifyOriginWasAccessedOnIOThread( | 565 void SandboxMountPointProvider::NotifyOriginWasAccessedOnIOThread( |
| 573 QuotaManagerProxy* proxy, const GURL& origin_url, | 566 QuotaManagerProxy* proxy, const GURL& origin_url, |
| 574 fileapi::FileSystemType type) { | 567 fileapi::FileSystemType type) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 | 644 |
| 652 // Creates the root directory. | 645 // Creates the root directory. |
| 653 root = origin_base_path.Append(OldCreateUniqueDirectoryName(origin_url)); | 646 root = origin_base_path.Append(OldCreateUniqueDirectoryName(origin_url)); |
| 654 if (!file_util::CreateDirectory(root)) | 647 if (!file_util::CreateDirectory(root)) |
| 655 return FilePath(); | 648 return FilePath(); |
| 656 | 649 |
| 657 return root; | 650 return root; |
| 658 } | 651 } |
| 659 | 652 |
| 660 } // namespace fileapi | 653 } // namespace fileapi |
| OLD | NEW |