Chromium Code Reviews| 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" | |
| 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" | |
| 17 #include "net/cert/x509_certificate.h" | |
| 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(); | |
|
Wez
2016/02/12 02:31:14
IIUC you only need these because the struct is no
Kevin M
2016/02/13 00:44:18
Correct
| |
| 31 | |
| 32 std::vector<net::IPAddress> ip_addresses; | |
| 33 int16_t tcp_port; | |
| 34 int16_t ssl_port; | |
|
Wez
2016/02/12 02:31:13
Can you inline initialize these?
These need to be
Kevin M
2016/02/13 00:44:18
vOn 2016/02/12 02:31:13, Wez wrote:
| |
| 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 { |
|
Wez
2016/02/12 02:31:13
It seems strange to be bundling the dev-mode file-
Kevin M
2016/02/13 00:44:18
I think the boundary between "dev mode" and "produ
| |
| 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 virtual ~AssignmentSource(); |
|
Wez
2016/02/12 02:31:13
Why is this dtor virtual?
Kevin M
2016/02/13 00:44:18
Done.
| |
| 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 // Reads the contents of |path| into a string. | |
| 58 // Sends the contents to |callback| on the IO thread. | |
|
Wez
2016/02/12 02:31:13
This comment looks to be incorrect?
As far as I c
Kevin M
2016/02/13 00:44:18
Done.
| |
| 59 void ReadFromDisk(base::FilePath path, | |
|
Wez
2016/02/12 02:31:13
|path| should be const& here
Kevin M
2016/02/13 00:44:18
Done.
| |
| 60 const base::Callback<void(const std::string&)>& callback); | |
| 61 | |
| 62 // Parses a certificate from PEM-encoded |cert_str| and attaches it to | |
| 63 // |assignment|. Returns the populated assignment object via |callback|. | |
| 64 void ParseCertForAssignment(Assignment assignment, | |
|
Wez
2016/02/12 02:31:14
nit: It's really strange to be passing Assignment
Kevin M
2016/02/13 00:44:18
Passing around Assignments as scoped_ptr now.
| |
| 65 const AssignmentCallback& callback, | |
| 66 const std::string& cert_str); | |
| 67 | |
| 46 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 68 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 47 | 69 |
| 70 // Thread for executing cert file reads. | |
| 71 // TODO(kmarshall): Use BlimpClientSession IO thread task runner. | |
| 72 // dtrainor@ will land a change that moves AssignmentSource into the | |
| 73 // BlimpClientSession, which manages its own IO thread. | |
| 74 base::Thread io_thread_; | |
| 75 | |
| 48 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); | 76 DISALLOW_COPY_AND_ASSIGN(AssignmentSource); |
| 49 }; | 77 }; |
| 50 | 78 |
| 51 } // namespace client | 79 } // namespace client |
| 52 } // namespace blimp | 80 } // namespace blimp |
| 53 | 81 |
| 54 #endif // BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ | 82 #endif // BLIMP_CLIENT_SESSION_ASSIGNMENT_SOURCE_H_ |
| OLD | NEW |