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

Unified Diff: blimp/net/grpc_engine_stream.h

Issue 2462183002: GRPC Stream implementation of HeliumStream
Patch Set: Created 4 years, 1 month 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
Index: blimp/net/grpc_engine_stream.h
diff --git a/blimp/net/grpc_engine_stream.h b/blimp/net/grpc_engine_stream.h
new file mode 100644
index 0000000000000000000000000000000000000000..1432ba06edf834d8d3c2c245295b103548eaf840
--- /dev/null
+++ b/blimp/net/grpc_engine_stream.h
@@ -0,0 +1,67 @@
+// Copyright 2016 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.
+
+#ifndef BLIMP_NET_GRPC_ENGINE_STREAM_H_
+#define BLIMP_NET_GRPC_ENGINE_STREAM_H_
+
+#include <memory>
+#include <string>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "blimp/net/blimp_net_export.h"
+#include "blimp/net/blimp_transport.h"
+#include "net/base/completion_callback.h"
+
+#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
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc/grpc.h>
+
+#include "base/callback.h"
+#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
+#include "base/synchronization/lock.h"
+#include "base/threading/thread.h"
+#include "blimp/common/logging.h"
+#include "blimp/common/proto/blimp_message.pb.h"
+#include "blimp/common/proto/helium_service.grpc.pb.h"
+#include "blimp/net/blimp_message_processor.h"
+#include "blimp/net/blimp_message_pump.h"
+#include "blimp/net/grpc_connection.h"
+#include "blimp/net/grpc_stream.h"
+
+namespace grpc {
+class Channel;
+class ServerCompletionQueue;
+} // namespace grpc
+
+namespace blimp {
+
+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.
+ public:
+ GrpcEngineStream(const std::string& ip_address,
+ const net::CompletionCallback& connection_callback);
+
+ void SendMessage(std::unique_ptr<HeliumWrapper> helium_message,
+ const HeliumMessageSentCb& sent_cb) override;
+
+ void ReceiveMessage(const HeliumMessageReceivedCb& received_cb) override;
+
+ ~GrpcEngineStream() override;
+
+ private:
+ std::string ip_address_;
+ HeliumService::AsyncService service_;
+ std::unique_ptr<grpc::ServerCompletionQueue> completion_queue_;
+ std::unique_ptr<grpc::Server> server_;
+ grpc::ServerContext context_;
+ std::unique_ptr<grpc::ServerAsyncReaderWriter<HeliumWrapper, HeliumWrapper>>
+ stream_;
+};
+
+} // namespace blimp
+
+#endif // BLIMP_NET_GRPC_ENGINE_STREAM_H_

Powered by Google App Engine
This is Rietveld 408576698