OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BLIMP_TEST_FAKE_ENGINE_FAKE_ENGINE_H_ | |
6 #define BLIMP_TEST_FAKE_ENGINE_FAKE_ENGINE_H_ | |
7 | |
8 #include "blimp/test/fake_engine/proto/engine.grpc.pb.h" | |
9 #include "blimp/test/fake_engine/proto/lifetime.grpc.pb.h" | |
10 #include "blimp/test/fake_engine/proto/logging.grpc.pb.h" | |
11 #include "third_party/grpc/include/grpc++/grpc++.h" | |
12 | |
13 namespace blimp { | |
14 | |
15 // FD to serve the Engine API on | |
16 const int kEngineListenFd = 3; | |
17 | |
18 // FD on which the Rendering Server API is served | |
19 const int kRenderingServerListenFd = 4; | |
20 | |
21 class EngineServiceImpl final : public Engine::Service { | |
22 public: | |
23 grpc::Status CheckHealth( | |
24 grpc::ServerContext* context, | |
25 const CheckHealthRequest* request, | |
26 CheckHealthResponse* response) override; | |
27 | |
28 grpc::Status ShutDown(grpc::ServerContext* context, | |
29 const ShutDownRequest* request, | |
30 ShutDownResponse* response) override; | |
31 }; | |
32 | |
33 class FakeEngine { | |
34 public: | |
35 FakeEngine(); | |
36 ~FakeEngine(); | |
37 | |
38 // Starts the FakeEngine. | |
39 void Start(); | |
40 | |
41 // Waits until the FakeEngine gRPC service is shut down. As gRPC++ doesn't | |
42 // support clean shut down yet, this actually never returns. | |
43 void WaitForShutdown(); | |
44 | |
45 // The following methods return the stubs for communication with rendering | |
46 // server. They must not be called before Start() method. | |
47 Lifetime::Stub* GetLifetimeStub(); | |
48 Logging::Stub* GetLoggingStub(); | |
49 | |
50 private: | |
51 std::unique_ptr<grpc::Server> grpc_server_; | |
52 EngineServiceImpl engine_service_; | |
53 | |
54 std::shared_ptr<grpc::Channel> rendering_server_channel_; | |
55 std::unique_ptr<Lifetime::Stub> lifetime_stub_; | |
56 std::unique_ptr<Logging::Stub> logging_stub_; | |
57 }; | |
58 | |
59 } // namespace blimp | |
60 | |
61 #endif // BLIMP_TEST_FAKE_ENGINE_FAKE_ENGINE_H_ | |
OLD | NEW |