Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1411203010: Separate RenderViewHost from RenderWidgetHost, part 4: delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: done Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 6b1407b78e0ace939218a24a5478b0c23d48f1c3..814c0de02cfd259a82ba9fc910776311d9225fff 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -279,15 +279,16 @@ void WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting(
}
}
-WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) {
+WebContents* WebContents::FromRenderViewHost(RenderViewHost* rvh) {
+ if (!rvh)
+ return nullptr;
return rvh->GetDelegate()->GetAsWebContents();
}
WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) {
- RenderFrameHostImpl* rfh_impl = static_cast<RenderFrameHostImpl*>(rfh);
- if (!rfh_impl)
- return NULL;
- return rfh_impl->delegate()->GetAsWebContents();
+ if (!rfh)
+ return nullptr;
+ return static_cast<RenderFrameHostImpl*>(rfh)->delegate()->GetAsWebContents();
}
// WebContentsImpl::DestructionObserver ----------------------------------------
@@ -543,26 +544,19 @@ WebContentsImpl* WebContentsImpl::CreateWithOpener(
// static
std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() {
- std::vector<WebContentsImpl*> result;
scoped_ptr<RenderWidgetHostIterator> widgets(
RenderWidgetHostImpl::GetRenderWidgetHosts());
- std::set<WebContentsImpl*> web_contents_set;
+ std::set<WebContentsImpl*> contentses;
while (RenderWidgetHost* rwh = widgets->GetNextHost()) {
- if (!rwh->IsRenderView())
- continue;
RenderViewHost* rvh = RenderViewHost::From(rwh);
if (!rvh)
continue;
WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
if (!web_contents)
continue;
- WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents);
- if (web_contents_set.find(wci) == web_contents_set.end()) {
- web_contents_set.insert(wci);
- result.push_back(wci);
- }
+ contentses.insert(static_cast<WebContentsImpl*>(web_contents));
ncarter (slow) 2015/10/26 18:35:02 Random observation: We could build the vector dire
Avi (use Gerrit) 2015/10/26 19:41:28 Oh, that's clever/evil.
}
- return result;
+ return std::vector<WebContentsImpl*>(contentses.begin(), contentses.end());
}
// static

Powered by Google App Engine
This is Rietveld 408576698