OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/navigation_resource_handler.h" | 5 #include "content/browser/loader/navigation_resource_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/devtools/devtools_netlog_observer.h" | 8 #include "content/browser/devtools/devtools_netlog_observer.h" |
9 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 9 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
10 #include "content/browser/loader/resource_request_info_impl.h" | 10 #include "content/browser/loader/resource_request_info_impl.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 void NavigationResourceHandler::Cancel() { | 38 void NavigationResourceHandler::Cancel() { |
39 controller()->Cancel(); | 39 controller()->Cancel(); |
40 core_ = nullptr; | 40 core_ = nullptr; |
41 } | 41 } |
42 | 42 |
43 void NavigationResourceHandler::FollowRedirect() { | 43 void NavigationResourceHandler::FollowRedirect() { |
44 controller()->Resume(); | 44 controller()->Resume(); |
45 } | 45 } |
46 | 46 |
| 47 void NavigationResourceHandler::ProceedWithResponse() { |
| 48 // Detach from the loader; at this point, the request is now owned by the |
| 49 // StreamHandle sent in OnResponseStarted. |
| 50 DetachFromCore(); |
| 51 controller()->Resume(); |
| 52 } |
| 53 |
47 void NavigationResourceHandler::SetController(ResourceController* controller) { | 54 void NavigationResourceHandler::SetController(ResourceController* controller) { |
48 writer_.set_controller(controller); | 55 writer_.set_controller(controller); |
49 ResourceHandler::SetController(controller); | 56 ResourceHandler::SetController(controller); |
50 } | 57 } |
51 | 58 |
52 bool NavigationResourceHandler::OnRequestRedirected( | 59 bool NavigationResourceHandler::OnRequestRedirected( |
53 const net::RedirectInfo& redirect_info, | 60 const net::RedirectInfo& redirect_info, |
54 ResourceResponse* response, | 61 ResourceResponse* response, |
55 bool* defer) { | 62 bool* defer) { |
56 DCHECK(core_); | 63 DCHECK(core_); |
(...skipping 20 matching lines...) Expand all Loading... |
77 // all the way to the UI thread. Downloads, user certificates, etc., should be | 84 // all the way to the UI thread. Downloads, user certificates, etc., should be |
78 // dispatched at the navigation layer. | 85 // dispatched at the navigation layer. |
79 if (info->IsDownload() || info->is_stream()) | 86 if (info->IsDownload() || info->is_stream()) |
80 return true; | 87 return true; |
81 | 88 |
82 StreamContext* stream_context = | 89 StreamContext* stream_context = |
83 GetStreamContextForResourceContext(info->GetContext()); | 90 GetStreamContextForResourceContext(info->GetContext()); |
84 writer_.InitializeStream(stream_context->registry(), | 91 writer_.InitializeStream(stream_context->registry(), |
85 request()->url().GetOrigin()); | 92 request()->url().GetOrigin()); |
86 | 93 |
87 // Detach from the loader; at this point, the request is now owned by the | |
88 // StreamHandle. | |
89 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); | 94 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); |
90 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle()); | 95 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle()); |
91 DetachFromCore(); | 96 *defer = true; |
92 return true; | 97 return true; |
93 } | 98 } |
94 | 99 |
95 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { | 100 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { |
96 return true; | 101 return true; |
97 } | 102 } |
98 | 103 |
99 bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url, | 104 bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url, |
100 bool* defer) { | 105 bool* defer) { |
101 return true; | 106 return true; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 NOTREACHED(); | 143 NOTREACHED(); |
139 } | 144 } |
140 | 145 |
141 void NavigationResourceHandler::DetachFromCore() { | 146 void NavigationResourceHandler::DetachFromCore() { |
142 DCHECK(core_); | 147 DCHECK(core_); |
143 core_->set_resource_handler(nullptr); | 148 core_->set_resource_handler(nullptr); |
144 core_ = nullptr; | 149 core_ = nullptr; |
145 } | 150 } |
146 | 151 |
147 } // namespace content | 152 } // namespace content |
OLD | NEW |