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

Unified Diff: content/common/service_manager/service_manager_connection_impl_unittest.cc

Issue 2729733003: Change ServiceManagerConnectionImpl to run service request handlers on the IO thread. (Closed)
Patch Set: Fix startup race. 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/service_manager/service_manager_connection_impl_unittest.cc
diff --git a/content/common/service_manager/service_manager_connection_impl_unittest.cc b/content/common/service_manager/service_manager_connection_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ecca7a6b7e420c16f2400becca5c314494f98599
--- /dev/null
+++ b/content/common/service_manager/service_manager_connection_impl_unittest.cc
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/service_manager/service_manager_connection_impl.h"
+
+#include "base/message_loop/message_loop.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/threading/thread.h"
+#include "services/service_manager/public/cpp/identity.h"
+#include "services/service_manager/public/cpp/service.h"
+#include "services/service_manager/public/interfaces/constants.mojom.h"
+#include "services/service_manager/public/interfaces/service_factory.mojom.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+namespace {
+
+constexpr char kTestServiceName[] = "test service";
+
+std::unique_ptr<service_manager::Service> LaunchService(
+ base::WaitableEvent* event) {
+ event->Signal();
+ return base::MakeUnique<service_manager::Service>();
+}
+
+} // namespace
+
+TEST(ServiceManagerConnectionImplTest, ServiceLaunchThreading) {
+ base::MessageLoop message_loop;
+ base::Thread io_thread("ServiceManagerConnectionImplTest IO Thread");
+ io_thread.Start();
+ service_manager::mojom::ServicePtr service;
+ ServiceManagerConnectionImpl connection_impl(mojo::MakeRequest(&service),
+ io_thread.task_runner());
+ ServiceManagerConnection& connection = connection_impl;
+ ServiceInfo info;
+ base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ info.factory = base::Bind(&LaunchService, &event);
+ info.task_runner = io_thread.task_runner();
+ connection.AddEmbeddedService(kTestServiceName, info);
+ connection.Start();
+ service_manager::ServiceInfo source_info(
+ {service_manager::mojom::kServiceName,
+ service_manager::mojom::kRootUserID},
+ service_manager::InterfaceProviderSpecMap{});
+ service_manager::mojom::ServiceFactoryPtr factory;
+ service->OnBindInterface(source_info,
+ service_manager::mojom::ServiceFactory::Name_,
+ mojo::MakeRequest(&factory).PassMessagePipe(),
+ base::Bind(&base::DoNothing));
+ service_manager::mojom::ServicePtr created_service;
+ factory->CreateService(mojo::MakeRequest(&created_service), kTestServiceName);
+ event.Wait();
+}
+
+} // namespace content
« 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