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

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

Issue 6079009: Move some misc thread-related stuff from base to base/thread and into the bas... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/proxy/polling_proxy_config_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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 <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/worker_pool.h" 10 #include "base/threading/worker_pool.h"
11 #include "net/disk_cache/disk_cache.h" 11 #include "net/disk_cache/disk_cache.h"
12 #include "net/disk_cache/in_flight_io.h" 12 #include "net/disk_cache/in_flight_io.h"
13 13
14 namespace { 14 namespace {
15 15
16 // This class represents a single asynchronous IO operation while it is being 16 // This class represents a single asynchronous IO operation while it is being
17 // bounced between threads. 17 // bounced between threads.
18 class FileBackgroundIO : public disk_cache::BackgroundIO { 18 class FileBackgroundIO : public disk_cache::BackgroundIO {
19 public: 19 public:
20 // Other than the actual parameters for the IO operation (including the 20 // Other than the actual parameters for the IO operation (including the
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 // --------------------------------------------------------------------------- 108 // ---------------------------------------------------------------------------
109 109
110 void FileInFlightIO::PostRead(disk_cache::File *file, void* buf, size_t buf_len, 110 void FileInFlightIO::PostRead(disk_cache::File *file, void* buf, size_t buf_len,
111 size_t offset, disk_cache::FileIOCallback *callback) { 111 size_t offset, disk_cache::FileIOCallback *callback) {
112 scoped_refptr<FileBackgroundIO> operation( 112 scoped_refptr<FileBackgroundIO> operation(
113 new FileBackgroundIO(file, buf, buf_len, offset, callback, this)); 113 new FileBackgroundIO(file, buf, buf_len, offset, callback, this));
114 file->AddRef(); // Balanced on OnOperationComplete() 114 file->AddRef(); // Balanced on OnOperationComplete()
115 115
116 WorkerPool::PostTask(FROM_HERE, 116 base::WorkerPool::PostTask(FROM_HERE,
117 NewRunnableMethod(operation.get(), &FileBackgroundIO::Read), true); 117 NewRunnableMethod(operation.get(), &FileBackgroundIO::Read), true);
118 OnOperationPosted(operation); 118 OnOperationPosted(operation);
119 } 119 }
120 120
121 void FileInFlightIO::PostWrite(disk_cache::File* file, const void* buf, 121 void FileInFlightIO::PostWrite(disk_cache::File* file, const void* buf,
122 size_t buf_len, size_t offset, 122 size_t buf_len, size_t offset,
123 disk_cache::FileIOCallback* callback) { 123 disk_cache::FileIOCallback* callback) {
124 scoped_refptr<FileBackgroundIO> operation( 124 scoped_refptr<FileBackgroundIO> operation(
125 new FileBackgroundIO(file, buf, buf_len, offset, callback, this)); 125 new FileBackgroundIO(file, buf, buf_len, offset, callback, this));
126 file->AddRef(); // Balanced on OnOperationComplete() 126 file->AddRef(); // Balanced on OnOperationComplete()
127 127
128 WorkerPool::PostTask(FROM_HERE, 128 base::WorkerPool::PostTask(FROM_HERE,
129 NewRunnableMethod(operation.get(), &FileBackgroundIO::Write), true); 129 NewRunnableMethod(operation.get(), &FileBackgroundIO::Write), true);
130 OnOperationPosted(operation); 130 OnOperationPosted(operation);
131 } 131 }
132 132
133 // Runs on the IO thread. 133 // Runs on the IO thread.
134 void FileInFlightIO::OnOperationComplete(disk_cache::BackgroundIO* operation, 134 void FileInFlightIO::OnOperationComplete(disk_cache::BackgroundIO* operation,
135 bool cancel) { 135 bool cancel) {
136 FileBackgroundIO* op = static_cast<FileBackgroundIO*>(operation); 136 FileBackgroundIO* op = static_cast<FileBackgroundIO*>(operation);
137 137
138 disk_cache::FileIOCallback* callback = op->callback(); 138 disk_cache::FileIOCallback* callback = op->callback();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 // Static. 285 // Static.
286 void File::WaitForPendingIO(int* num_pending_io) { 286 void File::WaitForPendingIO(int* num_pending_io) {
287 // We may be running unit tests so we should allow be able to reset the 287 // We may be running unit tests so we should allow be able to reset the
288 // message loop. 288 // message loop.
289 GetFileInFlightIO()->WaitForPendingIO(); 289 GetFileInFlightIO()->WaitForPendingIO();
290 DeleteFileInFlightIO(); 290 DeleteFileInFlightIO();
291 } 291 }
292 292
293 } // namespace disk_cache 293 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/proxy/polling_proxy_config_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698