| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    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 |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "blimp/client/core/session/assignment_source.h" |    5 #include "blimp/client/core/session/assignment_source.h" | 
|    6  |    6  | 
|    7 #include <memory> |    7 #include <memory> | 
|    8 #include <utility> |    8 #include <utility> | 
|    9  |    9  | 
|   10 #include "base/bind.h" |   10 #include "base/bind.h" | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   44 // Assignment request JSON keys. |   44 // Assignment request JSON keys. | 
|   45 const char kProtocolVersionKey[] = "protocol_version"; |   45 const char kProtocolVersionKey[] = "protocol_version"; | 
|   46  |   46  | 
|   47 // Assignment response JSON keys. |   47 // Assignment response JSON keys. | 
|   48 const char kClientAuthTokenKey[] = "clientToken"; |   48 const char kClientAuthTokenKey[] = "clientToken"; | 
|   49 const char kHostKey[] = "host"; |   49 const char kHostKey[] = "host"; | 
|   50 const char kPortKey[] = "port"; |   50 const char kPortKey[] = "port"; | 
|   51 const char kCertificateKey[] = "certificate"; |   51 const char kCertificateKey[] = "certificate"; | 
|   52  |   52  | 
|   53 // Possible arguments for the "--engine-transport" command line parameter. |   53 // Possible arguments for the "--engine-transport" command line parameter. | 
 |   54 const char kGrpcTransportValue[] = "grpc"; | 
|   54 const char kSSLTransportValue[] = "ssl"; |   55 const char kSSLTransportValue[] = "ssl"; | 
|   55 const char kTCPTransportValue[] = "tcp"; |   56 const char kTCPTransportValue[] = "tcp"; | 
|   56  |   57  | 
|   57 class SimpleURLRequestContextGetter : public net::URLRequestContextGetter { |   58 class SimpleURLRequestContextGetter : public net::URLRequestContextGetter { | 
|   58  public: |   59  public: | 
|   59   SimpleURLRequestContextGetter( |   60   SimpleURLRequestContextGetter( | 
|   60       const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |   61       const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 
|   61       const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) |   62       const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) | 
|   62       : io_task_runner_(io_task_runner), file_task_runner_(file_task_runner) {} |   63       : io_task_runner_(io_task_runner), file_task_runner_(file_task_runner) {} | 
|   63  |   64  | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  131   } |  132   } | 
|  132   assignment.engine_endpoint = |  133   assignment.engine_endpoint = | 
|  133       net::IPEndPoint(ip_address, base::checked_cast<uint16_t>(port_parsed)); |  134       net::IPEndPoint(ip_address, base::checked_cast<uint16_t>(port_parsed)); | 
|  134  |  135  | 
|  135   std::string transport_str = |  136   std::string transport_str = | 
|  136       cmd_line->GetSwitchValueASCII(switches::kEngineTransport); |  137       cmd_line->GetSwitchValueASCII(switches::kEngineTransport); | 
|  137   if (transport_str == kSSLTransportValue) { |  138   if (transport_str == kSSLTransportValue) { | 
|  138     assignment.transport_protocol = Assignment::TransportProtocol::SSL; |  139     assignment.transport_protocol = Assignment::TransportProtocol::SSL; | 
|  139   } else if (transport_str == kTCPTransportValue) { |  140   } else if (transport_str == kTCPTransportValue) { | 
|  140     assignment.transport_protocol = Assignment::TransportProtocol::TCP; |  141     assignment.transport_protocol = Assignment::TransportProtocol::TCP; | 
 |  142   } else if (transport_str == kGrpcTransportValue) { | 
 |  143     assignment.transport_protocol = Assignment::TransportProtocol::GRPC; | 
|  141   } else { |  144   } else { | 
|  142     DLOG(FATAL) << "Invalid engine transport " << transport_str; |  145     DLOG(FATAL) << "Invalid engine transport " << transport_str; | 
|  143     return Assignment(); |  146     return Assignment(); | 
|  144   } |  147   } | 
|  145  |  148  | 
|  146   scoped_refptr<net::X509Certificate> cert; |  149   scoped_refptr<net::X509Certificate> cert; | 
|  147   if (assignment.transport_protocol == Assignment::TransportProtocol::SSL) { |  150   if (assignment.transport_protocol == Assignment::TransportProtocol::SSL) { | 
|  148     base::FilePath cert_path = |  151     base::FilePath cert_path = | 
|  149         cmd_line->GetSwitchValuePath(switches::kEngineCertPath); |  152         cmd_line->GetSwitchValuePath(switches::kEngineCertPath); | 
|  150     if (cert_path.empty()) { |  153     if (cert_path.empty()) { | 
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  371 } |  374 } | 
|  372  |  375  | 
|  373 void AssignmentSource::OnJsonParseError(const std::string& error) { |  376 void AssignmentSource::OnJsonParseError(const std::string& error) { | 
|  374   DLOG(ERROR) << "Error while parsing assigner JSON: " << error; |  377   DLOG(ERROR) << "Error while parsing assigner JSON: " << error; | 
|  375   base::ResetAndReturn(&callback_) |  378   base::ResetAndReturn(&callback_) | 
|  376       .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment()); |  379       .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment()); | 
|  377 } |  380 } | 
|  378  |  381  | 
|  379 }  // namespace client |  382 }  // namespace client | 
|  380 }  // namespace blimp |  383 }  // namespace blimp | 
| OLD | NEW |