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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/memory/scoped_callback_factory.h" | 7 #include "base/memory/scoped_callback_factory.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 FilePath GetOriginBasePath(const std::string& origin_url, | 124 FilePath GetOriginBasePath(const std::string& origin_url, |
125 quota::StorageType type) { | 125 quota::StorageType type) { |
126 // Note: this test assumes sandbox_provider impl is used for | 126 // Note: this test assumes sandbox_provider impl is used for |
127 // temporary and persistent filesystem. | 127 // temporary and persistent filesystem. |
128 return file_system_context_->path_manager()->sandbox_provider()-> | 128 return file_system_context_->path_manager()->sandbox_provider()-> |
129 GetBaseDirectoryForOriginAndType( | 129 GetBaseDirectoryForOriginAndType( |
130 GURL(origin_url), QuotaStorageTypeToFileSystemType(type), true); | 130 GURL(origin_url), QuotaStorageTypeToFileSystemType(type), true); |
131 } | 131 } |
132 | 132 |
133 FileSystemOperationContext* CreateFileSystemOperationContext( | 133 FileSystemOperationContext* CreateFileSystemOperationContext( |
134 FileSystemFileUtil* file_util, | 134 FileApiFileUtil* file_util, |
135 const FilePath& virtual_path, | 135 const FilePath& virtual_path, |
136 const std::string& origin_url, | 136 const std::string& origin_url, |
137 quota::StorageType type) { | 137 quota::StorageType type) { |
138 FileSystemOperationContext* context = | 138 FileSystemOperationContext* context = |
139 new FileSystemOperationContext(file_system_context_, file_util); | 139 new FileSystemOperationContext(file_system_context_, file_util); |
140 context->set_src_origin_url(GURL(origin_url)); | 140 context->set_src_origin_url(GURL(origin_url)); |
141 context->set_src_virtual_path(virtual_path); | 141 context->set_src_virtual_path(virtual_path); |
142 context->set_src_type(QuotaStorageTypeToFileSystemType(type)); | 142 context->set_src_type(QuotaStorageTypeToFileSystemType(type)); |
143 context->set_allowed_bytes_growth(100000000); | 143 context->set_allowed_bytes_growth(100000000); |
144 return context; | 144 return context; |
145 } | 145 } |
146 | 146 |
147 bool CreateFileSystemDirectory(const FilePath& path, | 147 bool CreateFileSystemDirectory(const FilePath& path, |
148 const std::string& origin_url, | 148 const std::string& origin_url, |
149 quota::StorageType type) { | 149 quota::StorageType type) { |
150 FileSystemFileUtil* file_util = | 150 FileApiFileUtil* file_util = file_system_context_->path_manager()-> |
151 file_system_context_->path_manager()->GetFileSystemFileUtil( | 151 GetFileUtil(QuotaStorageTypeToFileSystemType(type)); |
152 QuotaStorageTypeToFileSystemType(type)); | |
153 | 152 |
154 scoped_ptr<FileSystemOperationContext> context( | 153 scoped_ptr<FileSystemOperationContext> context( |
155 CreateFileSystemOperationContext(file_util, path, origin_url, type)); | 154 CreateFileSystemOperationContext(file_util, path, origin_url, type)); |
156 | 155 |
157 base::PlatformFileError result = | 156 base::PlatformFileError result = |
158 file_util->CreateDirectory(context.get(), path, false, false); | 157 file_util->CreateDirectory(context.get(), path, false, false); |
159 if (result != base::PLATFORM_FILE_OK) | 158 if (result != base::PLATFORM_FILE_OK) |
160 return false; | 159 return false; |
161 return true; | 160 return true; |
162 } | 161 } |
163 | 162 |
164 bool CreateFileSystemFile(const FilePath& path, | 163 bool CreateFileSystemFile(const FilePath& path, |
165 int64 file_size, | 164 int64 file_size, |
166 const std::string& origin_url, | 165 const std::string& origin_url, |
167 quota::StorageType type) { | 166 quota::StorageType type) { |
168 if (path.empty()) | 167 if (path.empty()) |
169 return false; | 168 return false; |
170 | 169 |
171 FileSystemFileUtil* file_util = file_system_context_->path_manager()-> | 170 FileApiFileUtil* file_util = file_system_context_->path_manager()-> |
172 sandbox_provider()->GetFileSystemFileUtil(); | 171 sandbox_provider()->GetFileUtil(); |
173 | 172 |
174 scoped_ptr<FileSystemOperationContext> context( | 173 scoped_ptr<FileSystemOperationContext> context( |
175 CreateFileSystemOperationContext(file_util, path, origin_url, type)); | 174 CreateFileSystemOperationContext(file_util, path, origin_url, type)); |
176 | 175 |
177 bool created = false; | 176 bool created = false; |
178 if (base::PLATFORM_FILE_OK != | 177 if (base::PLATFORM_FILE_OK != |
179 file_util->EnsureFileExists(context.get(), path, &created)) | 178 file_util->EnsureFileExists(context.get(), path, &created)) |
180 return false; | 179 return false; |
181 EXPECT_TRUE(created); | 180 EXPECT_TRUE(created); |
182 if (base::PLATFORM_FILE_OK != | 181 if (base::PLATFORM_FILE_OK != |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 GetOriginUsage(quota_client.get(), | 590 GetOriginUsage(quota_client.get(), |
592 "https://bar.com/", | 591 "https://bar.com/", |
593 kPersistent)); | 592 kPersistent)); |
594 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, | 593 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, |
595 GetOriginUsage(quota_client.get(), | 594 GetOriginUsage(quota_client.get(), |
596 "https://bar.com/", | 595 "https://bar.com/", |
597 kTemporary)); | 596 kTemporary)); |
598 } | 597 } |
599 | 598 |
600 } // namespace fileapi | 599 } // namespace fileapi |
OLD | NEW |