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

Unified Diff: blimp/client/core/context/assignment_fetcher.h

Issue 2406403003: Clean up Assignment Create in BlimpClientContextImpl. (Closed)
Patch Set: Addresses dtrainor's #14 comments. Created 4 years, 2 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/core/context/BUILD.gn ('k') | blimp/client/core/context/assignment_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/client/core/context/assignment_fetcher.h
diff --git a/blimp/client/core/context/assignment_fetcher.h b/blimp/client/core/context/assignment_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..3818f9e9c985e7f3476f31caf6b055d52e4f62fd
--- /dev/null
+++ b/blimp/client/core/context/assignment_fetcher.h
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_CLIENT_CORE_CONTEXT_ASSIGNMENT_FETCHER_H_
+#define BLIMP_CLIENT_CORE_CONTEXT_ASSIGNMENT_FETCHER_H_
+
+#include <memory>
+#include <string>
+
+#include "blimp/client/core/session/assignment_source.h"
+#include "blimp/client/core/session/identity_source.h"
+
+namespace blimp {
+namespace client {
+
+class AssignmentFetcher {
+ public:
+ using AuthErrorCallback = base::Callback<void(const GoogleServiceAuthError&)>;
+ using AssignmentResultCallback =
+ base::Callback<void(AssignmentRequestResult, const Assignment&)>;
+
+ AssignmentFetcher(
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
+ std::unique_ptr<IdentityProvider> identity_provider,
+ GURL assigner_url,
+ const AssignmentResultCallback& assignment_received_callback,
+ const AuthErrorCallback& error_callback);
+
+ ~AssignmentFetcher();
+
+ void Fetch();
+
+ IdentitySource* GetIdentitySource();
+
+ private:
+ // Called when an OAuth2 token is received. Will then ask the
+ // AssignmentSource for an Assignment with this token.
+ void OnAuthTokenReceived(const std::string& client_auth_token);
+
+ // Provide OAuth2 token and propagate account sign in states change.
+ std::unique_ptr<IdentitySource> identity_source_;
+
+ AssignmentResultCallback assignment_received_callback_;
+
+ // Returns the URL to use for connections to the assigner. Used to construct
+ // the AssignmentSource.
+ GURL assigner_url_;
+
+ // The AssignmentSource is used when the user of AssignmentFetcher calls
+ // Fetch() to get a valid assignment and later connect to the engine.
+ std::unique_ptr<AssignmentSource> assignment_source_;
+
+ // The task runner to use for IO operations.
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
+
+ // The task runner to use for file operations.
+ scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(AssignmentFetcher);
+};
+
+} // namespace client
+} // namespace blimp
+
+#endif // BLIMP_CLIENT_CORE_CONTEXT_ASSIGNMENT_FETCHER_H_
« no previous file with comments | « blimp/client/core/context/BUILD.gn ('k') | blimp/client/core/context/assignment_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698