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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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_BLOCKFILE_IN_FLIGHT_IO_H_ 5 #ifndef NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_
6 #define NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_ 6 #define NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 23 matching lines...) Expand all
34 // Allows the cancellation of the task to notify the controller (step number 8 34 // Allows the cancellation of the task to notify the controller (step number 8
35 // in the diagram below). In practice, if the controller waits for the 35 // in the diagram below). In practice, if the controller waits for the
36 // operation to finish it doesn't have to wait for the final task to be 36 // operation to finish it doesn't have to wait for the final task to be
37 // processed by the message loop so calling this method prevents its delivery. 37 // processed by the message loop so calling this method prevents its delivery.
38 // Note that this method is not intended to cancel the actual IO operation or 38 // Note that this method is not intended to cancel the actual IO operation or
39 // to prevent the first notification to take place (OnIOComplete). 39 // to prevent the first notification to take place (OnIOComplete).
40 void Cancel(); 40 void Cancel();
41 41
42 int result() { return result_; } 42 int result() { return result_; }
43 43
44 base::WaitableEvent* io_completed() { 44 base::WaitableEvent* io_completed() { return &io_completed_; }
45 return &io_completed_;
46 }
47 45
48 protected: 46 protected:
49 virtual ~BackgroundIO(); 47 virtual ~BackgroundIO();
50 48
51 // Notifies the controller about the end of the operation, from the background 49 // Notifies the controller about the end of the operation, from the background
52 // thread. 50 // thread.
53 void NotifyController(); 51 void NotifyController();
54 52
55 int result_; // Final operation result. 53 int result_; // Final operation result.
56 54
57 private: 55 private:
58 friend class base::RefCountedThreadSafe<BackgroundIO>; 56 friend class base::RefCountedThreadSafe<BackgroundIO>;
59 57
60 // An event to signal when the operation completes. 58 // An event to signal when the operation completes.
61 base::WaitableEvent io_completed_; 59 base::WaitableEvent io_completed_;
62 InFlightIO* controller_; // The controller that tracks all operations. 60 InFlightIO* controller_; // The controller that tracks all operations.
63 base::Lock controller_lock_; // A lock protecting clearing of controller_. 61 base::Lock controller_lock_; // A lock protecting clearing of controller_.
64 62
65 DISALLOW_COPY_AND_ASSIGN(BackgroundIO); 63 DISALLOW_COPY_AND_ASSIGN(BackgroundIO);
66 }; 64 };
67 65
68 // This class keeps track of asynchronous IO operations. A single instance 66 // This class keeps track of asynchronous IO operations. A single instance
69 // of this class is meant to be used to start an asynchronous operation (using 67 // of this class is meant to be used to start an asynchronous operation (using
70 // PostXX, exposed by a derived class). This class will post the operation to a 68 // PostXX, exposed by a derived class). This class will post the operation to a
71 // worker thread, hanlde the notification when the operation finishes and 69 // worker thread, hanlde the notification when the operation finishes and
72 // perform the callback on the same thread that was used to start the operation. 70 // perform the callback on the same thread that was used to start the operation.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // be executed on a background thread. This method must be called on the same 116 // be executed on a background thread. This method must be called on the same
119 // thread used to create this object. 117 // thread used to create this object.
120 void OnOperationPosted(BackgroundIO* operation); 118 void OnOperationPosted(BackgroundIO* operation);
121 119
122 private: 120 private:
123 typedef std::set<scoped_refptr<BackgroundIO> > IOList; 121 typedef std::set<scoped_refptr<BackgroundIO> > IOList;
124 122
125 IOList io_list_; // List of pending, in-flight io operations. 123 IOList io_list_; // List of pending, in-flight io operations.
126 scoped_refptr<base::MessageLoopProxy> callback_thread_; 124 scoped_refptr<base::MessageLoopProxy> callback_thread_;
127 125
128 bool running_; // True after the first posted operation completes. 126 bool running_; // True after the first posted operation completes.
129 bool single_thread_; // True if we only have one thread. 127 bool single_thread_; // True if we only have one thread.
130 128
131 DISALLOW_COPY_AND_ASSIGN(InFlightIO); 129 DISALLOW_COPY_AND_ASSIGN(InFlightIO);
132 }; 130 };
133 131
134 } // namespace disk_cache 132 } // namespace disk_cache
135 133
136 #endif // NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_ 134 #endif // NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_IO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698