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 #include "extensions/browser/serial_extension_host_queue.h"
8 #include "base/message_loop/message_loop.h"
9 #include "extensions/browser/deferred_start_render_host.h"
11 namespace extensions
{
13 SerialExtensionHostQueue::SerialExtensionHostQueue()
14 : pending_create_(false), ptr_factory_(this) {
17 SerialExtensionHostQueue::~SerialExtensionHostQueue() {
20 void SerialExtensionHostQueue::Add(DeferredStartRenderHost
* host
) {
21 queue_
.push_back(host
);
25 void SerialExtensionHostQueue::Remove(DeferredStartRenderHost
* host
) {
26 std::list
<DeferredStartRenderHost
*>::iterator it
=
27 std::find(queue_
.begin(), queue_
.end(), host
);
28 if (it
!= queue_
.end())
32 void SerialExtensionHostQueue::PostTask() {
33 if (!pending_create_
) {
34 base::MessageLoop::current()->PostTask(
35 FROM_HERE
, base::Bind(&SerialExtensionHostQueue::ProcessOneHost
,
36 ptr_factory_
.GetWeakPtr()));
37 pending_create_
= true;
41 void SerialExtensionHostQueue::ProcessOneHost() {
42 pending_create_
= false;
44 return; // can happen on shutdown
46 queue_
.front()->CreateRenderViewNow();
53 } // namespace extensions