| 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..6e1b433be8e4072037ee0431dc49c05334e99b81 100644
|
| --- a/blimp/client/session/assignment_source.h
|
| +++ b/blimp/client/session/assignment_source.h
|
| @@ -8,17 +8,21 @@
|
| #include <string>
|
|
|
| #include "base/callback.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "blimp/client/blimp_client_export.h"
|
| #include "net/base/ip_endpoint.h"
|
| #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 +48,22 @@ 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;
|
| };
|
|
|
| // AssignmentSource provides functionality to find out how a client should
|
| @@ -72,18 +83,15 @@ 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);
|
| + explicit AssignmentSource(
|
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
|
| ~AssignmentSource() override;
|
|
|
| // Retrieves a valid assignment for the client and posts the result to the
|
| @@ -94,21 +102,27 @@ class BLIMP_CLIENT_EXPORT AssignmentSource : public net::URLFetcherDelegate {
|
| void GetAssignment(const std::string& client_auth_token,
|
| const AssignmentCallback& callback);
|
|
|
| + // Called when GetCustomAssignment() has completed.
|
| + // Uses |custom_assignment| if provided; queries the Assigner for one
|
| + // otherwise.
|
| + void OnGetCustomAssignmentDone(const std::string& client_auth_token,
|
| + Assignment custom_assignment);
|
| +
|
| // net::URLFetcherDelegate implementation:
|
| void OnURLFetchComplete(const net::URLFetcher* source) override;
|
|
|
| private:
|
| void ParseAssignerResponse();
|
|
|
| - scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
|
| -
|
| - scoped_refptr<net::URLRequestContextGetter> url_request_context_;
|
| - scoped_ptr<net::URLFetcher> url_fetcher_;
|
| -
|
| // This callback is set during a call to GetAssignment() and is cleared after
|
| // the request has completed (whether it be a success or failure).
|
| AssignmentCallback callback_;
|
|
|
| + scoped_refptr<net::URLRequestContextGetter> url_request_context_;
|
| + scoped_refptr<base::TaskRunner> io_task_runner_;
|
| + scoped_ptr<net::URLFetcher> url_fetcher_;
|
| + base::WeakPtrFactory<AssignmentSource> weak_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AssignmentSource);
|
| };
|
|
|
|
|