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 "base/debug/trace_event.h" |
8 #include "content/browser/service_worker/service_worker_version.h" | 9 #include "content/browser/service_worker/service_worker_version.h" |
9 | 10 |
10 namespace content { | 11 namespace content { |
11 | 12 |
12 ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher( | 13 ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher( |
13 scoped_ptr<ServiceWorkerFetchRequest> request, | 14 scoped_ptr<ServiceWorkerFetchRequest> request, |
14 ServiceWorkerVersion* version, | 15 ServiceWorkerVersion* version, |
15 const base::Closure& prepare_callback, | 16 const base::Closure& prepare_callback, |
16 const FetchCallback& fetch_callback) | 17 const FetchCallback& fetch_callback) |
17 : version_(version), | 18 : version_(version), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // The previous activation seems to have failed, abort the step | 51 // The previous activation seems to have failed, abort the step |
51 // with activate error. (The error should be separately reported | 52 // with activate error. (The error should be separately reported |
52 // to the associated documents and association must be dropped | 53 // to the associated documents and association must be dropped |
53 // at this point) | 54 // at this point) |
54 DidFinish(SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED, | 55 DidFinish(SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED, |
55 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, | 56 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, |
56 ServiceWorkerResponse()); | 57 ServiceWorkerResponse()); |
57 } | 58 } |
58 | 59 |
59 void ServiceWorkerFetchDispatcher::DispatchFetchEvent() { | 60 void ServiceWorkerFetchDispatcher::DispatchFetchEvent() { |
| 61 TRACE_EVENT_ASYNC_BEGIN0( |
| 62 "ServiceWorker", |
| 63 "ServiceWorkerFetchDispatcher::DispatchFetchEvent", |
| 64 request_.get()); |
60 version_->DispatchFetchEvent( | 65 version_->DispatchFetchEvent( |
61 *request_.get(), | 66 *request_.get(), |
62 base::Bind(&ServiceWorkerFetchDispatcher::DidPrepare, | 67 base::Bind(&ServiceWorkerFetchDispatcher::DidPrepare, |
63 weak_factory_.GetWeakPtr()), | 68 weak_factory_.GetWeakPtr()), |
64 base::Bind(&ServiceWorkerFetchDispatcher::DidFinish, | 69 base::Bind(&ServiceWorkerFetchDispatcher::DidFinish, |
65 weak_factory_.GetWeakPtr())); | 70 weak_factory_.GetWeakPtr())); |
66 } | 71 } |
67 | 72 |
68 void ServiceWorkerFetchDispatcher::DidPrepare() { | 73 void ServiceWorkerFetchDispatcher::DidPrepare() { |
69 DCHECK(!prepare_callback_.is_null()); | 74 DCHECK(!prepare_callback_.is_null()); |
70 base::Closure prepare_callback = prepare_callback_; | 75 base::Closure prepare_callback = prepare_callback_; |
71 prepare_callback.Run(); | 76 prepare_callback.Run(); |
72 } | 77 } |
73 | 78 |
74 void ServiceWorkerFetchDispatcher::DidFinish( | 79 void ServiceWorkerFetchDispatcher::DidFinish( |
75 ServiceWorkerStatusCode status, | 80 ServiceWorkerStatusCode status, |
76 ServiceWorkerFetchEventResult fetch_result, | 81 ServiceWorkerFetchEventResult fetch_result, |
77 const ServiceWorkerResponse& response) { | 82 const ServiceWorkerResponse& response) { |
| 83 TRACE_EVENT_ASYNC_END0( |
| 84 "ServiceWorker", |
| 85 "ServiceWorkerFetchDispatcher::DispatchFetchEvent", |
| 86 request_.get()); |
78 DCHECK(!fetch_callback_.is_null()); | 87 DCHECK(!fetch_callback_.is_null()); |
79 FetchCallback fetch_callback = fetch_callback_; | 88 FetchCallback fetch_callback = fetch_callback_; |
80 fetch_callback.Run(status, fetch_result, response); | 89 fetch_callback.Run(status, fetch_result, response); |
81 } | 90 } |
82 | 91 |
83 } // namespace content | 92 } // namespace content |
OLD | NEW |