// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_ #define NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_ #include <set> #include "base/check.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h" namespace base { class SequencedTaskRunner; } // namespace base namespace disk_cache { class InFlightIO; // This class represents a single asynchronous IO operation while it is being // bounced between threads. class BackgroundIO : public base::RefCountedThreadSafe<BackgroundIO> { … }; // This class keeps track of asynchronous IO operations. A single instance // of this class is meant to be used to start an asynchronous operation (using // PostXX, exposed by a derived class). This class will post the operation to a // worker thread, hanlde the notification when the operation finishes and // perform the callback on the same thread that was used to start the operation. // // The regular sequence of calls is: // Thread_1 Worker_thread // 1. DerivedInFlightIO::PostXX() // 2. -> PostTask -> // 3. InFlightIO::OnOperationPosted() // 4. DerivedBackgroundIO::XX() // 5. IO operation completes // 6. InFlightIO::OnIOComplete() // 7. <- PostTask <- // 8. BackgroundIO::OnIOSignalled() // 9. InFlightIO::InvokeCallback() // 10. DerivedInFlightIO::OnOperationComplete() // 11. invoke callback // // Shutdown is a special case that is handled though WaitForPendingIO() instead // of just waiting for step 7. class InFlightIO { … }; } // namespace disk_cache #endif // NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_