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 #include "blimp/net/grpc_engine_transport.h" |
| 6 |
| 7 #include <grpc++/security/server_credentials.h> |
| 8 #include <grpc++/server.h> |
| 9 #include <grpc++/server_builder.h> |
| 10 #include <grpc++/server_context.h> |
| 11 #include <grpc/grpc.h> |
| 12 |
| 13 #include <queue> |
| 14 #include <string> |
| 15 #include <utility> |
| 16 |
| 17 #include "base/command_line.h" |
| 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/synchronization/lock.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "blimp/common/logging.h" |
| 22 #include "blimp/common/proto/blimp_message.pb.h" |
| 23 #include "blimp/common/proto/helium_service.grpc.pb.h" |
| 24 #include "blimp/net/blimp_message_processor.h" |
| 25 #include "blimp/net/blimp_message_pump.h" |
| 26 #include "blimp/net/grpc_connection.h" |
| 27 #include "blimp/net/grpc_engine_stream.h" |
| 28 #include "net/base/net_errors.h" |
| 29 |
| 30 namespace blimp { |
| 31 |
| 32 GrpcEngineTransport::GrpcEngineTransport( |
| 33 const AssignmentOptions& assignment_options) |
| 34 : BlimpEngineTransport(), assignment_options_(assignment_options) { |
| 35 DVLOG(1) << "gRPC Engine Initialized @ " |
| 36 << assignment_options.engine_endpoint.ToString(); |
| 37 } |
| 38 |
| 39 void GrpcEngineTransport::Connect(const net::CompletionCallback& callback) { |
| 40 std::unique_ptr<GrpcEngineStream> engine_stream = |
| 41 base::MakeUnique<GrpcEngineStream>(assignment_options_, callback); |
| 42 assignment_options_ = engine_stream->GetAssignmentOptions(); |
| 43 grpc_connection_ = base::MakeUnique<GrpcConnection>(std::move(engine_stream)); |
| 44 } |
| 45 |
| 46 std::unique_ptr<BlimpConnection> GrpcEngineTransport::MakeConnection() { |
| 47 DVLOG(1) << "Grpc Engine finished setup"; |
| 48 return std::move(grpc_connection_); |
| 49 } |
| 50 |
| 51 const char* GrpcEngineTransport::GetName() const { |
| 52 return "GRPC"; |
| 53 } |
| 54 |
| 55 void GrpcEngineTransport::GetAssignmentOptions( |
| 56 AssignmentOptions* assignment_options) const { |
| 57 *assignment_options = assignment_options_; |
| 58 } |
| 59 |
| 60 GrpcEngineTransport::~GrpcEngineTransport() {} |
| 61 |
| 62 } // namespace blimp |
OLD | NEW |