Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: content/browser/service_worker/service_worker_fetch_dispatcher.cc

Issue 475333002: [ServiceWorker] Sends the blob uuid of the request body to the ServiceWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve blobs Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
10 #include "content/public/common/page_transition_types.h"
11 #include "net/url_request/url_request.h"
12 9
13 namespace content { 10 namespace content {
14 11
15 ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher( 12 ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher(
16 net::URLRequest* request, 13 scoped_ptr<ServiceWorkerFetchRequest> request,
17 ServiceWorkerVersion* version, 14 ServiceWorkerVersion* version,
18 const FetchCallback& callback) 15 const FetchCallback& callback)
19 : version_(version), 16 : version_(version),
20 callback_(callback), 17 callback_(callback),
18 request_(request.Pass()),
21 weak_factory_(this) { 19 weak_factory_(this) {
22 request_.url = request->url();
23 request_.method = request->method();
24 const net::HttpRequestHeaders& headers = request->extra_request_headers();
25 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();)
26 request_.headers[it.name()] = it.value();
27 request_.referrer = GURL(request->referrer());
28 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
29 if (info) {
30 request_.is_reload = PageTransitionCoreTypeIs(info->GetPageTransition(),
31 PAGE_TRANSITION_RELOAD);
32 }
33 } 20 }
34 21
35 ServiceWorkerFetchDispatcher::~ServiceWorkerFetchDispatcher() {} 22 ServiceWorkerFetchDispatcher::~ServiceWorkerFetchDispatcher() {}
36 23
37 void ServiceWorkerFetchDispatcher::Run() { 24 void ServiceWorkerFetchDispatcher::Run() {
38 DCHECK(version_->status() == ServiceWorkerVersion::ACTIVATING || 25 DCHECK(version_->status() == ServiceWorkerVersion::ACTIVATING ||
39 version_->status() == ServiceWorkerVersion::ACTIVATED) 26 version_->status() == ServiceWorkerVersion::ACTIVATED)
40 << version_->status(); 27 << version_->status();
41 28
42 if (version_->status() == ServiceWorkerVersion::ACTIVATING) { 29 if (version_->status() == ServiceWorkerVersion::ACTIVATING) {
(...skipping 19 matching lines...) Expand all
62 // with activate error. (The error should be separately reported 49 // with activate error. (The error should be separately reported
63 // to the associated documents and association must be dropped 50 // to the associated documents and association must be dropped
64 // at this point) 51 // at this point)
65 DidFinish(SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED, 52 DidFinish(SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED,
66 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, 53 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK,
67 ServiceWorkerResponse()); 54 ServiceWorkerResponse());
68 } 55 }
69 56
70 void ServiceWorkerFetchDispatcher::DispatchFetchEvent() { 57 void ServiceWorkerFetchDispatcher::DispatchFetchEvent() {
71 version_->DispatchFetchEvent( 58 version_->DispatchFetchEvent(
72 request_, 59 *request_.get(),
73 base::Bind(&ServiceWorkerFetchDispatcher::DidFinish, 60 base::Bind(&ServiceWorkerFetchDispatcher::DidFinish,
74 weak_factory_.GetWeakPtr())); 61 weak_factory_.GetWeakPtr()));
75 } 62 }
76 63
77 void ServiceWorkerFetchDispatcher::DidFinish( 64 void ServiceWorkerFetchDispatcher::DidFinish(
78 ServiceWorkerStatusCode status, 65 ServiceWorkerStatusCode status,
79 ServiceWorkerFetchEventResult fetch_result, 66 ServiceWorkerFetchEventResult fetch_result,
80 const ServiceWorkerResponse& response) { 67 const ServiceWorkerResponse& response) {
81 DCHECK(!callback_.is_null()); 68 DCHECK(!callback_.is_null());
82 FetchCallback callback = callback_; 69 FetchCallback callback = callback_;
83 callback.Run(status, fetch_result, response); 70 callback.Run(status, fetch_result, response);
84 } 71 }
85 72
86 } // namespace content 73 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698