OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "content/browser/service_worker/embedded_worker_status.h" | 10 #include "content/browser/service_worker/embedded_worker_status.h" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 return; | 420 return; |
421 } | 421 } |
422 | 422 |
423 DCHECK_EQ(ServiceWorkerVersion::ACTIVATING, activating_version->status()); | 423 DCHECK_EQ(ServiceWorkerVersion::ACTIVATING, activating_version->status()); |
424 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, activating_version->running_status()) | 424 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, activating_version->running_status()) |
425 << "Worker stopped too soon after it was started."; | 425 << "Worker stopped too soon after it was started."; |
426 int request_id = activating_version->StartRequest( | 426 int request_id = activating_version->StartRequest( |
427 ServiceWorkerMetrics::EventType::ACTIVATE, | 427 ServiceWorkerMetrics::EventType::ACTIVATE, |
428 base::Bind(&ServiceWorkerRegistration::OnActivateEventFinished, this, | 428 base::Bind(&ServiceWorkerRegistration::OnActivateEventFinished, this, |
429 activating_version)); | 429 activating_version)); |
430 activating_version | 430 activating_version->event_dispatcher()->DispatchActivateEvent( |
431 ->DispatchSimpleEvent<ServiceWorkerHostMsg_ActivateEventFinished>( | 431 base::Bind(&ServiceWorkerVersion::OnSimpleEventFinished, |
432 request_id, ServiceWorkerMsg_ActivateEvent(request_id)); | 432 activating_version, request_id)); |
shimazu
2017/02/07 04:43:48
Could you use base::Unretained(activating_version.
xiaofengzhang
2017/02/07 06:15:36
Sure. But I am a little confused that other places
shimazu
2017/02/07 07:19:31
Oops, I didn't realize that. I think base::Unretai
Peter Beverloo
2017/02/08 15:13:16
That's great context - thanks shimazu!
It would b
shimazu
2017/02/10 05:42:27
Yeah, I also feel it's scary.
How about having a
| |
433 } | 433 } |
434 | 434 |
435 void ServiceWorkerRegistration::OnActivateEventFinished( | 435 void ServiceWorkerRegistration::OnActivateEventFinished( |
436 scoped_refptr<ServiceWorkerVersion> activating_version, | 436 scoped_refptr<ServiceWorkerVersion> activating_version, |
437 ServiceWorkerStatusCode status) { | 437 ServiceWorkerStatusCode status) { |
438 // Activate is prone to failing due to shutdown, because it's triggered when | 438 // Activate is prone to failing due to shutdown, because it's triggered when |
439 // tabs close. | 439 // tabs close. |
440 bool is_shutdown = | 440 bool is_shutdown = |
441 !context_ || context_->wrapper()->process_manager()->IsShutdown(); | 441 !context_ || context_->wrapper()->process_manager()->IsShutdown(); |
442 ServiceWorkerMetrics::RecordActivateEventStatus(status, is_shutdown); | 442 ServiceWorkerMetrics::RecordActivateEventStatus(status, is_shutdown); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 if (!context_) { | 514 if (!context_) { |
515 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 515 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
516 return; | 516 return; |
517 } | 517 } |
518 context_->storage()->NotifyDoneInstallingRegistration( | 518 context_->storage()->NotifyDoneInstallingRegistration( |
519 this, version.get(), status); | 519 this, version.get(), status); |
520 callback.Run(status); | 520 callback.Run(status); |
521 } | 521 } |
522 | 522 |
523 } // namespace content | 523 } // namespace content |
OLD | NEW |