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 "webkit/browser/fileapi/file_system_file_stream_reader.h" | 5 #include "webkit/browser/fileapi/file_system_file_stream_reader.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "content/public/test/async_file_test_helper.h" |
14 #include "content/public/test/test_file_system_context.h" | 15 #include "content/public/test/test_file_system_context.h" |
15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
17 #include "net/base/test_completion_callback.h" | 18 #include "net/base/test_completion_callback.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "webkit/browser/fileapi/async_file_test_helper.h" | |
20 #include "webkit/browser/fileapi/external_mount_points.h" | 20 #include "webkit/browser/fileapi/external_mount_points.h" |
21 #include "webkit/browser/fileapi/file_system_context.h" | 21 #include "webkit/browser/fileapi/file_system_context.h" |
22 #include "webkit/browser/fileapi/file_system_file_util.h" | 22 #include "webkit/browser/fileapi/file_system_file_util.h" |
23 | 23 |
24 using fileapi::AsyncFileTestHelper; | 24 using content::AsyncFileTestHelper; |
25 using fileapi::FileSystemContext; | 25 using fileapi::FileSystemContext; |
26 using fileapi::FileSystemFileStreamReader; | 26 using fileapi::FileSystemFileStreamReader; |
27 using fileapi::FileSystemType; | 27 using fileapi::FileSystemType; |
28 using fileapi::FileSystemURL; | 28 using fileapi::FileSystemURL; |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 const char kURLOrigin[] = "http://remote/"; | 34 const char kURLOrigin[] = "http://remote/"; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return test_file_modification_time_; | 103 return test_file_modification_time_; |
104 } | 104 } |
105 | 105 |
106 void WriteFile(const std::string& file_name, | 106 void WriteFile(const std::string& file_name, |
107 const char* buf, | 107 const char* buf, |
108 int buf_size, | 108 int buf_size, |
109 base::Time* modification_time) { | 109 base::Time* modification_time) { |
110 FileSystemURL url = GetFileSystemURL(file_name); | 110 FileSystemURL url = GetFileSystemURL(file_name); |
111 | 111 |
112 ASSERT_EQ(base::File::FILE_OK, | 112 ASSERT_EQ(base::File::FILE_OK, |
113 fileapi::AsyncFileTestHelper::CreateFileWithData( | 113 content::AsyncFileTestHelper::CreateFileWithData( |
114 file_system_context_, url, buf, buf_size)); | 114 file_system_context_, url, buf, buf_size)); |
115 | 115 |
116 base::File::Info file_info; | 116 base::File::Info file_info; |
117 ASSERT_EQ(base::File::FILE_OK, | 117 ASSERT_EQ(base::File::FILE_OK, |
118 AsyncFileTestHelper::GetMetadata( | 118 AsyncFileTestHelper::GetMetadata( |
119 file_system_context_, url, &file_info)); | 119 file_system_context_, url, &file_info)); |
120 if (modification_time) | 120 if (modification_time) |
121 *modification_time = file_info.last_modified; | 121 *modification_time = file_info.last_modified; |
122 } | 122 } |
123 | 123 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 new net::IOBufferWithSize(kTestDataSize)); | 263 new net::IOBufferWithSize(kTestDataSize)); |
264 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); | 264 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); |
265 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); | 265 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); |
266 | 266 |
267 // Delete immediately. | 267 // Delete immediately. |
268 // Should not crash; nor should NeverCalled be callback. | 268 // Should not crash; nor should NeverCalled be callback. |
269 reader.reset(); | 269 reader.reset(); |
270 } | 270 } |
271 | 271 |
272 } // namespace content | 272 } // namespace content |
OLD | NEW |