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/service_worker/service_worker_fetch_dispatcher.h" | 5 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/browser/service_worker/service_worker_version.h" | 8 #include "content/browser/service_worker/service_worker_version.h" |
9 #include "content/public/browser/resource_request_info.h" | 9 #include "content/public/browser/resource_request_info.h" |
10 #include "content/public/common/page_transition_types.h" | 10 #include "content/public/common/page_transition_types.h" |
11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher( | 15 ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher( |
16 net::URLRequest* request, | 16 net::URLRequest* request, |
17 ServiceWorkerVersion* version, | 17 ServiceWorkerVersion* version, |
18 const FetchCallback& callback) | 18 const FetchCallback& callback) |
19 : version_(version), | 19 : version_(version), |
20 callback_(callback), | 20 callback_(callback), |
21 weak_factory_(this) { | 21 weak_factory_(this) { |
22 request_.url = request->url(); | 22 request_.url = request->url(); |
23 request_.method = request->method(); | 23 request_.method = request->method(); |
24 const net::HttpRequestHeaders& headers = request->extra_request_headers(); | 24 const net::HttpRequestHeaders& headers = request->extra_request_headers(); |
25 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) | 25 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) |
26 request_.headers[it.name()] = it.value(); | 26 request_.headers[it.name()] = it.value(); |
| 27 request_.referrer = GURL(request->referrer()); |
27 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 28 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
28 if (info) { | 29 if (info) { |
29 request_.is_reload = PageTransitionCoreTypeIs(info->GetPageTransition(), | 30 request_.is_reload = PageTransitionCoreTypeIs(info->GetPageTransition(), |
30 PAGE_TRANSITION_RELOAD); | 31 PAGE_TRANSITION_RELOAD); |
31 } | 32 } |
32 } | 33 } |
33 | 34 |
34 ServiceWorkerFetchDispatcher::~ServiceWorkerFetchDispatcher() {} | 35 ServiceWorkerFetchDispatcher::~ServiceWorkerFetchDispatcher() {} |
35 | 36 |
36 void ServiceWorkerFetchDispatcher::Run() { | 37 void ServiceWorkerFetchDispatcher::Run() { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 void ServiceWorkerFetchDispatcher::DidFinish( | 77 void ServiceWorkerFetchDispatcher::DidFinish( |
77 ServiceWorkerStatusCode status, | 78 ServiceWorkerStatusCode status, |
78 ServiceWorkerFetchEventResult fetch_result, | 79 ServiceWorkerFetchEventResult fetch_result, |
79 const ServiceWorkerResponse& response) { | 80 const ServiceWorkerResponse& response) { |
80 DCHECK(!callback_.is_null()); | 81 DCHECK(!callback_.is_null()); |
81 FetchCallback callback = callback_; | 82 FetchCallback callback = callback_; |
82 callback.Run(status, fetch_result, response); | 83 callback.Run(status, fetch_result, response); |
83 } | 84 } |
84 | 85 |
85 } // namespace content | 86 } // namespace content |
OLD | NEW |