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

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

Issue 1687393002: Add assigner support to Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix evil build break? 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
« no previous file with comments | « blimp/client/app/linux/blimp_main.cc ('k') | blimp/client/session/assignment_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..dabe72cbaf7b4f1583db648a293294d043b232d9 100644
--- a/blimp/client/session/assignment_source.h
+++ b/blimp/client/session/assignment_source.h
@@ -10,41 +10,105 @@
#include "base/callback.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 SingleThreadTaskRunner;
}
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+}
+
namespace blimp {
namespace client {
+// TODO(kmarshall): Take values from configuration data.
+const char kDummyClientToken[] = "MyVoiceIsMyPassport";
+
+// Potential assigner URLs.
+const char kDefaultAssignerURL[] =
+ "https://blimp-pa.googleapis.com/v1/assignment";
+
// An Assignment contains the configuration data needed for a client
// to connect to the engine.
struct BLIMP_CLIENT_EXPORT Assignment {
+ enum TransportProtocol {
+ UNKNOWN = 0,
+ SSL = 1,
+ TCP = 2,
+ QUIC = 3,
+ };
+
+ Assignment();
+ ~Assignment();
+
+ TransportProtocol transport_protocol;
net::IPEndPoint ip_endpoint;
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;
};
// 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;
+ // A Java counterpart will be generated for this enum.
+ // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.blimp.assignment
+ enum Result {
+ RESULT_UNKNOWN = 0,
+ RESULT_OK = 1,
+ RESULT_BAD_REQUEST = 2,
+ RESULT_BAD_RESPONSE = 3,
+ RESULT_INVALID_PROTOCOL_VERSION = 4,
+ RESULT_EXPIRED_ACCESS_TOKEN = 5,
+ RESULT_USER_INVALID = 6,
+ RESULT_OUT_OF_VMS = 7,
+ RESULT_SERVER_ERROR = 8,
+ RESULT_SERVER_INTERRUPTED = 9,
+ RESULT_NETWORK_FAILURE = 10
+ };
+
+ 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);
- virtual ~AssignmentSource();
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
+ ~AssignmentSource() override;
// Retrieves a valid assignment for the client and posts the result to the
- // given callback.
- void GetAssignment(const AssignmentCallback& callback);
+ // given callback. |client_auth_token| is the OAuth2 access token to send to
+ // the assigner when requesting an assignment. If this is called before a
+ // previous call has completed, the old callback will be called with
+ // RESULT_SERVER_INTERRUPTED and no Assignment.
+ void GetAssignment(const std::string& client_auth_token,
+ const AssignmentCallback& callback);
+
+ // 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_;
+
DISALLOW_COPY_AND_ASSIGN(AssignmentSource);
};
« no previous file with comments | « blimp/client/app/linux/blimp_main.cc ('k') | blimp/client/session/assignment_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698