OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_system_file_stream_reader.h" | 5 #include "webkit/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" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 new FileSystemContext( | 73 new FileSystemContext( |
74 FileSystemTaskRunners::CreateMockTaskRunners(), | 74 FileSystemTaskRunners::CreateMockTaskRunners(), |
75 special_storage_policy_, | 75 special_storage_policy_, |
76 NULL, | 76 NULL, |
77 temp_dir_.path(), | 77 temp_dir_.path(), |
78 CreateDisallowFileAccessOptions()); | 78 CreateDisallowFileAccessOptions()); |
79 | 79 |
80 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( | 80 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( |
81 GURL(kURLOrigin), kFileSystemTypeTemporary, true, // create | 81 GURL(kURLOrigin), kFileSystemTypeTemporary, true, // create |
82 base::Bind(&OnValidateFileSystem)); | 82 base::Bind(&OnValidateFileSystem)); |
83 MessageLoop::current()->RunAllPending(); | 83 MessageLoop::current()->RunUntilIdle(); |
84 | 84 |
85 WriteFile(kTestFileName, kTestData, kTestDataSize, | 85 WriteFile(kTestFileName, kTestData, kTestDataSize, |
86 &test_file_modification_time_); | 86 &test_file_modification_time_); |
87 } | 87 } |
88 | 88 |
89 virtual void TearDown() OVERRIDE { | 89 virtual void TearDown() OVERRIDE { |
90 MessageLoop::current()->RunAllPending(); | 90 MessageLoop::current()->RunUntilIdle(); |
91 } | 91 } |
92 | 92 |
93 protected: | 93 protected: |
94 FileSystemFileStreamReader* CreateFileReader( | 94 FileSystemFileStreamReader* CreateFileReader( |
95 const std::string& file_name, | 95 const std::string& file_name, |
96 int64 initial_offset, | 96 int64 initial_offset, |
97 const base::Time& expected_modification_time) { | 97 const base::Time& expected_modification_time) { |
98 return new FileSystemFileStreamReader(file_system_context_, | 98 return new FileSystemFileStreamReader(file_system_context_, |
99 GetFileSystemURL(file_name), | 99 GetFileSystemURL(file_name), |
100 initial_offset, | 100 initial_offset, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 new net::IOBufferWithSize(kTestDataSize)); | 279 new net::IOBufferWithSize(kTestDataSize)); |
280 int rv = reader->Read(buf, buf->size(), base::Bind(&NeverCalled)); | 280 int rv = reader->Read(buf, buf->size(), base::Bind(&NeverCalled)); |
281 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); | 281 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); |
282 | 282 |
283 // Delete immediately. | 283 // Delete immediately. |
284 // Should not crash; nor should NeverCalled be callback. | 284 // Should not crash; nor should NeverCalled be callback. |
285 reader.reset(); | 285 reader.reset(); |
286 } | 286 } |
287 | 287 |
288 } // namespace fileapi | 288 } // namespace fileapi |
OLD | NEW |