| 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_IMPL_H_ | 5 #ifndef EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_IMPL_H_ |
| 6 #define EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_IMPL_H_ | 6 #define EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 T* RequestQueue<T>::active_request() { | 35 T* RequestQueue<T>::active_request() { |
| 36 return active_request_.get(); | 36 return active_request_.get(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 template <typename T> | 39 template <typename T> |
| 40 int RequestQueue<T>::active_request_failure_count() { | 40 int RequestQueue<T>::active_request_failure_count() { |
| 41 return active_backoff_entry_->failure_count(); | 41 return active_backoff_entry_->failure_count(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 template <typename T> | 44 template <typename T> |
| 45 scoped_ptr<T> RequestQueue<T>::reset_active_request() { | 45 std::unique_ptr<T> RequestQueue<T>::reset_active_request() { |
| 46 active_backoff_entry_.reset(); | 46 active_backoff_entry_.reset(); |
| 47 return std::move(active_request_); | 47 return std::move(active_request_); |
| 48 } | 48 } |
| 49 | 49 |
| 50 template <typename T> | 50 template <typename T> |
| 51 void RequestQueue<T>::ScheduleRequest(scoped_ptr<T> request) { | 51 void RequestQueue<T>::ScheduleRequest(std::unique_ptr<T> request) { |
| 52 PushImpl(std::move(request), scoped_ptr<net::BackoffEntry>( | 52 PushImpl(std::move(request), std::unique_ptr<net::BackoffEntry>( |
| 53 new net::BackoffEntry(backoff_policy_))); | 53 new net::BackoffEntry(backoff_policy_))); |
| 54 StartNextRequest(); | 54 StartNextRequest(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 template <typename T> | 57 template <typename T> |
| 58 void RequestQueue<T>::PushImpl(scoped_ptr<T> request, | 58 void RequestQueue<T>::PushImpl( |
| 59 scoped_ptr<net::BackoffEntry> backoff_entry) { | 59 std::unique_ptr<T> request, |
| 60 std::unique_ptr<net::BackoffEntry> backoff_entry) { |
| 60 pending_requests_.push_back( | 61 pending_requests_.push_back( |
| 61 Request(backoff_entry.release(), request.release())); | 62 Request(backoff_entry.release(), request.release())); |
| 62 std::push_heap( | 63 std::push_heap( |
| 63 pending_requests_.begin(), pending_requests_.end(), CompareRequests); | 64 pending_requests_.begin(), pending_requests_.end(), CompareRequests); |
| 64 } | 65 } |
| 65 | 66 |
| 66 template <typename T> | 67 template <typename T> |
| 67 bool RequestQueue<T>::empty() const { | 68 bool RequestQueue<T>::empty() const { |
| 68 return pending_requests_.empty(); | 69 return pending_requests_.empty(); |
| 69 } | 70 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 148 |
| 148 // static | 149 // static |
| 149 template <typename T> | 150 template <typename T> |
| 150 bool RequestQueue<T>::CompareRequests(const Request& a, const Request& b) { | 151 bool RequestQueue<T>::CompareRequests(const Request& a, const Request& b) { |
| 151 return a.backoff_entry->GetReleaseTime() > b.backoff_entry->GetReleaseTime(); | 152 return a.backoff_entry->GetReleaseTime() > b.backoff_entry->GetReleaseTime(); |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace extensions | 155 } // namespace extensions |
| 155 | 156 |
| 156 #endif // EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_IMPL_H_ | 157 #endif // EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_IMPL_H_ |
| OLD | NEW |