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