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

Side by Side Diff: net/disk_cache/in_flight_io.h

Issue 11649028: Add an IO thread index bitmap to disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows build fix Created 7 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 #ifndef NET_DISK_CACHE_IN_FLIGHT_IO_H_ 5 #ifndef NET_DISK_CACHE_IN_FLIGHT_IO_H_
6 #define NET_DISK_CACHE_IN_FLIGHT_IO_H_ 6 #define NET_DISK_CACHE_IN_FLIGHT_IO_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 return &io_completed_; 45 return &io_completed_;
46 } 46 }
47 47
48 protected: 48 protected:
49 virtual ~BackgroundIO(); 49 virtual ~BackgroundIO();
50 50
51 // Notifies the controller about the end of the operation, from the background 51 // Notifies the controller about the end of the operation, from the background
52 // thread. 52 // thread.
53 void NotifyController(); 53 void NotifyController();
54 54
55 scoped_refptr<base::MessageLoopProxy> GetCallbackThread();
56
55 int result_; // Final operation result. 57 int result_; // Final operation result.
56 58
57 private: 59 private:
58 friend class base::RefCountedThreadSafe<BackgroundIO>; 60 friend class base::RefCountedThreadSafe<BackgroundIO>;
59 61
60 // An event to signal when the operation completes. 62 // An event to signal when the operation completes.
61 base::WaitableEvent io_completed_; 63 base::WaitableEvent io_completed_;
62 InFlightIO* controller_; // The controller that tracks all operations. 64 InFlightIO* controller_; // The controller that tracks all operations.
63 base::Lock controller_lock_; // A lock protecting clearing of controller_. 65 base::Lock controller_lock_; // A lock protecting clearing of controller_.
64 66
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 103
102 // Called on a background thread when |operation| completes. 104 // Called on a background thread when |operation| completes.
103 void OnIOComplete(BackgroundIO* operation); 105 void OnIOComplete(BackgroundIO* operation);
104 106
105 // Invokes the users' completion callback at the end of the IO operation. 107 // Invokes the users' completion callback at the end of the IO operation.
106 // |cancel_task| is true if the actual task posted to the thread is still 108 // |cancel_task| is true if the actual task posted to the thread is still
107 // queued (because we are inside WaitForPendingIO), and false if said task is 109 // queued (because we are inside WaitForPendingIO), and false if said task is
108 // the one performing the call. 110 // the one performing the call.
109 void InvokeCallback(BackgroundIO* operation, bool cancel_task); 111 void InvokeCallback(BackgroundIO* operation, bool cancel_task);
110 112
113 scoped_refptr<base::MessageLoopProxy> callback_thread() {
114 return callback_thread_;
115 }
116
111 protected: 117 protected:
112 // This method is called to signal the completion of the |operation|. |cancel| 118 // This method is called to signal the completion of the |operation|. |cancel|
113 // is true if the operation is being cancelled. This method is called on the 119 // is true if the operation is being cancelled. This method is called on the
114 // thread that created this object. 120 // thread that created this object.
115 virtual void OnOperationComplete(BackgroundIO* operation, bool cancel) = 0; 121 virtual void OnOperationComplete(BackgroundIO* operation, bool cancel) = 0;
116 122
117 // Signals this object that the derived class just posted the |operation| to 123 // Signals this object that the derived class just posted the |operation| to
118 // be executed on a background thread. This method must be called on the same 124 // be executed on a background thread. This method must be called on the same
119 // thread used to create this object. 125 // thread used to create this object.
120 void OnOperationPosted(BackgroundIO* operation); 126 void OnOperationPosted(BackgroundIO* operation);
121 127
122 private: 128 private:
123 typedef std::set<scoped_refptr<BackgroundIO> > IOList; 129 typedef std::set<scoped_refptr<BackgroundIO> > IOList;
124 130
125 IOList io_list_; // List of pending, in-flight io operations. 131 IOList io_list_; // List of pending, in-flight io operations.
126 scoped_refptr<base::MessageLoopProxy> callback_thread_; 132 scoped_refptr<base::MessageLoopProxy> callback_thread_;
127 133
128 bool running_; // True after the first posted operation completes. 134 bool running_; // True after the first posted operation completes.
129 bool single_thread_; // True if we only have one thread. 135 bool single_thread_; // True if we only have one thread.
130 136
131 DISALLOW_COPY_AND_ASSIGN(InFlightIO); 137 DISALLOW_COPY_AND_ASSIGN(InFlightIO);
132 }; 138 };
133 139
134 } // namespace disk_cache 140 } // namespace disk_cache
135 141
136 #endif // NET_DISK_CACHE_IN_FLIGHT_IO_H_ 142 #endif // NET_DISK_CACHE_IN_FLIGHT_IO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698