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

Side by Side Diff: components/password_manager/core/browser/affiliation_fetcher.h

Issue 767163005: Add AffiliationFetcher to fetch authoritative affiliation information regarding facets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN build. Created 6 years 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
OLDNEW
(Empty)
1 // Copyright 2014 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_
7
8 #include <vector>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "components/password_manager/core/browser/affiliation_fetcher_delegate. h"
13 #include "components/password_manager/core/browser/affiliation_utils.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15
16 class GURL;
17
18 namespace net {
19 class URLRequestContextGetter;
20 } // namespace net
21
22 namespace password_manager {
23
24 // Fetches authoritative information regarding which facets are affiliated with
25 // each other, that is, which facets belong to the same logical application.
26 // See affiliation_utils.h for a definition of what this means.
27 //
28 // An instance is good for exactly one fetch, and may be used from any thread
29 // that runs a message loop (i.e. not a worker pool thread).
30 class AffiliationFetcher : net::URLFetcherDelegate {
31 public:
32 ~AffiliationFetcher() override;
33
34 // Constructs a fetcher to retrieve affiliations for each facet in |facet_ids|
35 // using the specified |request_context_getter|, and will provide the results
36 // to the |delegate| on the same thread that creates the instance.
37 static AffiliationFetcher* Create(
38 net::URLRequestContextGetter* request_context_getter,
39 const std::vector<FacetURI>& facet_uris,
40 AffiliationFetcherDelegate* delegate);
41
42 // Actually starts the request, and will call the delegate with the results on
43 // the same thread when done. If |this| is destroyed before completion, the
44 // in-flight request is cancelled, and the delegate will not be called.
45 // Further details:
46 // * No cookies are sent/saved with the request.
47 // * In case of network/server errors, the request will not be retried.
48 // * Results are guaranteed to be always fresh and will never be cached.
49 virtual void StartRequest();
50
51 const std::vector<FacetURI>& requested_facet_uris() const {
52 return requested_facet_uris_;
53 }
54
55 AffiliationFetcherDelegate* delegate() const { return delegate_; }
56
57 protected:
58 AffiliationFetcher(net::URLRequestContextGetter* request_context_getter,
59 const std::vector<FacetURI>& facet_uris,
60 AffiliationFetcherDelegate* delegate);
61
62 private:
63 // Builds the URL for the Affiliation API's lookup method.
64 GURL BuildQueryURL() const;
65
66 // Prepares and returns the serialized protocol buffer message that will be
67 // the payload of the POST request.
68 std::string PreparePayload() const;
69
70 // Parses and validates the response protocol buffer message for a list of
71 // equivalence classes, stores them into |result| and returns true on success.
72 // Returns false if the response was gravely ill-formed or self-inconsistent.
73 // Unknown kinds of facet URIs and new protocol buffer fields will be ignored.
74 bool ParseResponse(AffiliationFetcherDelegate::Result* result) const;
75
76 // net::URLFetcherDelegate:
77 void OnURLFetchComplete(const net::URLFetcher* source) override;
78
79 const scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
80 const std::vector<FacetURI> requested_facet_uris_;
81 AffiliationFetcherDelegate* const delegate_;
82
83 scoped_ptr<net::URLFetcher> fetcher_;
84
85 DISALLOW_COPY_AND_ASSIGN(AffiliationFetcher);
86 };
87
88 } // namespace password_manager
89
90 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698