| 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 #ifndef BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_ | 5 #ifndef BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_ |
| 6 #define BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_ | 6 #define BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "net/base/ip_endpoint.h" | 12 #include "blimp/client/public/session/assignment.h" |
| 13 #include "net/url_request/url_fetcher_delegate.h" | 13 #include "net/url_request/url_fetcher_delegate.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class FilePath; | 17 class FilePath; |
| 18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 19 class Value; | 19 class Value; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 class URLFetcher; | 23 class URLFetcher; |
| 24 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
| 25 class X509Certificate; | |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace blimp { | 27 namespace blimp { |
| 29 namespace client { | 28 namespace client { |
| 30 | 29 |
| 31 // An Assignment contains the configuration data needed for a client | |
| 32 // to connect to the engine. | |
| 33 struct Assignment { | |
| 34 enum TransportProtocol { | |
| 35 UNKNOWN = 0, | |
| 36 SSL = 1, | |
| 37 TCP = 2, | |
| 38 }; | |
| 39 | |
| 40 Assignment(); | |
| 41 Assignment(const Assignment& other); | |
| 42 ~Assignment(); | |
| 43 | |
| 44 // Returns true if the net::IPEndPoint has an unspecified IP, port, or | |
| 45 // transport protocol. | |
| 46 bool IsValid() const; | |
| 47 | |
| 48 // Specifies the transport to use to connect to the engine. | |
| 49 TransportProtocol transport_protocol; | |
| 50 | |
| 51 // Specifies the IP address and port on which to reach the engine. | |
| 52 net::IPEndPoint engine_endpoint; | |
| 53 | |
| 54 // Used to authenticate to the specified engine. | |
| 55 std::string client_token; | |
| 56 | |
| 57 // Specifies the X.509 certificate that the engine must report. | |
| 58 scoped_refptr<net::X509Certificate> cert; | |
| 59 }; | |
| 60 | |
| 61 // AssignmentSource provides functionality to find out how a client should | 30 // AssignmentSource provides functionality to find out how a client should |
| 62 // connect to an engine. | 31 // connect to an engine. |
| 63 class AssignmentSource : public net::URLFetcherDelegate { | 32 class AssignmentSource : public net::URLFetcherDelegate { |
| 64 public: | 33 public: |
| 65 // A Java counterpart will be generated for this enum. | 34 typedef base::Callback<void(AssignmentRequestResult, const Assignment&)> |
| 66 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.blimp.core.session.assignment | |
| 67 enum Result { | |
| 68 RESULT_UNKNOWN = 0, | |
| 69 RESULT_OK = 1, | |
| 70 RESULT_BAD_REQUEST = 2, | |
| 71 RESULT_BAD_RESPONSE = 3, | |
| 72 RESULT_INVALID_PROTOCOL_VERSION = 4, | |
| 73 RESULT_EXPIRED_ACCESS_TOKEN = 5, | |
| 74 RESULT_USER_INVALID = 6, | |
| 75 RESULT_OUT_OF_VMS = 7, | |
| 76 RESULT_SERVER_ERROR = 8, | |
| 77 RESULT_SERVER_INTERRUPTED = 9, | |
| 78 RESULT_NETWORK_FAILURE = 10, | |
| 79 RESULT_INVALID_CERT = 11, | |
| 80 }; | |
| 81 | |
| 82 typedef base::Callback<void(AssignmentSource::Result, const Assignment&)> | |
| 83 AssignmentCallback; | 35 AssignmentCallback; |
| 84 | 36 |
| 85 // |assigner_endpoint|: The URL of the Assigner service to query. | 37 // |assigner_endpoint|: The URL of the Assigner service to query. |
| 86 // |network_task_runner|: The task runner to use for querying the Assigner API | 38 // |network_task_runner|: The task runner to use for querying the Assigner API |
| 87 // over the network. | 39 // over the network. |
| 88 // |file_task_runner|: The task runner to use for reading cert files from disk | 40 // |file_task_runner|: The task runner to use for reading cert files from disk |
| 89 // (specified on the command line.) | 41 // (specified on the command line.) |
| 90 AssignmentSource( | 42 AssignmentSource( |
| 91 const GURL& assigner_endpoint, | 43 const GURL& assigner_endpoint, |
| 92 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner, | 44 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 123 | 75 |
| 124 base::WeakPtrFactory<AssignmentSource> weak_factory_; | 76 base::WeakPtrFactory<AssignmentSource> weak_factory_; |
| 125 | 77 |
| 126 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); | 78 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); |
| 127 }; | 79 }; |
| 128 | 80 |
| 129 } // namespace client | 81 } // namespace client |
| 130 } // namespace blimp | 82 } // namespace blimp |
| 131 | 83 |
| 132 #endif // BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_ | 84 #endif // BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_ |
| OLD | NEW |