Chromium Code Reviews| 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_NET_GRPC_ENGINE_STREAM_H_ | |
| 6 #define BLIMP_NET_GRPC_ENGINE_STREAM_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "blimp/net/blimp_net_export.h" | |
| 14 #include "blimp/net/blimp_transport.h" | |
| 15 #include "net/base/completion_callback.h" | |
| 16 | |
| 17 #include <grpc++/security/server_credentials.h> | |
|
Kevin M
2016/10/31 21:33:25
General point (yeah I know I'm not supposed to rev
perumaal
2016/10/31 22:11:01
Oops this is intentional for now because I was try
| |
| 18 #include <grpc++/server.h> | |
| 19 #include <grpc++/server_builder.h> | |
| 20 #include <grpc++/server_context.h> | |
| 21 #include <grpc/grpc.h> | |
| 22 | |
| 23 #include "base/callback.h" | |
| 24 #include "base/command_line.h" | |
| 25 #include "base/memory/ptr_util.h" | |
| 26 #include "base/synchronization/lock.h" | |
| 27 #include "base/threading/thread.h" | |
| 28 #include "blimp/common/logging.h" | |
| 29 #include "blimp/common/proto/blimp_message.pb.h" | |
| 30 #include "blimp/common/proto/helium_service.grpc.pb.h" | |
| 31 #include "blimp/net/blimp_message_processor.h" | |
| 32 #include "blimp/net/blimp_message_pump.h" | |
| 33 #include "blimp/net/grpc_connection.h" | |
| 34 #include "blimp/net/grpc_stream.h" | |
| 35 | |
| 36 namespace grpc { | |
| 37 class Channel; | |
| 38 class ServerCompletionQueue; | |
| 39 } // namespace grpc | |
| 40 | |
| 41 namespace blimp { | |
| 42 | |
| 43 class GrpcEngineStream : public GrpcStream { | |
|
Kevin M
2016/10/31 21:33:25
As this runs on its own thread, should we use a Th
perumaal
2016/10/31 22:11:01
Yep, added a TODO.
| |
| 44 public: | |
| 45 GrpcEngineStream(const std::string& ip_address, | |
| 46 const net::CompletionCallback& connection_callback); | |
| 47 | |
| 48 void SendMessage(std::unique_ptr<HeliumWrapper> helium_message, | |
| 49 const HeliumMessageSentCb& sent_cb) override; | |
| 50 | |
| 51 void ReceiveMessage(const HeliumMessageReceivedCb& received_cb) override; | |
| 52 | |
| 53 ~GrpcEngineStream() override; | |
| 54 | |
| 55 private: | |
| 56 std::string ip_address_; | |
| 57 HeliumService::AsyncService service_; | |
| 58 std::unique_ptr<grpc::ServerCompletionQueue> completion_queue_; | |
| 59 std::unique_ptr<grpc::Server> server_; | |
| 60 grpc::ServerContext context_; | |
| 61 std::unique_ptr<grpc::ServerAsyncReaderWriter<HeliumWrapper, HeliumWrapper>> | |
| 62 stream_; | |
| 63 }; | |
| 64 | |
| 65 } // namespace blimp | |
| 66 | |
| 67 #endif // BLIMP_NET_GRPC_ENGINE_STREAM_H_ | |
| OLD | NEW |