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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 const base::Closure& quit, | 76 const base::Closure& quit, |
77 base::SingleThreadTaskRunner* original_message_loop) { | 77 base::SingleThreadTaskRunner* original_message_loop) { |
78 closure.Run(); | 78 closure.Run(); |
79 original_message_loop->PostTask(FROM_HERE, quit); | 79 original_message_loop->PostTask(FROM_HERE, quit); |
80 } | 80 } |
81 | 81 |
82 void RunOnIOThreadWithDelay(const base::Closure& closure, | 82 void RunOnIOThreadWithDelay(const base::Closure& closure, |
83 base::TimeDelta delay) { | 83 base::TimeDelta delay) { |
84 base::RunLoop run_loop; | 84 base::RunLoop run_loop; |
85 BrowserThread::PostDelayedTask( | 85 BrowserThread::PostDelayedTask( |
86 BrowserThread::IO, | 86 BrowserThread::IO, FROM_HERE, |
87 FROM_HERE, | 87 base::Bind(&RunAndQuit, closure, run_loop.QuitClosure(), |
88 base::Bind(&RunAndQuit, | 88 base::RetainedRef(base::ThreadTaskRunnerHandle::Get())), |
89 closure, | |
90 run_loop.QuitClosure(), | |
91 base::ThreadTaskRunnerHandle::Get()), | |
92 delay); | 89 delay); |
93 run_loop.Run(); | 90 run_loop.Run(); |
94 } | 91 } |
95 | 92 |
96 void RunOnIOThread(const base::Closure& closure) { | 93 void RunOnIOThread(const base::Closure& closure) { |
97 RunOnIOThreadWithDelay(closure, base::TimeDelta()); | 94 RunOnIOThreadWithDelay(closure, base::TimeDelta()); |
98 } | 95 } |
99 | 96 |
100 void RunOnIOThread( | 97 void RunOnIOThread( |
101 const base::Callback<void(const base::Closure& continuation)>& closure) { | 98 const base::Callback<void(const base::Closure& continuation)>& closure) { |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 actual_response.blob_uuid); | 684 actual_response.blob_uuid); |
688 } | 685 } |
689 if (!quit.is_null()) | 686 if (!quit.is_null()) |
690 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit); | 687 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit); |
691 } | 688 } |
692 | 689 |
693 ServiceWorkerFetchDispatcher::FetchCallback CreateResponseReceiver( | 690 ServiceWorkerFetchDispatcher::FetchCallback CreateResponseReceiver( |
694 const base::Closure& quit, | 691 const base::Closure& quit, |
695 ChromeBlobStorageContext* blob_context, | 692 ChromeBlobStorageContext* blob_context, |
696 FetchResult* result) { | 693 FetchResult* result) { |
697 return base::Bind( | 694 return base::Bind(&self::ReceiveFetchResultOnIOThread, this, quit, |
698 &self::ReceiveFetchResultOnIOThread, this, quit, | 695 base::RetainedRef(blob_context), result); |
699 make_scoped_refptr<ChromeBlobStorageContext>(blob_context), result); | |
700 } | 696 } |
701 | 697 |
702 void StopOnIOThread(const base::Closure& done, | 698 void StopOnIOThread(const base::Closure& done, |
703 ServiceWorkerStatusCode* result) { | 699 ServiceWorkerStatusCode* result) { |
704 ASSERT_TRUE(version_.get()); | 700 ASSERT_TRUE(version_.get()); |
705 version_->StopWorker(CreateReceiver(BrowserThread::UI, done, result)); | 701 version_->StopWorker(CreateReceiver(BrowserThread::UI, done, result)); |
706 } | 702 } |
707 | 703 |
708 protected: | 704 protected: |
709 scoped_refptr<ServiceWorkerRegistration> registration_; | 705 scoped_refptr<ServiceWorkerRegistration> registration_; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 ASSERT_EQ(SERVICE_WORKER_OK, status); | 1484 ASSERT_EQ(SERVICE_WORKER_OK, status); |
1489 // Stop the worker. | 1485 // Stop the worker. |
1490 StopWorker(SERVICE_WORKER_OK); | 1486 StopWorker(SERVICE_WORKER_OK); |
1491 // Restart the worker. | 1487 // Restart the worker. |
1492 StartWorker(SERVICE_WORKER_OK); | 1488 StartWorker(SERVICE_WORKER_OK); |
1493 // Stop the worker. | 1489 // Stop the worker. |
1494 StopWorker(SERVICE_WORKER_OK); | 1490 StopWorker(SERVICE_WORKER_OK); |
1495 } | 1491 } |
1496 | 1492 |
1497 } // namespace content | 1493 } // namespace content |
OLD | NEW |