OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_SERIAL_EXTENSION_HOST_QUEUE_H_ | 5 #ifndef EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_ |
6 #define EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_ | 6 #define EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "extensions/browser/extension_host_queue.h" | 12 #include "extensions/browser/extension_host_queue.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 class ExtensionHost; | 16 class DeferredStartRenderHost; |
17 | 17 |
18 // An ExtensionHostQueue which initializes ExtensionHosts in the order they're | 18 // An ExtensionHostQueue which initializes DeferredStartRenderHosts in the order |
19 // Add()ed, with simple rate limiting logic that re-posts each task to the UI | 19 // they're Add()ed, with simple rate limiting logic that re-posts each task to |
20 // thread, to avoid clogging it for a long period of time. | 20 // the UI thread, to avoid clogging it for a long period of time. |
21 class SerialExtensionHostQueue : public ExtensionHostQueue { | 21 class SerialExtensionHostQueue : public ExtensionHostQueue { |
22 public: | 22 public: |
23 SerialExtensionHostQueue(); | 23 SerialExtensionHostQueue(); |
24 ~SerialExtensionHostQueue() override; | 24 ~SerialExtensionHostQueue() override; |
25 | 25 |
26 private: | 26 private: |
27 // ExtensionHostQueue: | 27 // ExtensionHostQueue: |
28 void Add(ExtensionHost* host) override; | 28 void Add(DeferredStartRenderHost* host) override; |
29 void Remove(ExtensionHost* host) override; | 29 void Remove(DeferredStartRenderHost* host) override; |
30 | 30 |
31 // Queues up a delayed task to process the next ExtensionHost in the queue. | 31 // Queues up a delayed task to process the next DeferredStartRenderHost in |
| 32 // the queue. |
32 void PostTask(); | 33 void PostTask(); |
33 | 34 |
34 // Creates the RenderView for the next host in the queue. | 35 // Creates the RenderView for the next host in the queue. |
35 void ProcessOneHost(); | 36 void ProcessOneHost(); |
36 | 37 |
37 // True if this queue is currently in the process of starting an | 38 // True if this queue is currently in the process of starting an |
38 // ExtensionHost. | 39 // DeferredStartRenderHost. |
39 bool pending_create_; | 40 bool pending_create_; |
40 | 41 |
41 // The list of ExtensionHosts waiting to be started. | 42 // The list of DeferredStartRenderHosts waiting to be started. |
42 std::list<ExtensionHost*> queue_; | 43 std::list<DeferredStartRenderHost*> queue_; |
43 | 44 |
44 base::WeakPtrFactory<SerialExtensionHostQueue> ptr_factory_; | 45 base::WeakPtrFactory<SerialExtensionHostQueue> ptr_factory_; |
45 | 46 |
46 DISALLOW_COPY_AND_ASSIGN(SerialExtensionHostQueue); | 47 DISALLOW_COPY_AND_ASSIGN(SerialExtensionHostQueue); |
47 }; | 48 }; |
48 | 49 |
49 } // namespace extensions | 50 } // namespace extensions |
50 | 51 |
51 #endif // EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_ | 52 #endif // EXTENSIONS_BROWSER_SERIAL_EXTENSION_HOST_QUEUE_H_ |
OLD | NEW |