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 #include <vector> | |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_path.h" | |
Ryan Sleevi
2016/02/19 22:56:08
Unused
Kevin M
2016/02/22 22:53:31
Done.
| |
13 #include "base/threading/thread.h" | |
11 #include "blimp/client/blimp_client_export.h" | 14 #include "blimp/client/blimp_client_export.h" |
12 #include "net/base/ip_endpoint.h" | 15 #include "net/base/address_list.h" |
16 #include "net/base/hash_value.h" | |
Ryan Sleevi
2016/02/19 22:56:08
Unused
Kevin M
2016/02/22 22:53:31
Done.
| |
17 #include "net/cert/x509_certificate.h" | |
Ryan Sleevi
2016/02/19 22:56:08
Can forward declare
Kevin M
2016/02/22 22:53:31
Done.
| |
13 | 18 |
14 namespace base { | 19 namespace base { |
15 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
16 } | 21 } |
17 | 22 |
18 namespace blimp { | 23 namespace blimp { |
19 namespace client { | 24 namespace client { |
20 | 25 |
21 // An Assignment contains the configuration data needed for a client | 26 // An Assignment contains the configuration data needed for a client |
22 // to connect to the engine. | 27 // to connect to the engine. |
23 struct BLIMP_CLIENT_EXPORT Assignment { | 28 struct BLIMP_CLIENT_EXPORT Assignment { |
24 net::IPEndPoint ip_endpoint; | 29 Assignment(); |
30 ~Assignment(); | |
31 | |
32 std::vector<net::IPAddress> ip_addresses; | |
Ryan Sleevi
2016/02/19 22:56:08
STYLE: Document this. It took me a while of readin
Kevin M
2016/02/22 22:53:31
Agreed that multiple addresses contribute to ambig
| |
33 uint16_t tcp_port = 0; | |
34 uint16_t ssl_port = 0; | |
25 std::string client_token; | 35 std::string client_token; |
36 scoped_refptr<net::X509Certificate> cert; | |
26 }; | 37 }; |
27 | 38 |
28 // AssignmentSource provides functionality to find out how a client should | 39 // AssignmentSource provides functionality to find out how a client should |
29 // connect to an engine. | 40 // connect to an engine. |
30 class BLIMP_CLIENT_EXPORT AssignmentSource { | 41 class BLIMP_CLIENT_EXPORT AssignmentSource { |
31 public: | 42 public: |
32 typedef const base::Callback<void(const Assignment&)> AssignmentCallback; | 43 typedef const base::Callback<void(const Assignment&)> AssignmentCallback; |
33 | 44 |
34 // The |main_task_runner| should be the task runner for the UI thread because | 45 // The |main_task_runner| should be the task runner for the UI thread because |
35 // this will in some cases be used to trigger user interaction on the UI | 46 // this will in some cases be used to trigger user interaction on the UI |
36 // thread. | 47 // thread. |
37 AssignmentSource( | 48 AssignmentSource( |
38 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner); | 49 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner); |
39 virtual ~AssignmentSource(); | 50 ~AssignmentSource(); |
40 | 51 |
41 // Retrieves a valid assignment for the client and posts the result to the | 52 // Retrieves a valid assignment for the client and posts the result to the |
42 // given callback. | 53 // given callback. |
43 void GetAssignment(const AssignmentCallback& callback); | 54 void GetAssignment(const AssignmentCallback& callback); |
44 | 55 |
45 private: | 56 private: |
57 // Returns the TaskRunner for the |io_thread_|. | |
58 scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner(); | |
59 | |
46 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 60 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
47 | 61 |
62 // Thread for executing cert file reads. | |
63 // TODO(kmarshall): Use BlimpClientSession IO thread task runner. | |
64 // dtrainor@ will land a change that moves AssignmentSource into the | |
65 // BlimpClientSession, which manages its own IO thread. | |
66 scoped_ptr<base::Thread> io_thread_; | |
67 | |
48 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); | 68 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); |
49 }; | 69 }; |
50 | 70 |
51 } // namespace client | 71 } // namespace client |
52 } // namespace blimp | 72 } // namespace blimp |
53 | 73 |
54 #endif // BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ | 74 #endif // BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ |
OLD | NEW |