OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/worker_host/worker_service_impl.h" | 5 #include "content/browser/worker_host/worker_service_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 &WorkerPrioritySetter::GatherVisibleIDsAndUpdateWorkerPriorities, | 103 &WorkerPrioritySetter::GatherVisibleIDsAndUpdateWorkerPriorities, |
104 this)); | 104 this)); |
105 } | 105 } |
106 | 106 |
107 void WorkerPrioritySetter::GatherVisibleIDsAndUpdateWorkerPriorities() { | 107 void WorkerPrioritySetter::GatherVisibleIDsAndUpdateWorkerPriorities() { |
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
109 std::set<std::pair<int, int> >* visible_renderer_ids = | 109 std::set<std::pair<int, int> >* visible_renderer_ids = |
110 new std::set<std::pair<int, int> >(); | 110 new std::set<std::pair<int, int> >(); |
111 | 111 |
112 // Gather up all the visible renderer process/view pairs | 112 // Gather up all the visible renderer process/view pairs |
113 for (RenderProcessHost::iterator it = | 113 RenderWidgetHost::List widgets = RenderWidgetHost::GetRenderWidgetHosts(); |
114 RenderProcessHost::AllHostsIterator(); | 114 for (size_t i = 0; i < widgets.size(); ++i) { |
115 !it.IsAtEnd(); it.Advance()) { | 115 if (widgets[i]->GetProcess()->VisibleWidgetCount() == 0) |
116 RenderProcessHost* render_process_host = it.GetCurrentValue(); | 116 continue; |
117 if (render_process_host->VisibleWidgetCount()) { | 117 |
118 for (RenderProcessHost::RenderWidgetHostsIterator rit = | 118 RenderWidgetHostView* render_view = widgets[i]->GetView(); |
119 render_process_host->GetRenderWidgetHostsIterator(); !rit.IsAtEnd(); | 119 if (render_view && render_view->IsShowing()) { |
120 rit.Advance()) { | 120 visible_renderer_ids->insert( |
121 RenderWidgetHost* render_widget = | 121 std::pair<int, int>(widgets[i]->GetProcess()->GetID(), |
122 render_process_host->GetRenderWidgetHostByID(rit.GetCurrentKey()); | 122 widgets[i]->GetRoutingID())); |
123 if (render_widget) { | |
124 RenderWidgetHostView* render_view = render_widget->GetView(); | |
125 if (render_view && render_view->IsShowing()) { | |
126 visible_renderer_ids->insert( | |
127 std::pair<int, int>(render_process_host->GetID(), | |
128 render_widget->GetRoutingID())); | |
129 } | |
130 } | |
131 } | |
132 } | 123 } |
133 } | 124 } |
134 | 125 |
135 BrowserThread::PostTask( | 126 BrowserThread::PostTask( |
136 BrowserThread::IO, FROM_HERE, | 127 BrowserThread::IO, FROM_HERE, |
137 base::Bind(&WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet, | 128 base::Bind(&WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet, |
138 this, base::Owned(visible_renderer_ids))); | 129 this, base::Owned(visible_renderer_ids))); |
139 } | 130 } |
140 | 131 |
141 void WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet( | 132 void WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet( |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 return instance; | 716 return instance; |
726 | 717 |
727 // No existing pending worker - create a new one. | 718 // No existing pending worker - create a new one. |
728 WorkerProcessHost::WorkerInstance pending( | 719 WorkerProcessHost::WorkerInstance pending( |
729 url, true, name, resource_context, partition); | 720 url, true, name, resource_context, partition); |
730 pending_shared_workers_.push_back(pending); | 721 pending_shared_workers_.push_back(pending); |
731 return &pending_shared_workers_.back(); | 722 return &pending_shared_workers_.back(); |
732 } | 723 } |
733 | 724 |
734 } // namespace content | 725 } // namespace content |
OLD | NEW |