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

Unified Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 493373002: ServiceWorker: Add prepare_callback in DispatchFetchEvent to notify the end of SW preparation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the test failure and rebase Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_fetch_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_browsertest.cc
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc
index abd8a4f4a59af7cfbbff57c16a3a76cede1b5729..a1a26585aa8ce99a5889f486888716fdaddede49 100644
--- a/content/browser/service_worker/service_worker_browsertest.cc
+++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -80,6 +80,14 @@ void RunOnIOThread(
run_loop.Run();
}
+void ReceivePrepareResult(bool* is_prepared) {
+ *is_prepared = true;
+}
+
+base::Closure CreatePrepareReceiver(bool* is_prepared) {
+ return base::Bind(&ReceivePrepareResult, is_prepared);
+}
+
// Contrary to the style guide, the output parameter of this function comes
// before input parameters so Bind can be used on it to create a FetchCallback
// to pass to DispatchFetchEvent.
@@ -466,6 +474,7 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest {
scoped_ptr<storage::BlobDataHandle>* blob_data_handle) {
blob_context_ = ChromeBlobStorageContext::GetFor(
shell()->web_contents()->GetBrowserContext());
+ bool prepare_result = false;
FetchResult fetch_result;
fetch_result.status = SERVICE_WORKER_ERROR_FAILED;
base::RunLoop fetch_run_loop;
@@ -474,8 +483,10 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest {
base::Bind(&self::FetchOnIOThread,
this,
fetch_run_loop.QuitClosure(),
+ &prepare_result,
&fetch_result));
fetch_run_loop.Run();
+ ASSERT_TRUE(prepare_result);
*result = fetch_result.result;
*response = fetch_result.response;
*blob_data_handle = fetch_result.blob_data_handle.Pass();
@@ -526,7 +537,9 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest {
CreateReceiver(BrowserThread::UI, done, result));
}
- void FetchOnIOThread(const base::Closure& done, FetchResult* result) {
+ void FetchOnIOThread(const base::Closure& done,
+ bool* prepare_result,
+ FetchResult* result) {
ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
ServiceWorkerFetchRequest request(
embedded_test_server()->GetURL("/service_worker/empty.html"),
@@ -537,6 +550,7 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest {
version_->SetStatus(ServiceWorkerVersion::ACTIVATED);
version_->DispatchFetchEvent(
request,
+ CreatePrepareReceiver(prepare_result),
nhiroki 2014/08/27 05:05:38 nit: I think we don't have to use this indirect ca
CreateResponseReceiver(
BrowserThread::UI, done, blob_context_.get(), result));
}
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_fetch_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698