Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: net/disk_cache/file_posix.cc

Issue 103533012: Disk Cache: Use the old WorkerPool for Async IO on iOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "net/disk_cache/file.h" 5 #include "net/disk_cache/file.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 // Static. 161 // Static.
162 void File::WaitForPendingIO(int* num_pending_io) { 162 void File::WaitForPendingIO(int* num_pending_io) {
163 // We are running unit tests so we should wait for all callbacks. Sadly, the 163 // We are running unit tests so we should wait for all callbacks. Sadly, the
164 // worker pool only waits for tasks on the worker pool, not the "Reply" tasks 164 // worker pool only waits for tasks on the worker pool, not the "Reply" tasks
165 // so we have to let the current message loop to run. 165 // so we have to let the current message loop to run.
166 s_worker_pool.Get().FlushForTesting(); 166 s_worker_pool.Get().FlushForTesting();
167 base::RunLoop().RunUntilIdle(); 167 base::RunLoop().RunUntilIdle();
168 } 168 }
169 169
170 // Static.
171 void File::DropPendingIO() {
172 // Nothing to do here.
gavinp 2014/01/07 15:50:42 Drop this comment.
173 }
174
175
170 File::~File() { 176 File::~File() {
171 if (IsValid()) 177 if (IsValid())
172 base::ClosePlatformFile(platform_file_); 178 base::ClosePlatformFile(platform_file_);
173 } 179 }
174 180
175 // Runs on a worker thread. 181 // Runs on a worker thread.
176 int File::DoRead(void* buffer, size_t buffer_len, size_t offset) { 182 int File::DoRead(void* buffer, size_t buffer_len, size_t offset) {
177 if (Read(const_cast<void*>(buffer), buffer_len, offset)) 183 if (Read(const_cast<void*>(buffer), buffer_len, offset))
178 return static_cast<int>(buffer_len); 184 return static_cast<int>(buffer_len);
179 185
180 return net::ERR_CACHE_READ_FAILURE; 186 return net::ERR_CACHE_READ_FAILURE;
181 } 187 }
182 188
183 // Runs on a worker thread. 189 // Runs on a worker thread.
184 int File::DoWrite(const void* buffer, size_t buffer_len, size_t offset) { 190 int File::DoWrite(const void* buffer, size_t buffer_len, size_t offset) {
185 if (Write(const_cast<void*>(buffer), buffer_len, offset)) 191 if (Write(const_cast<void*>(buffer), buffer_len, offset))
186 return static_cast<int>(buffer_len); 192 return static_cast<int>(buffer_len);
187 193
188 return net::ERR_CACHE_WRITE_FAILURE; 194 return net::ERR_CACHE_WRITE_FAILURE;
189 } 195 }
190 196
191 // This method actually makes sure that the last reference to the file doesn't 197 // This method actually makes sure that the last reference to the file doesn't
192 // go away on the worker pool. 198 // go away on the worker pool.
193 void File::OnOperationComplete(FileIOCallback* callback, int result) { 199 void File::OnOperationComplete(FileIOCallback* callback, int result) {
194 callback->OnFileIOComplete(result); 200 callback->OnFileIOComplete(result);
195 } 201 }
196 202
197 } // namespace disk_cache 203 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698