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

Side by Side Diff: content/browser/loader_delegate_impl.cc

Issue 2108643004: Remove use of WebContentsImpl from ResourceDispatcherHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render-view-try-3
Patch Set: fix comment Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/loader_delegate_impl.h" 5 #include "content/browser/loader_delegate_impl.h"
6 6
7 #include "content/browser/frame_host/render_frame_host_impl.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
9 11
10 namespace content { 12 namespace content {
11 13
14 namespace {
15
16 void NotifyLoadStateChangedOnUI(int child_id,
17 int route_id,
18 const GURL& url,
19 const net::LoadStateWithParam& load_state,
20 uint64_t upload_position,
21 uint64_t upload_size) {
22 RenderViewHostImpl* view = RenderViewHostImpl::FromID(child_id, route_id);
23 if (view)
24 view->LoadStateChanged(url, load_state, upload_position, upload_size);
25 }
26
27 void DidGetResourceResponseStartOnUI(
28 int render_process_id,
29 int render_frame_host,
30 std::unique_ptr<ResourceRequestDetails> details) {
31 RenderFrameHostImpl* host =
32 RenderFrameHostImpl::FromID(render_process_id, render_frame_host);
33 WebContentsImpl* web_contents =
34 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host));
35 if (!web_contents)
36 return;
37 web_contents->DidGetResourceResponseStart(*details.get());
38 }
39
40 void DidGetRedirectForResourceRequestOnUI(
41 int render_process_id,
42 int render_frame_host,
43 std::unique_ptr<ResourceRedirectDetails> details) {
44 RenderFrameHostImpl* host =
45 RenderFrameHostImpl::FromID(render_process_id, render_frame_host);
46 WebContentsImpl* web_contents =
47 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host));
48 if (!web_contents)
49 return;
50 web_contents->DidGetRedirectForResourceRequest(host, *details.get());
51 }
52
53 } // namespace
54
12 LoaderDelegateImpl::~LoaderDelegateImpl() {} 55 LoaderDelegateImpl::~LoaderDelegateImpl() {}
13 56
14 void LoaderDelegateImpl::LoadStateChanged( 57 void LoaderDelegateImpl::LoadStateChanged(
15 int child_id, 58 int child_id,
16 int route_id, 59 int route_id,
17 const GURL& url, 60 const GURL& url,
18 const net::LoadStateWithParam& load_state, 61 const net::LoadStateWithParam& load_state,
19 uint64_t upload_position, 62 uint64_t upload_position,
20 uint64_t upload_size) { 63 uint64_t upload_size) {
64 DCHECK_CURRENTLY_ON(BrowserThread::IO);
21 BrowserThread::PostTask( 65 BrowserThread::PostTask(
22 BrowserThread::UI, FROM_HERE, 66 BrowserThread::UI, FROM_HERE,
23 base::Bind(&LoaderDelegateImpl::NotifyLoadStateChangedOnUI, 67 base::Bind(&NotifyLoadStateChangedOnUI, child_id, route_id, url,
24 base::Unretained(this), child_id, route_id, url, load_state, 68 load_state, upload_position, upload_size));
25 upload_position, upload_size));
26 } 69 }
27 70
28 void LoaderDelegateImpl::NotifyLoadStateChangedOnUI( 71 void LoaderDelegateImpl::DidGetResourceResponseStart(
29 int child_id, 72 int render_process_id,
30 int route_id, 73 int render_frame_host,
31 const GURL& url, 74 std::unique_ptr<ResourceRequestDetails> details) {
32 const net::LoadStateWithParam& load_state, 75 DCHECK_CURRENTLY_ON(BrowserThread::IO);
33 uint64_t upload_position, 76 BrowserThread::PostTask(
34 uint64_t upload_size) { 77 BrowserThread::UI, FROM_HERE,
35 RenderViewHostImpl* view = RenderViewHostImpl::FromID(child_id, route_id); 78 base::Bind(&DidGetResourceResponseStartOnUI, render_process_id,
36 if (view) 79 render_frame_host, base::Passed(std::move(details))));
37 view->LoadStateChanged(url, load_state, upload_position, upload_size); 80 }
81
82 void LoaderDelegateImpl::DidGetRedirectForResourceRequest(
83 int render_process_id,
84 int render_frame_host,
85 std::unique_ptr<ResourceRedirectDetails> details) {
86 DCHECK_CURRENTLY_ON(BrowserThread::IO);
87 BrowserThread::PostTask(
88 BrowserThread::UI, FROM_HERE,
89 base::Bind(&DidGetRedirectForResourceRequestOnUI, render_process_id,
90 render_frame_host, base::Passed(std::move(details))));
38 } 91 }
39 92
40 } // namespace content 93 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader_delegate_impl.h ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698