OLD | NEW |
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 EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ | 5 #ifndef EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ |
6 #define EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ | 6 #define EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Priority queue of pending requests. Not using std::priority_queue since | 104 // Priority queue of pending requests. Not using std::priority_queue since |
105 // the code needs to be able to iterate over all pending requests. | 105 // the code needs to be able to iterate over all pending requests. |
106 std::deque<Request> pending_requests_; | 106 std::deque<Request> pending_requests_; |
107 | 107 |
108 // Active request and its associated backoff entry. | 108 // Active request and its associated backoff entry. |
109 std::unique_ptr<T> active_request_; | 109 std::unique_ptr<T> active_request_; |
110 std::unique_ptr<net::BackoffEntry> active_backoff_entry_; | 110 std::unique_ptr<net::BackoffEntry> active_backoff_entry_; |
111 | 111 |
112 // Timer to schedule calls to StartNextRequest, if the first pending request | 112 // Timer to schedule calls to StartNextRequest, if the first pending request |
113 // hasn't passed its release time yet. | 113 // hasn't passed its release time yet. |
114 base::Timer timer_; | 114 base::OneShotTimer timer_; |
115 }; | 115 }; |
116 | 116 |
117 // Iterator class that wraps a std::deque<> iterator, only giving access to the | 117 // Iterator class that wraps a std::deque<> iterator, only giving access to the |
118 // actual request part of each item. | 118 // actual request part of each item. |
119 template <typename T> | 119 template <typename T> |
120 class RequestQueue<T>::iterator { | 120 class RequestQueue<T>::iterator { |
121 public: | 121 public: |
122 iterator() {} | 122 iterator() {} |
123 | 123 |
124 T* operator*() { return it_->request.get(); } | 124 T* operator*() { return it_->request.get(); } |
125 T* operator->() { return it_->request.get(); } | 125 T* operator->() { return it_->request.get(); } |
126 iterator& operator++() { | 126 iterator& operator++() { |
127 ++it_; | 127 ++it_; |
128 return *this; | 128 return *this; |
129 } | 129 } |
130 bool operator!=(const iterator& b) const { return it_ != b.it_; } | 130 bool operator!=(const iterator& b) const { return it_ != b.it_; } |
131 | 131 |
132 private: | 132 private: |
133 friend class RequestQueue<T>; | 133 friend class RequestQueue<T>; |
134 typedef std::deque<typename RequestQueue<T>::Request> Container; | 134 typedef std::deque<typename RequestQueue<T>::Request> Container; |
135 | 135 |
136 explicit iterator(const typename Container::iterator& it) : it_(it) {} | 136 explicit iterator(const typename Container::iterator& it) : it_(it) {} |
137 | 137 |
138 typename Container::iterator it_; | 138 typename Container::iterator it_; |
139 }; | 139 }; |
140 | 140 |
141 } // namespace extensions | 141 } // namespace extensions |
142 | 142 |
143 #endif // EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ | 143 #endif // EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ |
OLD | NEW |