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

Unified Diff: net/disk_cache/in_flight_io.cc

Issue 2944002: Revert 51858 - Disk cache: Switch the disk cache to use the cache_thread. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/in_flight_io.h ('k') | net/disk_cache/sparse_control.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/in_flight_io.cc
===================================================================
--- net/disk_cache/in_flight_io.cc (revision 51873)
+++ net/disk_cache/in_flight_io.cc (working copy)
@@ -1,73 +0,0 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/disk_cache/in_flight_io.h"
-
-#include "base/logging.h"
-
-namespace disk_cache {
-
-// Runs on the primary thread.
-void BackgroundIO::OnIOSignalled() {
- if (controller_)
- controller_->InvokeCallback(this, false);
-}
-
-void BackgroundIO::Cancel() {
- DCHECK(controller_);
- controller_ = NULL;
-}
-
-// Runs on the background thread.
-void BackgroundIO::NotifyController() {
- controller_->OnIOComplete(this);
-}
-
-// ---------------------------------------------------------------------------
-
-void InFlightIO::WaitForPendingIO() {
- while (!io_list_.empty()) {
- // Block the current thread until all pending IO completes.
- IOList::iterator it = io_list_.begin();
- InvokeCallback(*it, true);
- }
-}
-
-// Runs on a background thread.
-void InFlightIO::OnIOComplete(BackgroundIO* operation) {
-#ifndef NDEBUG
- if (callback_thread_ == MessageLoop::current()) {
- DCHECK(single_thread_ || !running_);
- single_thread_ = true;
- }
- running_ = true;
-#endif
-
- callback_thread_->PostTask(FROM_HERE,
- NewRunnableMethod(operation,
- &BackgroundIO::OnIOSignalled));
- operation->io_completed()->Signal();
-}
-
-// Runs on the primary thread.
-void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) {
- operation->io_completed()->Wait();
-
- if (cancel_task)
- operation->Cancel();
-
- // Make sure that we remove the operation from the list before invoking the
- // callback (so that a subsequent cancel does not invoke the callback again).
- DCHECK(io_list_.find(operation) != io_list_.end());
- io_list_.erase(operation);
- OnOperationComplete(operation, cancel_task);
-}
-
-// Runs on the primary thread.
-void InFlightIO::OnOperationPosted(BackgroundIO* operation) {
- DCHECK(callback_thread_ == MessageLoop::current());
- io_list_.insert(operation);
-}
-
-} // namespace disk_cache
« no previous file with comments | « net/disk_cache/in_flight_io.h ('k') | net/disk_cache/sparse_control.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698