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

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

Issue 2678733002: [ServiceWorker] Mojofy ActivateEvent of Service Worker (Closed)
Patch Set: Rebase and address shimazu, falken and peter's comments Created 3 years, 10 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 <stdint.h> 5 #include <stdint.h>
6 #include <tuple> 6 #include <tuple>
7 7
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 activate_event_result_(blink::WebServiceWorkerEventResultCompleted) {} 1453 activate_event_result_(blink::WebServiceWorkerEventResultCompleted) {}
1454 1454
1455 void OnInstallEvent(int embedded_worker_id, 1455 void OnInstallEvent(int embedded_worker_id,
1456 int request_id) override { 1456 int request_id) override {
1457 if (!install_callback_.is_null()) 1457 if (!install_callback_.is_null())
1458 install_callback_.Run(); 1458 install_callback_.Run();
1459 SimulateSend(new ServiceWorkerHostMsg_InstallEventFinished( 1459 SimulateSend(new ServiceWorkerHostMsg_InstallEventFinished(
1460 embedded_worker_id, request_id, install_event_result_, 1460 embedded_worker_id, request_id, install_event_result_,
1461 has_fetch_handler_, base::Time::Now())); 1461 has_fetch_handler_, base::Time::Now()));
1462 } 1462 }
1463 void OnActivateEvent(int embedded_worker_id, int request_id) override { 1463
1464 SimulateSend(new ServiceWorkerHostMsg_ActivateEventFinished( 1464 void OnActivateEvent(
1465 embedded_worker_id, request_id, activate_event_result_, 1465 const mojom::ServiceWorkerEventDispatcher::DispatchActivateEventCallback&
1466 base::Time::Now())); 1466 callback) override {
1467 callback.Run(
1468 activate_event_result_ == blink::WebServiceWorkerEventResultCompleted
1469 ? SERVICE_WORKER_OK
1470 : SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED,
Peter Beverloo 2017/02/14 15:48:13 shimazu@ - it may make sense to generalize EventRe
shimazu 2017/02/15 01:29:02 I agree that we have too many duplicated codes for
xiaofengzhang 2017/02/15 01:59:46 thanks a lot for both comments. :-)
falken 2017/02/15 07:32:03 Are you sure this is possible? Don't callbacks to
shimazu 2017/02/15 08:25:34 I see. I simply assumed that it's possible because
xiaofengzhang 2017/02/16 06:17:50 Done.
1471 base::Time::Now());
1467 } 1472 }
1468 1473
1469 void set_install_callback(const base::Closure& callback) { 1474 void set_install_callback(const base::Closure& callback) {
1470 install_callback_ = callback; 1475 install_callback_ = callback;
1471 } 1476 }
1472 void set_install_event_result(blink::WebServiceWorkerEventResult result) { 1477 void set_install_event_result(blink::WebServiceWorkerEventResult result) {
1473 install_event_result_ = result; 1478 install_event_result_ = result;
1474 } 1479 }
1475 void set_activate_event_result(blink::WebServiceWorkerEventResult result) { 1480 void set_activate_event_result(blink::WebServiceWorkerEventResult result) {
1476 activate_event_result_ = result; 1481 activate_event_result_ = result;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 // should not be promoted to ACTIVATED because failure occur 1731 // should not be promoted to ACTIVATED because failure occur
1727 // during shutdown. 1732 // during shutdown.
1728 runner->RunUntilIdle(); 1733 runner->RunUntilIdle();
1729 base::RunLoop().RunUntilIdle(); 1734 base::RunLoop().RunUntilIdle();
1730 EXPECT_EQ(new_version.get(), registration->active_version()); 1735 EXPECT_EQ(new_version.get(), registration->active_version());
1731 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); 1736 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status());
1732 registration->RemoveListener(update_helper); 1737 registration->RemoveListener(update_helper);
1733 } 1738 }
1734 1739
1735 } // namespace content 1740 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698