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

Side by Side Diff: services/video_capture/test/service_test.cc

Issue 2824883005: [Mojo Video Capture] Stop service when last client disconnects. (Closed)
Patch Set: Created 3 years, 8 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/video_capture/test/service_test.h" 5 #include "services/video_capture/test/service_test.h"
6 6
7 #include "services/service_manager/public/interfaces/constants.mojom.h"
8 #include "services/service_manager/public/interfaces/service_manager.mojom.h"
9 #include "services/video_capture/public/interfaces/constants.mojom.h"
10
7 namespace video_capture { 11 namespace video_capture {
8 12
13 ServiceManagerListenerImpl::ServiceManagerListenerImpl(
14 service_manager::mojom::ServiceManagerListenerRequest request,
15 base::RunLoop* loop)
16 : binding_(this, std::move(request)), loop_(loop) {}
17
18 ServiceManagerListenerImpl::~ServiceManagerListenerImpl() = default;
19
9 ServiceTest::ServiceTest() 20 ServiceTest::ServiceTest()
10 : service_manager::test::ServiceTest("video_capture_unittests") {} 21 : service_manager::test::ServiceTest("video_capture_unittests") {}
11 22
12 ServiceTest::~ServiceTest() = default; 23 ServiceTest::~ServiceTest() = default;
13 24
14 void ServiceTest::SetUp() { 25 void ServiceTest::SetUp() {
15 service_manager::test::ServiceTest::SetUp(); 26 service_manager::test::ServiceTest::SetUp();
16 connector()->BindInterface("video_capture", &service_); 27
28 service_manager::mojom::ServiceManagerPtr service_manager;
29 connector()->BindInterface(service_manager::mojom::kServiceName,
30 &service_manager);
31 service_manager::mojom::ServiceManagerListenerPtr listener;
32 base::RunLoop loop;
33 service_state_observer_ = base::MakeUnique<ServiceManagerListenerImpl>(
34 mojo::MakeRequest(&listener), &loop);
35 service_manager->AddListener(std::move(listener));
36 loop.Run();
37
38 connector()->BindInterface(mojom::kServiceName, &service_);
39 service_->SetShutdownDelayInSeconds(0.0f);
17 service_->ConnectToFakeDeviceFactory(mojo::MakeRequest(&factory_)); 40 service_->ConnectToFakeDeviceFactory(mojo::MakeRequest(&factory_));
18 } 41 }
19 42
20 } // namespace video_capture 43 } // namespace video_capture
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698