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 scoped_ptr<NavigationRequestInfo> request_info, | 21 scoped_ptr<NavigationRequestInfo> request_info, |
21 NavigationURLLoaderDelegate* delegate) | 22 NavigationURLLoaderDelegate* delegate) |
22 : delegate_(delegate), | 23 : delegate_(delegate), |
23 weak_factory_(this) { | 24 weak_factory_(this) { |
24 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 25 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
25 | 26 |
26 core_ = new NavigationURLLoaderImplCore(weak_factory_.GetWeakPtr()); | 27 // TODO(clamy): Picking the partition based on the URL is incorrect. |
| 28 // See crbug.com/513539 |
| 29 StoragePartition* partition = BrowserContext::GetStoragePartitionForSite( |
| 30 browser_context, request_info->common_params.url); |
| 31 DCHECK(partition); |
| 32 core_ = new NavigationURLLoaderImplCore(weak_factory_.GetWeakPtr(), |
| 33 partition->GetServiceWorkerContext()); |
27 BrowserThread::PostTask( | 34 BrowserThread::PostTask( |
28 BrowserThread::IO, FROM_HERE, | 35 BrowserThread::IO, FROM_HERE, |
29 base::Bind(&NavigationURLLoaderImplCore::Start, base::Unretained(core_), | 36 base::Bind(&NavigationURLLoaderImplCore::Start, base::Unretained(core_), |
30 browser_context->GetResourceContext(), | 37 browser_context->GetResourceContext(), |
31 base::Passed(&request_info))); | 38 base::Passed(&request_info))); |
32 } | 39 } |
33 | 40 |
34 NavigationURLLoaderImpl::~NavigationURLLoaderImpl() { | 41 NavigationURLLoaderImpl::~NavigationURLLoaderImpl() { |
35 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
36 | 43 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 delegate_->OnRequestFailed(in_cache, net_error); | 77 delegate_->OnRequestFailed(in_cache, net_error); |
71 } | 78 } |
72 | 79 |
73 void NavigationURLLoaderImpl::NotifyRequestStarted(base::TimeTicks timestamp) { | 80 void NavigationURLLoaderImpl::NotifyRequestStarted(base::TimeTicks timestamp) { |
74 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 81 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
75 | 82 |
76 delegate_->OnRequestStarted(timestamp); | 83 delegate_->OnRequestStarted(timestamp); |
77 } | 84 } |
78 | 85 |
79 } // namespace content | 86 } // namespace content |
OLD | NEW |