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_SESSION_ASSIGNMENT_SOURCE_H_ | 5 #ifndef BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ |
6 #define BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ | 6 #define BLIMP_CLIENT_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 "blimp/client/blimp_client_export.h" | |
13 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
14 #include "net/url_request/url_fetcher_delegate.h" | 13 #include "net/url_request/url_fetcher_delegate.h" |
15 #include "url/gurl.h" | 14 #include "url/gurl.h" |
16 | 15 |
17 namespace base { | 16 namespace base { |
18 class FilePath; | 17 class FilePath; |
19 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
20 class Value; | 19 class Value; |
21 } | 20 } |
22 | 21 |
23 namespace net { | 22 namespace net { |
24 class URLFetcher; | 23 class URLFetcher; |
25 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
26 class X509Certificate; | 25 class X509Certificate; |
27 } | 26 } |
28 | 27 |
29 namespace blimp { | 28 namespace blimp { |
30 namespace client { | 29 namespace client { |
31 | 30 |
32 // TODO(kmarshall): Take values from configuration data. | 31 // TODO(kmarshall): Take values from configuration data. |
33 const char kDummyClientToken[] = "MyVoiceIsMyPassport"; | 32 const char kDummyClientToken[] = "MyVoiceIsMyPassport"; |
34 | 33 |
35 // An Assignment contains the configuration data needed for a client | 34 // An Assignment contains the configuration data needed for a client |
36 // to connect to the engine. | 35 // to connect to the engine. |
37 struct BLIMP_CLIENT_EXPORT Assignment { | 36 struct Assignment { |
38 enum TransportProtocol { | 37 enum TransportProtocol { |
39 UNKNOWN = 0, | 38 UNKNOWN = 0, |
40 SSL = 1, | 39 SSL = 1, |
41 TCP = 2, | 40 TCP = 2, |
42 }; | 41 }; |
43 | 42 |
44 Assignment(); | 43 Assignment(); |
45 Assignment(const Assignment& other); | 44 Assignment(const Assignment& other); |
46 ~Assignment(); | 45 ~Assignment(); |
47 | 46 |
48 // Returns true if the net::IPEndPoint has an unspecified IP, port, or | 47 // Returns true if the net::IPEndPoint has an unspecified IP, port, or |
49 // transport protocol. | 48 // transport protocol. |
50 bool IsValid() const; | 49 bool IsValid() const; |
51 | 50 |
52 // Specifies the transport to use to connect to the engine. | 51 // Specifies the transport to use to connect to the engine. |
53 TransportProtocol transport_protocol; | 52 TransportProtocol transport_protocol; |
54 | 53 |
55 // Specifies the IP address and port on which to reach the engine. | 54 // Specifies the IP address and port on which to reach the engine. |
56 net::IPEndPoint engine_endpoint; | 55 net::IPEndPoint engine_endpoint; |
57 | 56 |
58 // Used to authenticate to the specified engine. | 57 // Used to authenticate to the specified engine. |
59 std::string client_token; | 58 std::string client_token; |
60 | 59 |
61 // Specifies the X.509 certificate that the engine must report. | 60 // Specifies the X.509 certificate that the engine must report. |
62 scoped_refptr<net::X509Certificate> cert; | 61 scoped_refptr<net::X509Certificate> cert; |
63 }; | 62 }; |
64 | 63 |
65 // AssignmentSource provides functionality to find out how a client should | 64 // AssignmentSource provides functionality to find out how a client should |
66 // connect to an engine. | 65 // connect to an engine. |
67 class BLIMP_CLIENT_EXPORT AssignmentSource : public net::URLFetcherDelegate { | 66 class AssignmentSource : public net::URLFetcherDelegate { |
68 public: | 67 public: |
69 // A Java counterpart will be generated for this enum. | 68 // A Java counterpart will be generated for this enum. |
70 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.blimp.assignment | 69 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.blimp.assignment |
71 enum Result { | 70 enum Result { |
72 RESULT_UNKNOWN = 0, | 71 RESULT_UNKNOWN = 0, |
73 RESULT_OK = 1, | 72 RESULT_OK = 1, |
74 RESULT_BAD_REQUEST = 2, | 73 RESULT_BAD_REQUEST = 2, |
75 RESULT_BAD_RESPONSE = 3, | 74 RESULT_BAD_RESPONSE = 3, |
76 RESULT_INVALID_PROTOCOL_VERSION = 4, | 75 RESULT_INVALID_PROTOCOL_VERSION = 4, |
77 RESULT_EXPIRED_ACCESS_TOKEN = 5, | 76 RESULT_EXPIRED_ACCESS_TOKEN = 5, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 126 |
128 base::WeakPtrFactory<AssignmentSource> weak_factory_; | 127 base::WeakPtrFactory<AssignmentSource> weak_factory_; |
129 | 128 |
130 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); | 129 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); |
131 }; | 130 }; |
132 | 131 |
133 } // namespace client | 132 } // namespace client |
134 } // namespace blimp | 133 } // namespace blimp |
135 | 134 |
136 #endif // BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ | 135 #endif // BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ |
OLD | NEW |