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_url_loader_impl.h" | 5 #include "content/browser/loader/navigation_url_loader_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "content/browser/frame_host/navigation_request_info.h" | 9 #include "content/browser/frame_host/navigation_request_info.h" |
10 #include "content/browser/loader/navigation_url_loader_delegate.h" | 10 #include "content/browser/loader/navigation_url_loader_delegate.h" |
11 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 11 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/storage_partition.h" |
14 #include "content/public/browser/stream_handle.h" | 15 #include "content/public/browser/stream_handle.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 NavigationURLLoaderImpl::NavigationURLLoaderImpl( | 19 NavigationURLLoaderImpl::NavigationURLLoaderImpl( |
19 BrowserContext* browser_context, | 20 BrowserContext* browser_context, |
20 int frame_tree_node_id, | 21 int frame_tree_node_id, |
21 scoped_ptr<NavigationRequestInfo> request_info, | 22 scoped_ptr<NavigationRequestInfo> request_info, |
22 NavigationURLLoaderDelegate* delegate) | 23 NavigationURLLoaderDelegate* delegate) |
23 : delegate_(delegate), | 24 : delegate_(delegate), |
24 weak_factory_(this) { | 25 weak_factory_(this) { |
25 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 26 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
26 | 27 |
27 core_ = new NavigationURLLoaderImplCore(weak_factory_.GetWeakPtr()); | 28 StoragePartition* partition = BrowserContext::GetStoragePartitionForSite( |
| 29 browser_context, request_info->common_params.url); |
| 30 DCHECK(partition); |
| 31 core_ = new NavigationURLLoaderImplCore(weak_factory_.GetWeakPtr(), |
| 32 partition->GetServiceWorkerContext()); |
28 BrowserThread::PostTask( | 33 BrowserThread::PostTask( |
29 BrowserThread::IO, FROM_HERE, | 34 BrowserThread::IO, FROM_HERE, |
30 base::Bind(&NavigationURLLoaderImplCore::Start, base::Unretained(core_), | 35 base::Bind(&NavigationURLLoaderImplCore::Start, base::Unretained(core_), |
31 browser_context->GetResourceContext(), frame_tree_node_id, | 36 browser_context->GetResourceContext(), frame_tree_node_id, |
32 base::Passed(&request_info))); | 37 base::Passed(&request_info))); |
33 } | 38 } |
34 | 39 |
35 NavigationURLLoaderImpl::~NavigationURLLoaderImpl() { | 40 NavigationURLLoaderImpl::~NavigationURLLoaderImpl() { |
36 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 41 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
37 | 42 |
(...skipping 13 matching lines...) Expand all Loading... |
51 void NavigationURLLoaderImpl::NotifyRequestRedirected( | 56 void NavigationURLLoaderImpl::NotifyRequestRedirected( |
52 const net::RedirectInfo& redirect_info, | 57 const net::RedirectInfo& redirect_info, |
53 const scoped_refptr<ResourceResponse>& response) { | 58 const scoped_refptr<ResourceResponse>& response) { |
54 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
55 | 60 |
56 delegate_->OnRequestRedirected(redirect_info, response); | 61 delegate_->OnRequestRedirected(redirect_info, response); |
57 } | 62 } |
58 | 63 |
59 void NavigationURLLoaderImpl::NotifyResponseStarted( | 64 void NavigationURLLoaderImpl::NotifyResponseStarted( |
60 const scoped_refptr<ResourceResponse>& response, | 65 const scoped_refptr<ResourceResponse>& response, |
61 scoped_ptr<StreamHandle> body) { | 66 scoped_ptr<StreamHandle> body, |
| 67 int navigation_provider_id) { |
62 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 68 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
63 | 69 |
64 delegate_->OnResponseStarted(response, body.Pass()); | 70 delegate_->OnResponseStarted(response, body.Pass(), navigation_provider_id); |
65 } | 71 } |
66 | 72 |
67 void NavigationURLLoaderImpl::NotifyRequestFailed(bool in_cache, | 73 void NavigationURLLoaderImpl::NotifyRequestFailed(bool in_cache, |
68 int net_error) { | 74 int net_error) { |
69 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 75 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
70 | 76 |
71 delegate_->OnRequestFailed(in_cache, net_error); | 77 delegate_->OnRequestFailed(in_cache, net_error); |
72 } | 78 } |
73 | 79 |
74 void NavigationURLLoaderImpl::NotifyRequestStarted(base::TimeTicks timestamp) { | 80 void NavigationURLLoaderImpl::NotifyRequestStarted(base::TimeTicks timestamp) { |
75 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 81 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
76 | 82 |
77 delegate_->OnRequestStarted(timestamp); | 83 delegate_->OnRequestStarted(timestamp); |
78 } | 84 } |
79 | 85 |
80 } // namespace content | 86 } // namespace content |
OLD | NEW |