blob: 7c545aa103148becfb4f1b151975cefbb31d55cb [file] [log] [blame]
kalmanfcece452015-02-18 18:20:421// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_
6#define EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_
7
8#include <list>
9
10#include "base/macros.h"
11#include "base/memory/weak_ptr.h"
12#include "extensions/browser/extension_host_queue.h"
13
14namespace extensions {
15
yozd61dfe192015-02-21 01:30:3716class DeferredStartRenderHost;
kalmanfcece452015-02-18 18:20:4217
yozd61dfe192015-02-21 01:30:3718// An ExtensionHostQueue which initializes DeferredStartRenderHosts in the order
19// they're Add()ed, with simple rate limiting logic that re-posts each task to
20// the UI thread, to avoid clogging it for a long period of time.
kalmanfcece452015-02-18 18:20:4221class SerialExtensionHostQueue : public ExtensionHostQueue {
22 public:
23 SerialExtensionHostQueue();
24 ~SerialExtensionHostQueue() override;
25
26 private:
27 // ExtensionHostQueue:
yozd61dfe192015-02-21 01:30:3728 void Add(DeferredStartRenderHost* host) override;
29 void Remove(DeferredStartRenderHost* host) override;
kalmanfcece452015-02-18 18:20:4230
yozd61dfe192015-02-21 01:30:3731 // Queues up a delayed task to process the next DeferredStartRenderHost in
32 // the queue.
kalmanfcece452015-02-18 18:20:4233 void PostTask();
34
35 // Creates the RenderView for the next host in the queue.
36 void ProcessOneHost();
37
38 // True if this queue is currently in the process of starting an
yozd61dfe192015-02-21 01:30:3739 // DeferredStartRenderHost.
kalmanfcece452015-02-18 18:20:4240 bool pending_create_;
41
yozd61dfe192015-02-21 01:30:3742 // The list of DeferredStartRenderHosts waiting to be started.
43 std::list<DeferredStartRenderHost*> queue_;
kalmanfcece452015-02-18 18:20:4244
Jeremy Roman9fc2de62019-07-12 14:15:0345 base::WeakPtrFactory<SerialExtensionHostQueue> ptr_factory_{this};
kalmanfcece452015-02-18 18:20:4246
47 DISALLOW_COPY_AND_ASSIGN(SerialExtensionHostQueue);
48};
49
50} // namespace extensions
51
52#endif // EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_