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

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

Issue 2002883002: ServiceWorker: Store the existence of fetch event handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DispatchInstallEvent Created 4 years, 7 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 base::Bind(&self::DispatchInstallEventOnIOThread, this, done, result), 644 base::Bind(&self::DispatchInstallEventOnIOThread, this, done, result),
645 CreateReceiver(BrowserThread::UI, done, result)); 645 CreateReceiver(BrowserThread::UI, done, result));
646 } 646 }
647 647
648 void DispatchInstallEventOnIOThread(const base::Closure& done, 648 void DispatchInstallEventOnIOThread(const base::Closure& done,
649 ServiceWorkerStatusCode* result) { 649 ServiceWorkerStatusCode* result) {
650 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 650 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
651 int request_id = 651 int request_id =
652 version_->StartRequest(ServiceWorkerMetrics::EventType::INSTALL, 652 version_->StartRequest(ServiceWorkerMetrics::EventType::INSTALL,
653 CreateReceiver(BrowserThread::UI, done, result)); 653 CreateReceiver(BrowserThread::UI, done, result));
654 version_->DispatchSimpleEvent<ServiceWorkerHostMsg_InstallEventFinished>( 654 version_->DispatchEvent<ServiceWorkerHostMsg_InstallEventFinished>(
655 request_id, ServiceWorkerMsg_InstallEvent(request_id)); 655 request_id, ServiceWorkerMsg_InstallEvent(request_id),
656 base::Bind(&self::ReceiveInstallEventOnIOThread, this, done, result));
657 }
658
659 void ReceiveInstallEventOnIOThread(const base::Closure& done,
660 ServiceWorkerStatusCode* out_result,
661 int request_id,
662 blink::WebServiceWorkerEventResult result,
663 bool has_fetch_handler) {
664 version_->FinishRequest(
665 request_id, result == blink::WebServiceWorkerEventResultCompleted);
666
667 ServiceWorkerStatusCode status = SERVICE_WORKER_OK;
668 if (result == blink::WebServiceWorkerEventResultRejected)
669 status = SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED;
670
671 *out_result = status;
672 if (!done.is_null())
673 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, done);
656 } 674 }
657 675
658 void StoreOnIOThread(const base::Closure& done, 676 void StoreOnIOThread(const base::Closure& done,
659 ServiceWorkerStatusCode* result, 677 ServiceWorkerStatusCode* result,
660 int64_t version_id) { 678 int64_t version_id) {
661 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 679 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
662 ServiceWorkerVersion* version = 680 ServiceWorkerVersion* version =
663 wrapper()->context()->GetLiveVersion(version_id); 681 wrapper()->context()->GetLiveVersion(version_id);
664 wrapper()->context()->storage()->StoreRegistration( 682 wrapper()->context()->storage()->StoreRegistration(
665 registration_.get(), version, 683 registration_.get(), version,
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 NavigateToTestPage(); 1852 NavigateToTestPage();
1835 // The V8 code cache must be stored to the CacheStorage which must be bigger 1853 // The V8 code cache must be stored to the CacheStorage which must be bigger
1836 // than 12 byte. 1854 // than 12 byte.
1837 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); 1855 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize);
1838 1856
1839 NavigateToTestPage(); 1857 NavigateToTestPage();
1840 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); 1858 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize);
1841 } 1859 }
1842 1860
1843 } // namespace content 1861 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698