| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" |
| 10 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 12 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 11 #include "content/browser/service_worker/embedded_worker_instance.h" | 13 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 12 #include "content/browser/service_worker/embedded_worker_registry.h" | 14 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 13 #include "content/browser/service_worker/service_worker_context_core.h" | 15 #include "content/browser/service_worker/service_worker_context_core.h" |
| 14 #include "content/browser/service_worker/service_worker_context_observer.h" | 16 #include "content/browser/service_worker/service_worker_context_observer.h" |
| 15 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 16 #include "content/browser/service_worker/service_worker_registration.h" | 18 #include "content/browser/service_worker/service_worker_registration.h" |
| 17 #include "content/browser/service_worker/service_worker_test_utils.h" | 19 #include "content/browser/service_worker/service_worker_test_utils.h" |
| 18 #include "content/browser/service_worker/service_worker_version.h" | 20 #include "content/browser/service_worker/service_worker_version.h" |
| 19 #include "content/common/service_worker/service_worker_messages.h" | 21 #include "content/common/service_worker/service_worker_messages.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 | 52 |
| 51 struct FetchResult { | 53 struct FetchResult { |
| 52 ServiceWorkerStatusCode status; | 54 ServiceWorkerStatusCode status; |
| 53 ServiceWorkerFetchEventResult result; | 55 ServiceWorkerFetchEventResult result; |
| 54 ServiceWorkerResponse response; | 56 ServiceWorkerResponse response; |
| 55 scoped_ptr<storage::BlobDataHandle> blob_data_handle; | 57 scoped_ptr<storage::BlobDataHandle> blob_data_handle; |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 void RunAndQuit(const base::Closure& closure, | 60 void RunAndQuit(const base::Closure& closure, |
| 59 const base::Closure& quit, | 61 const base::Closure& quit, |
| 60 base::MessageLoopProxy* original_message_loop) { | 62 base::SingleThreadTaskRunner* original_message_loop) { |
| 61 closure.Run(); | 63 closure.Run(); |
| 62 original_message_loop->PostTask(FROM_HERE, quit); | 64 original_message_loop->PostTask(FROM_HERE, quit); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void RunOnIOThreadWithDelay(const base::Closure& closure, | 67 void RunOnIOThreadWithDelay(const base::Closure& closure, |
| 66 base::TimeDelta delay) { | 68 base::TimeDelta delay) { |
| 67 base::RunLoop run_loop; | 69 base::RunLoop run_loop; |
| 68 BrowserThread::PostDelayedTask( | 70 BrowserThread::PostDelayedTask( |
| 69 BrowserThread::IO, FROM_HERE, | 71 BrowserThread::IO, |
| 70 base::Bind(&RunAndQuit, closure, run_loop.QuitClosure(), | 72 FROM_HERE, |
| 71 base::MessageLoopProxy::current()), | 73 base::Bind(&RunAndQuit, |
| 74 closure, |
| 75 run_loop.QuitClosure(), |
| 76 base::ThreadTaskRunnerHandle::Get()), |
| 72 delay); | 77 delay); |
| 73 run_loop.Run(); | 78 run_loop.Run(); |
| 74 } | 79 } |
| 75 | 80 |
| 76 void RunOnIOThread(const base::Closure& closure) { | 81 void RunOnIOThread(const base::Closure& closure) { |
| 77 RunOnIOThreadWithDelay(closure, base::TimeDelta()); | 82 RunOnIOThreadWithDelay(closure, base::TimeDelta()); |
| 78 } | 83 } |
| 79 | 84 |
| 80 void RunOnIOThread( | 85 void RunOnIOThread( |
| 81 const base::Callback<void(const base::Closure& continuation)>& closure) { | 86 const base::Callback<void(const base::Closure& continuation)>& closure) { |
| 82 base::RunLoop run_loop; | 87 base::RunLoop run_loop; |
| 83 base::Closure quit_on_original_thread = | 88 base::Closure quit_on_original_thread = |
| 84 base::Bind(base::IgnoreResult(&base::MessageLoopProxy::PostTask), | 89 base::Bind(base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), |
| 85 base::MessageLoopProxy::current().get(), | 90 base::ThreadTaskRunnerHandle::Get().get(), |
| 86 FROM_HERE, | 91 FROM_HERE, |
| 87 run_loop.QuitClosure()); | 92 run_loop.QuitClosure()); |
| 88 BrowserThread::PostTask(BrowserThread::IO, | 93 BrowserThread::PostTask(BrowserThread::IO, |
| 89 FROM_HERE, | 94 FROM_HERE, |
| 90 base::Bind(closure, quit_on_original_thread)); | 95 base::Bind(closure, quit_on_original_thread)); |
| 91 run_loop.Run(); | 96 run_loop.Run(); |
| 92 } | 97 } |
| 93 | 98 |
| 94 void ReceivePrepareResult(bool* is_prepared) { | 99 void ReceivePrepareResult(bool* is_prepared) { |
| 95 *is_prepared = true; | 100 *is_prepared = true; |
| (...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 ASSERT_EQ(SERVICE_WORKER_OK, status); | 1476 ASSERT_EQ(SERVICE_WORKER_OK, status); |
| 1472 // Stop the worker. | 1477 // Stop the worker. |
| 1473 StopWorker(SERVICE_WORKER_OK); | 1478 StopWorker(SERVICE_WORKER_OK); |
| 1474 // Restart the worker. | 1479 // Restart the worker. |
| 1475 StartWorker(SERVICE_WORKER_OK); | 1480 StartWorker(SERVICE_WORKER_OK); |
| 1476 // Stop the worker. | 1481 // Stop the worker. |
| 1477 StopWorker(SERVICE_WORKER_OK); | 1482 StopWorker(SERVICE_WORKER_OK); |
| 1478 } | 1483 } |
| 1479 | 1484 |
| 1480 } // namespace content | 1485 } // namespace content |
| OLD | NEW |