| 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_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "content/browser/service_worker/embedded_worker_instance.h" | 10 #include "content/browser/service_worker/embedded_worker_instance.h" |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 | 556 |
| 557 void ServiceWorkerVersion::OnActivateEventFinished( | 557 void ServiceWorkerVersion::OnActivateEventFinished( |
| 558 int request_id, | 558 int request_id, |
| 559 blink::WebServiceWorkerEventResult result) { | 559 blink::WebServiceWorkerEventResult result) { |
| 560 StatusCallback* callback = activate_callbacks_.Lookup(request_id); | 560 StatusCallback* callback = activate_callbacks_.Lookup(request_id); |
| 561 if (!callback) { | 561 if (!callback) { |
| 562 NOTREACHED() << "Got unexpected message: " << request_id; | 562 NOTREACHED() << "Got unexpected message: " << request_id; |
| 563 return; | 563 return; |
| 564 } | 564 } |
| 565 ServiceWorkerStatusCode status = SERVICE_WORKER_OK; | 565 ServiceWorkerStatusCode status = SERVICE_WORKER_OK; |
| 566 if (result == blink::WebServiceWorkerEventResultRejected) | 566 if (result == blink::WebServiceWorkerEventResultRejected) { |
| 567 status = SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED; | 567 status = SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED; |
| 568 else | 568 SetStatus(REDUNDANT); |
| 569 } else { |
| 569 SetStatus(ACTIVE); | 570 SetStatus(ACTIVE); |
| 571 } |
| 570 | 572 |
| 571 scoped_refptr<ServiceWorkerVersion> protect(this); | 573 scoped_refptr<ServiceWorkerVersion> protect(this); |
| 572 callback->Run(status); | 574 callback->Run(status); |
| 573 activate_callbacks_.Remove(request_id); | 575 activate_callbacks_.Remove(request_id); |
| 574 } | 576 } |
| 575 | 577 |
| 576 void ServiceWorkerVersion::OnInstallEventFinished( | 578 void ServiceWorkerVersion::OnInstallEventFinished( |
| 577 int request_id, | 579 int request_id, |
| 578 blink::WebServiceWorkerEventResult result) { | 580 blink::WebServiceWorkerEventResult result) { |
| 579 StatusCallback* callback = install_callbacks_.Lookup(request_id); | 581 StatusCallback* callback = install_callbacks_.Lookup(request_id); |
| 580 if (!callback) { | 582 if (!callback) { |
| 581 NOTREACHED() << "Got unexpected message: " << request_id; | 583 NOTREACHED() << "Got unexpected message: " << request_id; |
| 582 return; | 584 return; |
| 583 } | 585 } |
| 584 ServiceWorkerStatusCode status = SERVICE_WORKER_OK; | 586 ServiceWorkerStatusCode status = SERVICE_WORKER_OK; |
| 585 if (result == blink::WebServiceWorkerEventResultRejected) | 587 if (result == blink::WebServiceWorkerEventResultRejected) { |
| 586 status = SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED; | 588 status = SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED; |
| 587 else | 589 SetStatus(REDUNDANT); |
| 590 } else { |
| 588 SetStatus(INSTALLED); | 591 SetStatus(INSTALLED); |
| 592 } |
| 589 | 593 |
| 590 scoped_refptr<ServiceWorkerVersion> protect(this); | 594 scoped_refptr<ServiceWorkerVersion> protect(this); |
| 591 callback->Run(status); | 595 callback->Run(status); |
| 592 install_callbacks_.Remove(request_id); | 596 install_callbacks_.Remove(request_id); |
| 593 } | 597 } |
| 594 | 598 |
| 595 void ServiceWorkerVersion::OnFetchEventFinished( | 599 void ServiceWorkerVersion::OnFetchEventFinished( |
| 596 int request_id, | 600 int request_id, |
| 597 ServiceWorkerFetchEventResult result, | 601 ServiceWorkerFetchEventResult result, |
| 598 const ServiceWorkerResponse& response) { | 602 const ServiceWorkerResponse& response) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 return; | 658 return; |
| 655 } | 659 } |
| 656 stop_worker_timer_.Start( | 660 stop_worker_timer_.Start( |
| 657 FROM_HERE, base::TimeDelta::FromSeconds(kStopWorkerDelay), | 661 FROM_HERE, base::TimeDelta::FromSeconds(kStopWorkerDelay), |
| 658 base::Bind(&ServiceWorkerVersion::StopWorker, | 662 base::Bind(&ServiceWorkerVersion::StopWorker, |
| 659 weak_factory_.GetWeakPtr(), | 663 weak_factory_.GetWeakPtr(), |
| 660 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback))); | 664 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback))); |
| 661 } | 665 } |
| 662 | 666 |
| 663 } // namespace content | 667 } // namespace content |
| OLD | NEW |