Index: blimp/client/session/assignment_source.h |
diff --git a/blimp/client/session/assignment_source.h b/blimp/client/session/assignment_source.h |
index 9891d4a2d49c0d91cf1ffecfc4f2966bb9fd75ac..6e6c2738123ce830ac9688dbb10cad335a9f8357 100644 |
--- a/blimp/client/session/assignment_source.h |
+++ b/blimp/client/session/assignment_source.h |
@@ -10,41 +10,81 @@ |
#include "base/callback.h" |
#include "blimp/client/blimp_client_export.h" |
#include "net/base/ip_endpoint.h" |
+#include "net/url_request/url_fetcher.h" |
+#include "net/url_request/url_fetcher_delegate.h" |
namespace base { |
class SingleThreadTaskRunner; |
} |
+namespace net { |
+class URLFetcher; |
+class URLRequestContextGetter; |
+} |
+ |
namespace blimp { |
namespace client { |
+// A Java counterpart will be generated for this enum. |
+// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.blimp |
Kevin M
2016/02/12 19:45:27
You can move this enum into AssignmentSource and j
David Trainor- moved to gerrit
2016/02/17 21:09:48
Done. The java classname is a little odd but I ad
|
+enum AssignmentSourceResult { |
+ ASSIGNMENT_SOURCE_RESULT_UNKNOWN = 0, |
+ ASSIGNMENT_SOURCE_RESULT_OKAY = 1, |
+ ASSIGNMENT_SOURCE_RESULT_BAD_REQUEST = 2, |
+ ASSIGNMENT_SOURCE_RESULT_BAD_RESPONSE = 3, |
+ ASSIGNMENT_SOURCE_RESULT_INVALID_PROTOCOL_VERSION = 4, |
+ ASSIGNMENT_SOURCE_RESULT_EXPIRED_ACCESS_TOKEN = 5, |
+ ASSIGNMENT_SOURCE_RESULT_USER_INVALID = 6, |
+ ASSIGNMENT_SOURCE_RESULT_OUT_OF_VMS = 7, |
+ ASSIGNMENT_SOURCE_RESULT_SERVER_ERROR = 8, |
+ ASSIGNMENT_SOURCE_RESULT_SERVER_INTERRUPTED = 9, |
+ ASSIGNMENT_SOURCE_RESULT_NETWORK_FAILURE = 10 |
+}; |
+ |
// An Assignment contains the configuration data needed for a client |
// to connect to the engine. |
struct BLIMP_CLIENT_EXPORT Assignment { |
net::IPEndPoint ip_endpoint; |
std::string client_token; |
+ std::string certificate; |
+ std::string certificate_fingerprint; |
}; |
// AssignmentSource provides functionality to find out how a client should |
// connect to an engine. |
-class BLIMP_CLIENT_EXPORT AssignmentSource { |
+class BLIMP_CLIENT_EXPORT AssignmentSource : public net::URLFetcherDelegate { |
public: |
- typedef const base::Callback<void(const Assignment&)> AssignmentCallback; |
+ typedef const base::Callback<void(AssignmentSourceResult, 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>& main_task_runner, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
virtual ~AssignmentSource(); |
// Retrieves a valid assignment for the client and posts the result to the |
- // given callback. |
- void GetAssignment(const AssignmentCallback& callback); |
+ // given callback. |token| is the authentication token to send to the |
+ // assigner when requesting an assignment. |
+ void GetAssignment(const std::string& token, |
+ const AssignmentCallback& callback); |
+ |
+ // net::URLFetcherDelegate implementation: |
+ void OnURLFetchComplete(const net::URLFetcher* source) override; |
private: |
+ void RespondWithAssignment(const Assignment& assignment); |
+ void RespondWithError(AssignmentSourceResult result); |
+ |
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
+ scoped_ptr<net::URLFetcher> url_fetcher_; |
+ |
+ scoped_ptr<AssignmentCallback> callback_; |
Kevin M
2016/02/12 19:45:27
No need to put it in a scoped ptr
David Trainor- moved to gerrit
2016/02/17 21:09:48
Done.
|
+ |
DISALLOW_COPY_AND_ASSIGN(AssignmentSource); |
}; |