OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 "components/arc/test/fake_arc_bridge_instance.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/run_loop.h" | |
10 | |
11 namespace arc { | |
12 | |
13 FakeArcBridgeInstance::FakeArcBridgeInstance() : binding_(this) {} | |
14 FakeArcBridgeInstance::~FakeArcBridgeInstance() {} | |
15 | |
16 void FakeArcBridgeInstance::Init(mojom::ArcBridgeHostPtr host) { | |
17 host_ptr_ = std::move(host); | |
18 init_calls_++; | |
19 | |
20 // Wake WaitForInitCall(). | |
21 if (!quit_closure_.is_null()) | |
22 quit_closure_.Run(); | |
23 quit_closure_.Reset(); | |
24 } | |
25 | |
26 void FakeArcBridgeInstance::Unbind() { | |
27 host_ptr_.reset(); | |
28 if (binding_.is_bound()) | |
29 binding_.Close(); | |
30 } | |
31 | |
32 void FakeArcBridgeInstance::Bind( | |
33 mojo::InterfaceRequest<mojom::ArcBridgeInstance> interface_request) { | |
34 binding_.Bind(std::move(interface_request)); | |
35 } | |
36 | |
37 void FakeArcBridgeInstance::WaitForInitCall() { | |
38 base::RunLoop run_loop; | |
39 quit_closure_ = run_loop.QuitClosure(); | |
40 binding_.set_connection_error_handler(run_loop.QuitClosure()); | |
41 run_loop.Run(); | |
42 } | |
43 | |
44 void FakeArcBridgeInstance::Stop(ArcBridgeService::StopReason reason) { | |
45 if (!delegate_) | |
46 return; | |
47 delegate_->OnStopped(reason); | |
48 } | |
49 | |
50 } // namespace arc | |
OLD | NEW |