| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_CLIENT_CORE_CONTEXT_ASSIGNMENT_FETCHER_H_ | |
| 6 #define BLIMP_CLIENT_CORE_CONTEXT_ASSIGNMENT_FETCHER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/single_thread_task_runner.h" | |
| 13 #include "blimp/client/core/session/assignment_source.h" | |
| 14 #include "blimp/client/core/session/identity_source.h" | |
| 15 | |
| 16 namespace blimp { | |
| 17 namespace client { | |
| 18 | |
| 19 class AssignmentFetcher { | |
| 20 public: | |
| 21 using AuthErrorCallback = base::Callback<void(const GoogleServiceAuthError&)>; | |
| 22 using AssignmentResultCallback = | |
| 23 base::Callback<void(AssignmentRequestResult, const Assignment&)>; | |
| 24 | |
| 25 AssignmentFetcher( | |
| 26 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | |
| 27 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | |
| 28 std::unique_ptr<IdentityProvider> identity_provider, | |
| 29 GURL assigner_url, | |
| 30 const AssignmentResultCallback& assignment_received_callback, | |
| 31 const AuthErrorCallback& error_callback); | |
| 32 | |
| 33 ~AssignmentFetcher(); | |
| 34 | |
| 35 void Fetch(); | |
| 36 | |
| 37 IdentitySource* GetIdentitySource(); | |
| 38 | |
| 39 private: | |
| 40 // Called when an OAuth2 token is received. Will then ask the | |
| 41 // AssignmentSource for an Assignment with this token. | |
| 42 void OnAuthTokenReceived(const std::string& client_auth_token); | |
| 43 | |
| 44 // Provide OAuth2 token and propagate account sign in states change. | |
| 45 std::unique_ptr<IdentitySource> identity_source_; | |
| 46 | |
| 47 AssignmentResultCallback assignment_received_callback_; | |
| 48 | |
| 49 // Returns the URL to use for connections to the assigner. Used to construct | |
| 50 // the AssignmentSource. | |
| 51 GURL assigner_url_; | |
| 52 | |
| 53 // The AssignmentSource is used when the user of AssignmentFetcher calls | |
| 54 // Fetch() to get a valid assignment and later connect to the engine. | |
| 55 std::unique_ptr<AssignmentSource> assignment_source_; | |
| 56 | |
| 57 // The task runner to use for IO operations. | |
| 58 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; | |
| 59 | |
| 60 // The task runner to use for file operations. | |
| 61 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(AssignmentFetcher); | |
| 64 }; | |
| 65 | |
| 66 } // namespace client | |
| 67 } // namespace blimp | |
| 68 | |
| 69 #endif // BLIMP_CLIENT_CORE_CONTEXT_ASSIGNMENT_FETCHER_H_ | |
| OLD | NEW |