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 "storage/browser/fileapi/file_system_dir_url_request_job.h" | 5 #include "storage/browser/fileapi/file_system_dir_url_request_job.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <string> | 9 #include <string> |
8 | 10 |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
12 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
13 #include "base/location.h" | 15 #include "base/location.h" |
14 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
16 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
17 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
18 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
19 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
| 22 #include "build/build_config.h" |
20 #include "content/public/test/mock_special_storage_policy.h" | 23 #include "content/public/test/mock_special_storage_policy.h" |
21 #include "content/public/test/test_file_system_backend.h" | 24 #include "content/public/test/test_file_system_backend.h" |
22 #include "content/public/test/test_file_system_context.h" | 25 #include "content/public/test/test_file_system_context.h" |
23 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
24 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
25 #include "net/base/request_priority.h" | 28 #include "net/base/request_priority.h" |
26 #include "net/http/http_request_headers.h" | 29 #include "net/http/http_request_headers.h" |
27 #include "net/url_request/url_request.h" | 30 #include "net/url_request/url_request.h" |
28 #include "net/url_request/url_request_context.h" | 31 #include "net/url_request/url_request_context.h" |
29 #include "net/url_request/url_request_test_util.h" | 32 #include "net/url_request/url_request_test_util.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 false /* recursive */)); | 224 false /* recursive */)); |
222 } | 225 } |
223 | 226 |
224 void EnsureFileExists(const base::StringPiece file_name) { | 227 void EnsureFileExists(const base::StringPiece file_name) { |
225 base::FilePath path = base::FilePath().AppendASCII(file_name); | 228 base::FilePath path = base::FilePath().AppendASCII(file_name); |
226 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); | 229 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); |
227 ASSERT_EQ(base::File::FILE_OK, file_util()->EnsureFileExists( | 230 ASSERT_EQ(base::File::FILE_OK, file_util()->EnsureFileExists( |
228 context.get(), CreateURL(path), NULL)); | 231 context.get(), CreateURL(path), NULL)); |
229 } | 232 } |
230 | 233 |
231 void TruncateFile(const base::StringPiece file_name, int64 length) { | 234 void TruncateFile(const base::StringPiece file_name, int64_t length) { |
232 base::FilePath path = base::FilePath().AppendASCII(file_name); | 235 base::FilePath path = base::FilePath().AppendASCII(file_name); |
233 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); | 236 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); |
234 ASSERT_EQ(base::File::FILE_OK, file_util()->Truncate( | 237 ASSERT_EQ(base::File::FILE_OK, file_util()->Truncate( |
235 context.get(), CreateURL(path), length)); | 238 context.get(), CreateURL(path), length)); |
236 } | 239 } |
237 | 240 |
238 base::File::Error GetFileInfo(const base::FilePath& path, | 241 base::File::Error GetFileInfo(const base::FilePath& path, |
239 base::File::Info* file_info, | 242 base::File::Info* file_info, |
240 base::FilePath* platform_file_path) { | 243 base::FilePath* platform_file_path) { |
241 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); | 244 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); |
242 return file_util()->GetFileInfo(context.get(), | 245 return file_util()->GetFileInfo(context.get(), |
243 CreateURL(path), | 246 CreateURL(path), |
244 file_info, platform_file_path); | 247 file_info, platform_file_path); |
245 } | 248 } |
246 | 249 |
247 // If |size| is negative, the reported size is ignored. | 250 // If |size| is negative, the reported size is ignored. |
248 void VerifyListingEntry(const std::string& entry_line, | 251 void VerifyListingEntry(const std::string& entry_line, |
249 const std::string& name, | 252 const std::string& name, |
250 const std::string& url, | 253 const std::string& url, |
251 bool is_directory, | 254 bool is_directory, |
252 int64 size) { | 255 int64_t size) { |
253 #define STR "([^\"]*)" | 256 #define STR "([^\"]*)" |
254 icu::UnicodeString pattern("^<script>addRow\\(\"" STR "\",\"" STR | 257 icu::UnicodeString pattern("^<script>addRow\\(\"" STR "\",\"" STR |
255 "\",(0|1),\"" STR "\",\"" STR "\"\\);</script>"); | 258 "\",(0|1),\"" STR "\",\"" STR "\"\\);</script>"); |
256 #undef STR | 259 #undef STR |
257 icu::UnicodeString input(entry_line.c_str()); | 260 icu::UnicodeString input(entry_line.c_str()); |
258 | 261 |
259 UErrorCode status = U_ZERO_ERROR; | 262 UErrorCode status = U_ZERO_ERROR; |
260 icu::RegexMatcher match(pattern, input, 0, status); | 263 icu::RegexMatcher match(pattern, input, 0, status); |
261 | 264 |
262 EXPECT_TRUE(match.find()); | 265 EXPECT_TRUE(match.find()); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 ASSERT_FALSE(request_->status().is_success()); | 453 ASSERT_FALSE(request_->status().is_success()); |
451 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 454 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
452 | 455 |
453 ASSERT_FALSE( | 456 ASSERT_FALSE( |
454 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 457 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
455 kValidExternalMountPoint)); | 458 kValidExternalMountPoint)); |
456 } | 459 } |
457 | 460 |
458 } // namespace | 461 } // namespace |
459 } // namespace content | 462 } // namespace content |
OLD | NEW |