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 |
114 RenderProcessHost::AllHostsIterator(); | 114 scoped_ptr<RenderWidgetHost::List> hosts = |
115 !it.IsAtEnd(); it.Advance()) { | 115 RenderWidgetHost::GetRenderWidgetHosts(); |
116 RenderProcessHost* render_process_host = it.GetCurrentValue(); | 116 for (RenderWidgetHost::List::const_iterator it = hosts->begin(); |
117 if (render_process_host->VisibleWidgetCount()) { | 117 it != hosts->end(); |
118 for (RenderProcessHost::RenderWidgetHostsIterator rit = | 118 ++it) { |
119 render_process_host->GetRenderWidgetHostsIterator(); !rit.IsAtEnd(); | 119 const RenderWidgetHost* widget = *it; |
120 rit.Advance()) { | 120 if (widget->GetProcess()->VisibleWidgetCount() == 0) |
121 RenderWidgetHost* render_widget = | 121 continue; |
122 render_process_host->GetRenderWidgetHostByID(rit.GetCurrentKey()); | 122 |
123 if (render_widget) { | 123 RenderWidgetHostView* render_view = widget->GetView(); |
124 RenderWidgetHostView* render_view = render_widget->GetView(); | 124 if (render_view && render_view->IsShowing()) { |
125 if (render_view && render_view->IsShowing()) { | 125 visible_renderer_ids->insert( |
126 visible_renderer_ids->insert( | 126 std::pair<int, int>(widget->GetProcess()->GetID(), |
127 std::pair<int, int>(render_process_host->GetID(), | 127 widget->GetRoutingID())); |
128 render_widget->GetRoutingID())); | |
129 } | |
130 } | |
131 } | |
132 } | 128 } |
133 } | 129 } |
134 | 130 |
135 BrowserThread::PostTask( | 131 BrowserThread::PostTask( |
136 BrowserThread::IO, FROM_HERE, | 132 BrowserThread::IO, FROM_HERE, |
137 base::Bind(&WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet, | 133 base::Bind(&WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet, |
138 this, base::Owned(visible_renderer_ids))); | 134 this, base::Owned(visible_renderer_ids))); |
139 } | 135 } |
140 | 136 |
141 void WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet( | 137 void WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet( |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 return instance; | 721 return instance; |
726 | 722 |
727 // No existing pending worker - create a new one. | 723 // No existing pending worker - create a new one. |
728 WorkerProcessHost::WorkerInstance pending( | 724 WorkerProcessHost::WorkerInstance pending( |
729 url, true, name, resource_context, partition); | 725 url, true, name, resource_context, partition); |
730 pending_shared_workers_.push_back(pending); | 726 pending_shared_workers_.push_back(pending); |
731 return &pending_shared_workers_.back(); | 727 return &pending_shared_workers_.back(); |
732 } | 728 } |
733 | 729 |
734 } // namespace content | 730 } // namespace content |
OLD | NEW |