| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 disk_cache->CreateEntry(1, &entry1, completion_callback_); | 144 disk_cache->CreateEntry(1, &entry1, completion_callback_); |
| 145 disk_cache->CreateEntry(2, &entry2, completion_callback_); | 145 disk_cache->CreateEntry(2, &entry2, completion_callback_); |
| 146 FlushCacheTasks(); | 146 FlushCacheTasks(); |
| 147 EXPECT_TRUE(entry1); | 147 EXPECT_TRUE(entry1); |
| 148 EXPECT_TRUE(entry2); | 148 EXPECT_TRUE(entry2); |
| 149 | 149 |
| 150 // Write something to one of the entries and flush it. | 150 // Write something to one of the entries and flush it. |
| 151 const char* kData = "Hello"; | 151 const char* kData = "Hello"; |
| 152 const int kDataLen = strlen(kData) + 1; | 152 const int kDataLen = strlen(kData) + 1; |
| 153 scoped_refptr<net::IOBuffer> write_buf(new net::WrappedIOBuffer(kData)); | 153 scoped_refptr<net::IOBuffer> write_buf(new net::WrappedIOBuffer(kData)); |
| 154 entry1->Write(0, 0, write_buf, kDataLen, completion_callback_); | 154 entry1->Write(0, 0, write_buf.get(), kDataLen, completion_callback_); |
| 155 FlushCacheTasks(); | 155 FlushCacheTasks(); |
| 156 | 156 |
| 157 // Queue up a read and a write. | 157 // Queue up a read and a write. |
| 158 scoped_refptr<net::IOBuffer> read_buf = new net::IOBuffer(kDataLen); | 158 scoped_refptr<net::IOBuffer> read_buf = new net::IOBuffer(kDataLen); |
| 159 entry1->Read(0, 0, read_buf.get(), kDataLen, completion_callback_); | 159 entry1->Read(0, 0, read_buf.get(), kDataLen, completion_callback_); |
| 160 entry2->Write(0, 0, write_buf.get(), kDataLen, completion_callback_); | 160 entry2->Write(0, 0, write_buf.get(), kDataLen, completion_callback_); |
| 161 | 161 |
| 162 // Pull the plug | 162 // Pull the plug |
| 163 disk_cache->Disable(); | 163 disk_cache->Disable(); |
| 164 FlushCacheTasks(); | 164 FlushCacheTasks(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 175 EXPECT_EQ( | 175 EXPECT_EQ( |
| 176 net::ERR_ABORTED, | 176 net::ERR_ABORTED, |
| 177 entry1->Read(0, 0, read_buf.get(), kDataLen, completion_callback_)); | 177 entry1->Read(0, 0, read_buf.get(), kDataLen, completion_callback_)); |
| 178 entry1->Close(); | 178 entry1->Close(); |
| 179 entry2->Close(); | 179 entry2->Close(); |
| 180 | 180 |
| 181 FlushCacheTasks(); | 181 FlushCacheTasks(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace content | 184 } // namespace content |
| OLD | NEW |