// 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 EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ #define EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_ #include <stddef.h> #include <memory> #include <optional> #include <utility> #include "base/containers/circular_deque.h" #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "net/base/backoff_entry.h" namespace extensions { // This class keeps track of a queue of requests, and contains the logic to // retry requests with some backoff policy. Each request has a // net::BackoffEntry instance associated with it. // // The general flow when using this class would be something like this: // - requests are queued up by calling ScheduleRequest. // - when a request is ready to be executed, RequestQueue removes the // request from the queue, assigns it as active request, and calls // the callback that was passed to the constructor. // - (optionally) when a request has completed unsuccessfully call // RetryRequest to put the request back in the queue, using the // backoff policy and minimum backoff delay to determine when to // next schedule this request. // - call reset_active_request() to indicate that the active request has // been dealt with. // - call StartNextRequest to schedule the next pending request (if any). template <typename T> class RequestQueue { … }; // Iterator class that wraps a base::circular_deque<> iterator, only giving // access to the actual request part of each item. template <typename T> class RequestQueue<T>::iterator { … }; } // namespace extensions #endif // EXTENSIONS_BROWSER_UPDATER_REQUEST_QUEUE_H_