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

Side by Side Diff: blimp/client/core/session/assignment_source.h

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « blimp/client/core/session/BUILD.gn ('k') | blimp/client/core/session/assignment_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_SESSION_ASSIGNMENT_SOURCE_H_
6 #define BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "blimp/client/public/session/assignment.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15 #include "url/gurl.h"
16
17 namespace base {
18 class SingleThreadTaskRunner;
19 class Value;
20 }
21
22 namespace net {
23 class URLFetcher;
24 class URLRequestContextGetter;
25 }
26
27 namespace blimp {
28 namespace client {
29
30 // AssignmentSource provides functionality to find out how a client should
31 // connect to an engine.
32 class AssignmentSource : public net::URLFetcherDelegate {
33 public:
34 typedef base::Callback<void(AssignmentRequestResult, const Assignment&)>
35 AssignmentCallback;
36
37 // |assigner_endpoint|: The URL of the Assigner service to query.
38 // |network_task_runner|: The task runner to use for querying the Assigner API
39 // over the network.
40 // |file_task_runner|: The task runner to use for reading cert files from disk
41 // (specified on the command line.)
42 AssignmentSource(
43 const GURL& assigner_endpoint,
44 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner,
45 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner);
46
47 ~AssignmentSource() override;
48
49 // Retrieves a valid assignment for the client and posts the result to the
50 // given callback. |client_auth_token| is the OAuth2 access token to send to
51 // the assigner when requesting an assignment. If this is called before a
52 // previous call has completed, the old callback will be called with
53 // RESULT_SERVER_INTERRUPTED and no Assignment.
54 void GetAssignment(const std::string& client_auth_token,
55 const AssignmentCallback& callback);
56
57 private:
58 void OnGetAssignmentFromCommandLineDone(const std::string& client_auth_token,
59 Assignment parsed_assignment);
60 void QueryAssigner(const std::string& client_auth_token);
61 void ParseAssignerResponse();
62 void OnJsonParsed(std::unique_ptr<base::Value> json);
63 void OnJsonParseError(const std::string& error);
64
65 // net::URLFetcherDelegate implementation:
66 void OnURLFetchComplete(const net::URLFetcher* source) override;
67
68 // GetAssignment() callback, invoked after URLFetcher completion.
69 AssignmentCallback callback_;
70
71 const GURL assigner_endpoint_;
72 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
73 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
74 std::unique_ptr<net::URLFetcher> url_fetcher_;
75
76 base::WeakPtrFactory<AssignmentSource> weak_factory_;
77
78 DISALLOW_COPY_AND_ASSIGN(AssignmentSource);
79 };
80
81 } // namespace client
82 } // namespace blimp
83
84 #endif // BLIMP_CLIENT_CORE_SESSION_ASSIGNMENT_SOURCE_H_
OLDNEW
« no previous file with comments | « blimp/client/core/session/BUILD.gn ('k') | blimp/client/core/session/assignment_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698