| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool CreateFileSystemDirectory(const base::FilePath& file_path, | 121 bool CreateFileSystemDirectory(const base::FilePath& file_path, |
| 122 const std::string& origin_url, | 122 const std::string& origin_url, |
| 123 quota::StorageType storage_type) { | 123 quota::StorageType storage_type) { |
| 124 FileSystemType type = fileapi::QuotaStorageTypeToFileSystemType( | 124 FileSystemType type = fileapi::QuotaStorageTypeToFileSystemType( |
| 125 storage_type); | 125 storage_type); |
| 126 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( | 126 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( |
| 127 GURL(origin_url), type, file_path); | 127 GURL(origin_url), type, file_path); |
| 128 | 128 |
| 129 base::PlatformFileError result = | 129 base::File::Error result = |
| 130 AsyncFileTestHelper::CreateDirectory(file_system_context_, url); | 130 AsyncFileTestHelper::CreateDirectory(file_system_context_, url); |
| 131 return result == base::PLATFORM_FILE_OK; | 131 return result == base::File::FILE_OK; |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool CreateFileSystemFile(const base::FilePath& file_path, | 134 bool CreateFileSystemFile(const base::FilePath& file_path, |
| 135 int64 file_size, | 135 int64 file_size, |
| 136 const std::string& origin_url, | 136 const std::string& origin_url, |
| 137 quota::StorageType storage_type) { | 137 quota::StorageType storage_type) { |
| 138 if (file_path.empty()) | 138 if (file_path.empty()) |
| 139 return false; | 139 return false; |
| 140 | 140 |
| 141 FileSystemType type = fileapi::QuotaStorageTypeToFileSystemType( | 141 FileSystemType type = fileapi::QuotaStorageTypeToFileSystemType( |
| 142 storage_type); | 142 storage_type); |
| 143 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( | 143 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( |
| 144 GURL(origin_url), type, file_path); | 144 GURL(origin_url), type, file_path); |
| 145 | 145 |
| 146 base::PlatformFileError result = | 146 base::File::Error result = |
| 147 AsyncFileTestHelper::CreateFile(file_system_context_, url); | 147 AsyncFileTestHelper::CreateFile(file_system_context_, url); |
| 148 if (result != base::PLATFORM_FILE_OK) | 148 if (result != base::File::FILE_OK) |
| 149 return false; | 149 return false; |
| 150 | 150 |
| 151 result = AsyncFileTestHelper::TruncateFile( | 151 result = AsyncFileTestHelper::TruncateFile( |
| 152 file_system_context_, url, file_size); | 152 file_system_context_, url, file_size); |
| 153 return result == base::PLATFORM_FILE_OK; | 153 return result == base::File::FILE_OK; |
| 154 } | 154 } |
| 155 | 155 |
| 156 void InitializeOriginFiles(FileSystemQuotaClient* quota_client, | 156 void InitializeOriginFiles(FileSystemQuotaClient* quota_client, |
| 157 const TestFile* files, | 157 const TestFile* files, |
| 158 int num_files) { | 158 int num_files) { |
| 159 for (int i = 0; i < num_files; i++) { | 159 for (int i = 0; i < num_files; i++) { |
| 160 base::FilePath path = base::FilePath().AppendASCII(files[i].name); | 160 base::FilePath path = base::FilePath().AppendASCII(files[i].name); |
| 161 if (files[i].isDirectory) { | 161 if (files[i].isDirectory) { |
| 162 ASSERT_TRUE(CreateFileSystemDirectory( | 162 ASSERT_TRUE(CreateFileSystemDirectory( |
| 163 path, files[i].origin_url, files[i].type)); | 163 path, files[i].origin_url, files[i].type)); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 GetOriginUsage(quota_client.get(), | 563 GetOriginUsage(quota_client.get(), |
| 564 "https://bar.com/", | 564 "https://bar.com/", |
| 565 kPersistent)); | 565 kPersistent)); |
| 566 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, | 566 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, |
| 567 GetOriginUsage(quota_client.get(), | 567 GetOriginUsage(quota_client.get(), |
| 568 "https://bar.com/", | 568 "https://bar.com/", |
| 569 kTemporary)); | 569 kTemporary)); |
| 570 } | 570 } |
| 571 | 571 |
| 572 } // namespace content | 572 } // namespace content |
| OLD | NEW |