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/fileapi/local_file_stream_reader.h" | 5 #include "storage/browser/fileapi/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" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/location.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" |
15 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
16 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
17 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
18 #include "net/base/test_completion_callback.h" | 20 #include "net/base/test_completion_callback.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
20 | 22 |
21 using storage::LocalFileStreamReader; | 23 using storage::LocalFileStreamReader; |
22 | 24 |
23 namespace content { | 25 namespace content { |
24 | 26 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 96 } |
95 | 97 |
96 void TouchTestFile() { | 98 void TouchTestFile() { |
97 base::Time new_modified_time = | 99 base::Time new_modified_time = |
98 test_file_modification_time() - base::TimeDelta::FromSeconds(1); | 100 test_file_modification_time() - base::TimeDelta::FromSeconds(1); |
99 ASSERT_TRUE(base::TouchFile(test_path(), | 101 ASSERT_TRUE(base::TouchFile(test_path(), |
100 test_file_modification_time(), | 102 test_file_modification_time(), |
101 new_modified_time)); | 103 new_modified_time)); |
102 } | 104 } |
103 | 105 |
104 base::MessageLoopProxy* file_task_runner() const { | 106 base::SingleThreadTaskRunner* file_task_runner() const { |
105 return file_thread_.message_loop_proxy().get(); | 107 return file_thread_.task_runner().get(); |
106 } | 108 } |
107 | 109 |
108 base::FilePath test_dir() const { return dir_.path(); } | 110 base::FilePath test_dir() const { return dir_.path(); } |
109 base::FilePath test_path() const { return dir_.path().AppendASCII("test"); } | 111 base::FilePath test_path() const { return dir_.path().AppendASCII("test"); } |
110 base::Time test_file_modification_time() const { | 112 base::Time test_file_modification_time() const { |
111 return test_file_modification_time_; | 113 return test_file_modification_time_; |
112 } | 114 } |
113 | 115 |
114 void EnsureFileTaskFinished() { | 116 void EnsureFileTaskFinished() { |
115 file_task_runner()->PostTaskAndReply( | 117 file_task_runner()->PostTaskAndReply( |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); | 251 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); |
250 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); | 252 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); |
251 | 253 |
252 // Delete immediately. | 254 // Delete immediately. |
253 // Should not crash; nor should NeverCalled be callback. | 255 // Should not crash; nor should NeverCalled be callback. |
254 reader.reset(); | 256 reader.reset(); |
255 EnsureFileTaskFinished(); | 257 EnsureFileTaskFinished(); |
256 } | 258 } |
257 | 259 |
258 } // namespace content | 260 } // namespace content |
OLD | NEW |