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_url_request_job.h" | 5 #include "content/browser/service_worker/service_worker_url_request_job.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 return; | 222 return; |
223 | 223 |
224 case FORWARD_TO_SERVICE_WORKER: | 224 case FORWARD_TO_SERVICE_WORKER: |
225 DCHECK(provider_host_ && provider_host_->active_version()); | 225 DCHECK(provider_host_ && provider_host_->active_version()); |
226 DCHECK(!fetch_dispatcher_); | 226 DCHECK(!fetch_dispatcher_); |
227 // Send a fetch event to the ServiceWorker associated to the | 227 // Send a fetch event to the ServiceWorker associated to the |
228 // provider_host. | 228 // provider_host. |
229 fetch_dispatcher_.reset(new ServiceWorkerFetchDispatcher( | 229 fetch_dispatcher_.reset(new ServiceWorkerFetchDispatcher( |
230 CreateFetchRequest(), | 230 CreateFetchRequest(), |
231 provider_host_->active_version(), | 231 provider_host_->active_version(), |
232 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, | |
233 weak_factory_.GetWeakPtr()), | |
232 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, | 234 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, |
233 weak_factory_.GetWeakPtr()))); | 235 weak_factory_.GetWeakPtr()))); |
234 fetch_dispatcher_->Run(); | 236 fetch_dispatcher_->Run(); |
235 return; | 237 return; |
236 } | 238 } |
237 | 239 |
238 NOTREACHED(); | 240 NOTREACHED(); |
239 } | 241 } |
240 | 242 |
241 scoped_ptr<ServiceWorkerFetchRequest> | 243 scoped_ptr<ServiceWorkerFetchRequest> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 } | 317 } |
316 } | 318 } |
317 | 319 |
318 request_body_blob_data_handle_ = | 320 request_body_blob_data_handle_ = |
319 blob_storage_context_->AddFinishedBlob(blob_data.get()); | 321 blob_storage_context_->AddFinishedBlob(blob_data.get()); |
320 *blob_uuid = uuid; | 322 *blob_uuid = uuid; |
321 *blob_size = size; | 323 *blob_size = size; |
322 return true; | 324 return true; |
323 } | 325 } |
324 | 326 |
327 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent() { | |
nhiroki
2014/08/22 04:50:58
Can you add a comment here?
For example, if you w
horo
2014/08/22 05:11:51
Please write TODO comments.
shimazu
2014/08/25 02:17:40
Done.
shimazu
2014/08/25 02:17:40
Done.
| |
328 } | |
329 | |
325 void ServiceWorkerURLRequestJob::DidDispatchFetchEvent( | 330 void ServiceWorkerURLRequestJob::DidDispatchFetchEvent( |
326 ServiceWorkerStatusCode status, | 331 ServiceWorkerStatusCode status, |
327 ServiceWorkerFetchEventResult fetch_result, | 332 ServiceWorkerFetchEventResult fetch_result, |
328 const ServiceWorkerResponse& response) { | 333 const ServiceWorkerResponse& response) { |
329 fetch_dispatcher_.reset(); | 334 fetch_dispatcher_.reset(); |
330 | 335 |
331 // Check if we're not orphaned. | 336 // Check if we're not orphaned. |
332 if (!request()) | 337 if (!request()) |
333 return; | 338 return; |
334 | 339 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 411 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
407 // TODO(falken): Print an error to the console of the ServiceWorker and of | 412 // TODO(falken): Print an error to the console of the ServiceWorker and of |
408 // the requesting page. | 413 // the requesting page. |
409 CreateResponseHeader(500, | 414 CreateResponseHeader(500, |
410 "Service Worker Response Error", | 415 "Service Worker Response Error", |
411 std::map<std::string, std::string>()); | 416 std::map<std::string, std::string>()); |
412 CommitResponseHeader(); | 417 CommitResponseHeader(); |
413 } | 418 } |
414 | 419 |
415 } // namespace content | 420 } // namespace content |
OLD | NEW |