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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class ServiceWorkerContextCore; | |
18 class ServiceWorkerDispatcherHost; | |
19 class ServiceWorkerProviderHost; | |
20 | |
17 template <typename Arg> | 21 template <typename Arg> |
18 void ReceiveResult(BrowserThread::ID run_quit_thread, | 22 void ReceiveResult(BrowserThread::ID run_quit_thread, |
19 const base::Closure& quit, | 23 const base::Closure& quit, |
20 Arg* out, Arg actual) { | 24 Arg* out, Arg actual) { |
21 *out = actual; | 25 *out = actual; |
22 if (!quit.is_null()) | 26 if (!quit.is_null()) |
23 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); | 27 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); |
24 } | 28 } |
25 | 29 |
26 template <typename Arg> base::Callback<void(Arg)> | 30 template <typename Arg> base::Callback<void(Arg)> |
27 CreateReceiver(BrowserThread::ID run_quit_thread, | 31 CreateReceiver(BrowserThread::ID run_quit_thread, |
28 const base::Closure& quit, Arg* out) { | 32 const base::Closure& quit, Arg* out) { |
29 return base::Bind(&ReceiveResult<Arg>, run_quit_thread, quit, out); | 33 return base::Bind(&ReceiveResult<Arg>, run_quit_thread, quit, out); |
30 } | 34 } |
31 | 35 |
32 template <typename Arg> | 36 template <typename Arg> |
33 base::Callback<void(Arg)> CreateReceiverOnCurrentThread( | 37 base::Callback<void(Arg)> CreateReceiverOnCurrentThread( |
34 Arg* out, | 38 Arg* out, |
35 const base::Closure& quit = base::Closure()) { | 39 const base::Closure& quit = base::Closure()) { |
36 BrowserThread::ID id; | 40 BrowserThread::ID id; |
37 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); | 41 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); |
38 DCHECK(ret); | 42 DCHECK(ret); |
39 return base::Bind(&ReceiveResult<Arg>, id, quit, out); | 43 return base::Bind(&ReceiveResult<Arg>, id, quit, out); |
40 } | 44 } |
41 | 45 |
46 std::unique_ptr<ServiceWorkerProviderHost> CreateProviderHostForWindow( | |
dcheng
2017/02/14 08:47:46
#include <memory> for unique_ptr
shimazu
2017/02/15 02:24:18
Done.
| |
47 int process_id, | |
48 int provider_id, | |
49 bool is_parent_frame_secure, | |
50 base::WeakPtr<ServiceWorkerContextCore> context); | |
dcheng
2017/02/14 08:47:46
#include "base/memory/weak_ptr.h" for WeakPtr
shimazu
2017/02/15 02:24:18
Done.
| |
51 | |
52 std::unique_ptr<ServiceWorkerProviderHost> | |
53 CreateProviderHostForServiceWorkerContext( | |
54 int process_id, | |
55 int provider_id, | |
56 bool is_parent_frame_secure, | |
57 base::WeakPtr<ServiceWorkerContextCore> context); | |
58 | |
59 std::unique_ptr<ServiceWorkerProviderHost> CreateProviderHostWithDispatcherHost( | |
60 int process_id, | |
61 int provider_id, | |
62 base::WeakPtr<ServiceWorkerContextCore> context, | |
63 int route_id, | |
64 ServiceWorkerDispatcherHost* dispatcher_host); | |
65 | |
42 } // namespace content | 66 } // namespace content |
43 | 67 |
44 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ | 68 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ |
OLD | NEW |