Roll src/third_party/WebKit a3b4a2e:7441784 (svn 202551:202552)
[chromium-blink-merge.git] / extensions / browser / serial_extension_host_queue.h
blob40d11edd22274dc85319814d19ae3075dc13caf7
1 // 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.
5 #ifndef EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_
6 #define EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_
8 #include <list>
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "extensions/browser/extension_host_queue.h"
14 namespace extensions {
16 class DeferredStartRenderHost;
18 // 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.
21 class SerialExtensionHostQueue : public ExtensionHostQueue {
22 public:
23 SerialExtensionHostQueue();
24 ~SerialExtensionHostQueue() override;
26 private:
27 // ExtensionHostQueue:
28 void Add(DeferredStartRenderHost* host) override;
29 void Remove(DeferredStartRenderHost* host) override;
31 // Queues up a delayed task to process the next DeferredStartRenderHost in
32 // the queue.
33 void PostTask();
35 // Creates the RenderView for the next host in the queue.
36 void ProcessOneHost();
38 // True if this queue is currently in the process of starting an
39 // DeferredStartRenderHost.
40 bool pending_create_;
42 // The list of DeferredStartRenderHosts waiting to be started.
43 std::list<DeferredStartRenderHost*> queue_;
45 base::WeakPtrFactory<SerialExtensionHostQueue> ptr_factory_;
47 DISALLOW_COPY_AND_ASSIGN(SerialExtensionHostQueue);
50 } // namespace extensions
52 #endif // EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_