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" |
11 #include "content/browser/resource_context_impl.h" | 11 #include "content/browser/resource_context_impl.h" |
12 #include "content/browser/streams/stream.h" | 12 #include "content/browser/streams/stream.h" |
13 #include "content/browser/streams/stream_context.h" | 13 #include "content/browser/streams/stream_context.h" |
14 #include "content/public/browser/resource_controller.h" | 14 #include "content/public/browser/resource_controller.h" |
15 #include "content/public/browser/stream_handle.h" | 15 #include "content/public/browser/stream_handle.h" |
16 #include "content/public/common/resource_response.h" | 16 #include "content/public/common/resource_response.h" |
17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
18 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 NavigationResourceHandler::NavigationResourceHandler( | 22 NavigationResourceHandler::NavigationResourceHandler( |
23 net::URLRequest* request, | 23 net::URLRequest* request, |
24 NavigationURLLoaderImplCore* core) | 24 NavigationURLLoaderImplCore* core) |
25 : ResourceHandler(request), | 25 : ResourceHandler(request), core_(core) { |
26 core_(core) { | |
27 core_->set_resource_handler(this); | 26 core_->set_resource_handler(this); |
28 writer_.set_immediate_mode(true); | 27 writer_.set_immediate_mode(true); |
29 } | 28 } |
30 | 29 |
31 NavigationResourceHandler::~NavigationResourceHandler() { | 30 NavigationResourceHandler::~NavigationResourceHandler() { |
32 if (core_) { | 31 if (core_) { |
33 core_->NotifyRequestFailed(false, net::ERR_ABORTED); | 32 core_->NotifyRequestFailed(false, net::ERR_ABORTED); |
34 DetachFromCore(); | 33 DetachFromCore(); |
35 } | 34 } |
36 } | 35 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 68 |
70 ResourceRequestInfoImpl* info = GetRequestInfo(); | 69 ResourceRequestInfoImpl* info = GetRequestInfo(); |
71 | 70 |
72 // If the MimeTypeResourceHandler intercepted this request and converted it | 71 // If the MimeTypeResourceHandler intercepted this request and converted it |
73 // into a download, it will still call OnResponseStarted and immediately | 72 // into a download, it will still call OnResponseStarted and immediately |
74 // cancel. Ignore the call; OnReadCompleted will happen shortly. | 73 // cancel. Ignore the call; OnReadCompleted will happen shortly. |
75 // | 74 // |
76 // TODO(davidben): Move the dispatch out of MimeTypeResourceHandler. Perhaps | 75 // TODO(davidben): Move the dispatch out of MimeTypeResourceHandler. Perhaps |
77 // all the way to the UI thread. Downloads, user certificates, etc., should be | 76 // all the way to the UI thread. Downloads, user certificates, etc., should be |
78 // dispatched at the navigation layer. | 77 // dispatched at the navigation layer. |
79 if (info->IsDownload() || info->is_stream()) | 78 if (info->IsDownload()) |
80 return true; | 79 return true; |
81 | 80 |
82 StreamContext* stream_context = | 81 StreamContext* stream_context = |
83 GetStreamContextForResourceContext(info->GetContext()); | 82 GetStreamContextForResourceContext(info->GetContext()); |
84 writer_.InitializeStream(stream_context->registry(), | 83 writer_.InitializeStream(stream_context->registry(), |
85 request()->url().GetOrigin()); | 84 request()->url().GetOrigin()); |
86 | 85 |
87 // Detach from the loader; at this point, the request is now owned by the | 86 // Detach from the loader; at this point, the request is now owned by the |
88 // StreamHandle. | 87 // StreamHandle. |
89 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); | 88 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 NOTREACHED(); | 137 NOTREACHED(); |
139 } | 138 } |
140 | 139 |
141 void NavigationResourceHandler::DetachFromCore() { | 140 void NavigationResourceHandler::DetachFromCore() { |
142 DCHECK(core_); | 141 DCHECK(core_); |
143 core_->set_resource_handler(nullptr); | 142 core_->set_resource_handler(nullptr); |
144 core_ = nullptr; | 143 core_ = nullptr; |
145 } | 144 } |
146 | 145 |
147 } // namespace content | 146 } // namespace content |
OLD | NEW |