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 "content/shell/browser/shell_mojo_test_utils_android.h" | 5 #include "content/shell/browser/shell_mojo_test_utils_android.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
8 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
10 #include "content/browser/mojo/service_registry_android.h" | 12 #include "content/browser/mojo/service_registry_android.h" |
11 #include "content/common/mojo/service_registry_impl.h" | 13 #include "content/common/mojo/service_registry_impl.h" |
12 #include "jni/ShellMojoTestUtils_jni.h" | 14 #include "jni/ShellMojoTestUtils_jni.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 struct TestEnvironment { | 18 struct TestEnvironment { |
(...skipping 24 matching lines...) Expand all Loading... |
41 TestEnvironment* test_environment = | 43 TestEnvironment* test_environment = |
42 reinterpret_cast<TestEnvironment*>(native_test_environment); | 44 reinterpret_cast<TestEnvironment*>(native_test_environment); |
43 | 45 |
44 content::ServiceRegistryImpl* registry_a = new ServiceRegistryImpl(); | 46 content::ServiceRegistryImpl* registry_a = new ServiceRegistryImpl(); |
45 test_environment->registries.push_back(registry_a); | 47 test_environment->registries.push_back(registry_a); |
46 content::ServiceRegistryImpl* registry_b = new ServiceRegistryImpl(); | 48 content::ServiceRegistryImpl* registry_b = new ServiceRegistryImpl(); |
47 test_environment->registries.push_back(registry_b); | 49 test_environment->registries.push_back(registry_b); |
48 | 50 |
49 mojo::ServiceProviderPtr exposed_services_a; | 51 mojo::ServiceProviderPtr exposed_services_a; |
50 registry_a->Bind(GetProxy(&exposed_services_a)); | 52 registry_a->Bind(GetProxy(&exposed_services_a)); |
51 registry_b->BindRemoteServiceProvider(exposed_services_a.Pass()); | 53 registry_b->BindRemoteServiceProvider(std::move(exposed_services_a)); |
52 | 54 |
53 mojo::ServiceProviderPtr exposed_services_b; | 55 mojo::ServiceProviderPtr exposed_services_b; |
54 registry_b->Bind(GetProxy(&exposed_services_b)); | 56 registry_b->Bind(GetProxy(&exposed_services_b)); |
55 registry_a->BindRemoteServiceProvider(exposed_services_b.Pass()); | 57 registry_a->BindRemoteServiceProvider(std::move(exposed_services_b)); |
56 | 58 |
57 content::ServiceRegistryAndroid* wrapper_a = | 59 content::ServiceRegistryAndroid* wrapper_a = |
58 new ServiceRegistryAndroid(registry_a); | 60 new ServiceRegistryAndroid(registry_a); |
59 test_environment->wrappers.push_back(wrapper_a); | 61 test_environment->wrappers.push_back(wrapper_a); |
60 content::ServiceRegistryAndroid* wrapper_b = | 62 content::ServiceRegistryAndroid* wrapper_b = |
61 new ServiceRegistryAndroid(registry_b); | 63 new ServiceRegistryAndroid(registry_b); |
62 test_environment->wrappers.push_back(wrapper_b); | 64 test_environment->wrappers.push_back(wrapper_b); |
63 | 65 |
64 return Java_ShellMojoTestUtils_makePair(env, wrapper_a->GetObj().obj(), | 66 return Java_ShellMojoTestUtils_makePair(env, wrapper_a->GetObj().obj(), |
65 wrapper_b->GetObj().obj()); | 67 wrapper_b->GetObj().obj()); |
66 } | 68 } |
67 | 69 |
68 static void RunLoop(JNIEnv* env, | 70 static void RunLoop(JNIEnv* env, |
69 const JavaParamRef<jclass>& jcaller, | 71 const JavaParamRef<jclass>& jcaller, |
70 jlong timeout_ms) { | 72 jlong timeout_ms) { |
71 base::MessageLoop::current()->PostDelayedTask( | 73 base::MessageLoop::current()->PostDelayedTask( |
72 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 74 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
73 base::TimeDelta::FromMilliseconds(timeout_ms)); | 75 base::TimeDelta::FromMilliseconds(timeout_ms)); |
74 base::RunLoop run_loop; | 76 base::RunLoop run_loop; |
75 run_loop.Run(); | 77 run_loop.Run(); |
76 } | 78 } |
77 | 79 |
78 bool RegisterShellMojoTestUtils(JNIEnv* env) { | 80 bool RegisterShellMojoTestUtils(JNIEnv* env) { |
79 return RegisterNativesImpl(env); | 81 return RegisterNativesImpl(env); |
80 } | 82 } |
81 | 83 |
82 } // namespace content | 84 } // namespace content |
OLD | NEW |