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 #include "extensions/browser/serial_extension_host_queue.h" | 5 #include "extensions/browser/serial_extension_host_queue.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" |
10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
11 #include "components/variations/variations_associated_data.h" | 13 #include "components/variations/variations_associated_data.h" |
12 #include "extensions/browser/deferred_start_render_host.h" | 14 #include "extensions/browser/deferred_start_render_host.h" |
13 | 15 |
14 namespace extensions { | 16 namespace extensions { |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 // Gets the number of milliseconds to delay between loading ExtensionHosts. By | 20 // Gets the number of milliseconds to delay between loading ExtensionHosts. By |
19 // default this is 0, but it can be overridden by field trials. | 21 // default this is 0, but it can be overridden by field trials. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 56 |
55 void SerialExtensionHostQueue::Remove(DeferredStartRenderHost* host) { | 57 void SerialExtensionHostQueue::Remove(DeferredStartRenderHost* host) { |
56 std::list<DeferredStartRenderHost*>::iterator it = | 58 std::list<DeferredStartRenderHost*>::iterator it = |
57 std::find(queue_.begin(), queue_.end(), host); | 59 std::find(queue_.begin(), queue_.end(), host); |
58 if (it != queue_.end()) | 60 if (it != queue_.end()) |
59 queue_.erase(it); | 61 queue_.erase(it); |
60 } | 62 } |
61 | 63 |
62 void SerialExtensionHostQueue::PostTask() { | 64 void SerialExtensionHostQueue::PostTask() { |
63 if (!pending_create_) { | 65 if (!pending_create_) { |
64 base::MessageLoop::current()->PostDelayedTask( | 66 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
65 FROM_HERE, base::Bind(&SerialExtensionHostQueue::ProcessOneHost, | 67 FROM_HERE, base::Bind(&SerialExtensionHostQueue::ProcessOneHost, |
66 ptr_factory_.GetWeakPtr()), | 68 ptr_factory_.GetWeakPtr()), |
67 base::TimeDelta::FromMilliseconds(GetDelayMs())); | 69 base::TimeDelta::FromMilliseconds(GetDelayMs())); |
68 pending_create_ = true; | 70 pending_create_ = true; |
69 } | 71 } |
70 } | 72 } |
71 | 73 |
72 void SerialExtensionHostQueue::ProcessOneHost() { | 74 void SerialExtensionHostQueue::ProcessOneHost() { |
73 pending_create_ = false; | 75 pending_create_ = false; |
74 if (queue_.empty()) | 76 if (queue_.empty()) |
75 return; // can happen on shutdown | 77 return; // can happen on shutdown |
76 | 78 |
77 queue_.front()->CreateRenderViewNow(); | 79 queue_.front()->CreateRenderViewNow(); |
78 queue_.pop_front(); | 80 queue_.pop_front(); |
79 | 81 |
80 if (!queue_.empty()) | 82 if (!queue_.empty()) |
81 PostTask(); | 83 PostTask(); |
82 } | 84 } |
83 | 85 |
84 } // namespace extensions | 86 } // namespace extensions |
OLD | NEW |