| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/blob/local_file_stream_reader.h" | 5 #include "storage/browser/blob/local_file_stream_reader.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 base::MessageLoop::current()->Quit(); | 57 base::MessageLoop::current()->Quit(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 class LocalFileStreamReaderTest : public testing::Test { | 62 class LocalFileStreamReaderTest : public testing::Test { |
| 63 public: | 63 public: |
| 64 LocalFileStreamReaderTest() | 64 LocalFileStreamReaderTest() |
| 65 : file_thread_("FileUtilProxyTestFileThread") {} | 65 : file_thread_("FileUtilProxyTestFileThread") {} |
| 66 | 66 |
| 67 virtual void SetUp() override { | 67 void SetUp() override { |
| 68 ASSERT_TRUE(file_thread_.Start()); | 68 ASSERT_TRUE(file_thread_.Start()); |
| 69 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 69 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
| 70 | 70 |
| 71 base::WriteFile(test_path(), kTestData, kTestDataSize); | 71 base::WriteFile(test_path(), kTestData, kTestDataSize); |
| 72 base::File::Info info; | 72 base::File::Info info; |
| 73 ASSERT_TRUE(base::GetFileInfo(test_path(), &info)); | 73 ASSERT_TRUE(base::GetFileInfo(test_path(), &info)); |
| 74 test_file_modification_time_ = info.last_modified; | 74 test_file_modification_time_ = info.last_modified; |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual void TearDown() override { | 77 void TearDown() override { |
| 78 // Give another chance for deleted streams to perform Close. | 78 // Give another chance for deleted streams to perform Close. |
| 79 base::RunLoop().RunUntilIdle(); | 79 base::RunLoop().RunUntilIdle(); |
| 80 file_thread_.Stop(); | 80 file_thread_.Stop(); |
| 81 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 protected: | 84 protected: |
| 85 LocalFileStreamReader* CreateFileReader( | 85 LocalFileStreamReader* CreateFileReader( |
| 86 const base::FilePath& path, | 86 const base::FilePath& path, |
| 87 int64 initial_offset, | 87 int64 initial_offset, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); | 249 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); |
| 250 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); | 250 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); |
| 251 | 251 |
| 252 // Delete immediately. | 252 // Delete immediately. |
| 253 // Should not crash; nor should NeverCalled be callback. | 253 // Should not crash; nor should NeverCalled be callback. |
| 254 reader.reset(); | 254 reader.reset(); |
| 255 EnsureFileTaskFinished(); | 255 EnsureFileTaskFinished(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace content | 258 } // namespace content |
| OLD | NEW |