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

Side by Side Diff: content/browser/loader/navigation_url_loader_impl.cc

Issue 648813002: PlzNavigate: Add first version of NavigationURLLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plz-navigate-prepare
Patch Set: rebase Created 6 years, 1 month 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/loader/navigation_url_loader_impl.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "content/browser/frame_host/navigation_request_info.h"
10 #include "content/browser/loader/navigation_url_loader_delegate.h"
11 #include "content/browser/loader/navigation_url_loader_impl_core.h"
12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/stream_handle.h"
15
16 namespace content {
17
18 NavigationURLLoaderImpl::NavigationURLLoaderImpl(
19 BrowserContext* browser_context,
20 int64 frame_tree_node_id,
21 const CommonNavigationParams& common_params,
22 scoped_ptr<NavigationRequestInfo> request_info,
23 ResourceRequestBody* request_body,
24 NavigationURLLoaderDelegate* delegate)
25 : delegate_(delegate),
26 weak_factory_(this) {
27 DCHECK_CURRENTLY_ON(BrowserThread::UI);
28
29 core_ = new NavigationURLLoaderImplCore(weak_factory_.GetWeakPtr());
30 BrowserThread::PostTask(
31 BrowserThread::IO, FROM_HERE,
32 base::Bind(&NavigationURLLoaderImplCore::Start, base::Unretained(core_),
33 browser_context->GetResourceContext(), frame_tree_node_id,
34 common_params, base::Passed(&request_info),
35 make_scoped_refptr(request_body)));
36 }
37
38 NavigationURLLoaderImpl::~NavigationURLLoaderImpl() {
39 DCHECK_CURRENTLY_ON(BrowserThread::UI);
40
41 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, core_);
42 core_ = nullptr;
43 }
44
45 void NavigationURLLoaderImpl::FollowRedirect() {
46 DCHECK_CURRENTLY_ON(BrowserThread::UI);
47
48 BrowserThread::PostTask(
49 BrowserThread::IO, FROM_HERE,
50 base::Bind(&NavigationURLLoaderImplCore::FollowRedirect,
51 base::Unretained(core_)));
52 }
53
54 void NavigationURLLoaderImpl::NotifyRequestRedirected(
55 const net::RedirectInfo& redirect_info,
56 const scoped_refptr<ResourceResponse>& response) {
57 DCHECK_CURRENTLY_ON(BrowserThread::UI);
58
59 delegate_->OnRequestRedirected(redirect_info, response);
60 }
61
62 void NavigationURLLoaderImpl::NotifyResponseStarted(
63 const scoped_refptr<ResourceResponse>& response,
64 scoped_ptr<StreamHandle> body) {
65 DCHECK_CURRENTLY_ON(BrowserThread::UI);
66
67 delegate_->OnResponseStarted(response, body.Pass());
68 }
69
70 void NavigationURLLoaderImpl::NotifyRequestFailed(int net_error) {
71 DCHECK_CURRENTLY_ON(BrowserThread::UI);
72
73 delegate_->OnRequestFailed(net_error);
74 }
75
76 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/navigation_url_loader_impl.h ('k') | content/browser/loader/navigation_url_loader_impl_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698