Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: content/common/service_manager/service_manager_connection_impl_unittest.cc

Issue 2742523005: Revert Change ServiceManagerConnectionImpl to run service request handlers on the IO thread (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/common/service_manager/service_manager_connection_impl.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "base/synchronization/waitable_event.h"
9 #include "base/threading/thread.h"
10 #include "services/service_manager/public/cpp/identity.h"
11 #include "services/service_manager/public/cpp/service.h"
12 #include "services/service_manager/public/interfaces/constants.mojom.h"
13 #include "services/service_manager/public/interfaces/service_factory.mojom.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace content {
17 namespace {
18
19 constexpr char kTestServiceName[] = "test service";
20
21 std::unique_ptr<service_manager::Service> LaunchService(
22 base::WaitableEvent* event) {
23 event->Signal();
24 return base::MakeUnique<service_manager::Service>();
25 }
26
27 } // namespace
28
29 TEST(ServiceManagerConnectionImplTest, ServiceLaunchThreading) {
30 base::MessageLoop message_loop;
31 base::Thread io_thread("ServiceManagerConnectionImplTest IO Thread");
32 io_thread.Start();
33 service_manager::mojom::ServicePtr service;
34 ServiceManagerConnectionImpl connection_impl(mojo::MakeRequest(&service),
35 io_thread.task_runner());
36 ServiceManagerConnection& connection = connection_impl;
37 ServiceInfo info;
38 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
39 base::WaitableEvent::InitialState::NOT_SIGNALED);
40 info.factory = base::Bind(&LaunchService, &event);
41 info.task_runner = io_thread.task_runner();
42 connection.AddEmbeddedService(kTestServiceName, info);
43 connection.Start();
44 service_manager::ServiceInfo source_info(
45 {service_manager::mojom::kServiceName,
46 service_manager::mojom::kRootUserID},
47 service_manager::InterfaceProviderSpecMap{});
48 service_manager::mojom::ServiceFactoryPtr factory;
49 service->OnBindInterface(source_info,
50 service_manager::mojom::ServiceFactory::Name_,
51 mojo::MakeRequest(&factory).PassMessagePipe(),
52 base::Bind(&base::DoNothing));
53 service_manager::mojom::ServicePtr created_service;
54 factory->CreateService(mojo::MakeRequest(&created_service), kTestServiceName);
55 event.Wait();
56 }
57
58 } // namespace content
OLDNEW
« no previous file with comments | « content/common/service_manager/service_manager_connection_impl.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698