Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3040)

Unified Diff: blimp/client/session/assignment_source.h

Issue 1696563002: Blimp: add support for SSL connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address remaining rsleevi feedback items Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/client/session/assignment_source.h
diff --git a/blimp/client/session/assignment_source.h b/blimp/client/session/assignment_source.h
index dabe72cbaf7b4f1583db648a293294d043b232d9..136d05367efc0258c929c71ebebfd85dc34f0db7 100644
--- a/blimp/client/session/assignment_source.h
+++ b/blimp/client/session/assignment_source.h
@@ -13,12 +13,15 @@
#include "net/url_request/url_fetcher_delegate.h"
namespace base {
+class FilePath;
class SingleThreadTaskRunner;
+class TaskRunner;
}
namespace net {
class URLFetcher;
class URLRequestContextGetter;
+class X509Certificate;
}
namespace blimp {
@@ -44,15 +47,34 @@ struct BLIMP_CLIENT_EXPORT Assignment {
Assignment();
~Assignment();
+ // Returns true if the net::IPEndPoint has an unspecified IP, port, or
+ // transport protocol.
+ bool is_null() const;
+
+ // The transport protocol used to contact the engine.
TransportProtocol transport_protocol;
+
+ // The IP address of the engine.
net::IPEndPoint ip_endpoint;
+
+ // The token used to authenticate the client to the engine.
std::string client_token;
- std::string certificate;
- std::string certificate_fingerprint;
- // Returns true if the net::IPEndPoint has an unspecified IP, port, or
- // transport protocol.
- bool is_null() const;
+ // The expected certificate of the engine. The peer certificate must match
+ // |cert| exactly, otherwise the connection will be dropped.
+ scoped_refptr<net::X509Certificate> cert;
+};
+
+class FileReader {
Ryan Sleevi 2016/02/23 00:49:45 What's the envisioned usage here for this? Judging
Kevin M 2016/02/23 01:58:25 This provides us a mockable hook for file access,
+ public:
+ FileReader();
+ virtual ~FileReader();
+
+ virtual bool ReadFileToString(const base::FilePath& path,
+ std::string* output);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FileReader);
};
// AssignmentSource provides functionality to find out how a client should
@@ -72,17 +94,14 @@ class BLIMP_CLIENT_EXPORT AssignmentSource : public net::URLFetcherDelegate {
RESULT_OUT_OF_VMS = 7,
RESULT_SERVER_ERROR = 8,
RESULT_SERVER_INTERRUPTED = 9,
- RESULT_NETWORK_FAILURE = 10
+ RESULT_NETWORK_FAILURE = 10,
+ RESULT_INVALID_CERT = 11,
};
typedef base::Callback<void(AssignmentSource::Result, const Assignment&)>
AssignmentCallback;
- // The |main_task_runner| should be the task runner for the UI thread because
- // this will in some cases be used to trigger user interaction on the UI
- // thread.
AssignmentSource(
- const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
~AssignmentSource() override;
@@ -94,16 +113,30 @@ class BLIMP_CLIENT_EXPORT AssignmentSource : public net::URLFetcherDelegate {
void GetAssignment(const std::string& client_auth_token,
const AssignmentCallback& callback);
+ // Populates an Assignment using command-line parameters, if provided.
+ // Returns a null Assignment if no parameters were set.
+ // Must be called on the IO thread.
+ scoped_ptr<Assignment> GetCustomAssignment();
+
+ // Called when GetCustomAssignment() has completed.
+ // Uses |custom_assignment| if provided; queries the Assigner for one
+ // otherwise.
+ void OnGetCustomAssignmentDone(const std::string& client_auth_token,
+ scoped_ptr<Assignment> custom_assignment);
+
+ void SetFileReaderForTest(scoped_ptr<FileReader> reader);
+
// net::URLFetcherDelegate implementation:
void OnURLFetchComplete(const net::URLFetcher* source) override;
private:
void ParseAssignerResponse();
- scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+ scoped_refptr<base::TaskRunner> io_task_runner_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_;
scoped_ptr<net::URLFetcher> url_fetcher_;
+ scoped_ptr<FileReader> file_reader_;
// This callback is set during a call to GetAssignment() and is cleared after
// the request has completed (whether it be a success or failure).

Powered by Google App Engine
This is Rietveld 408576698