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

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

Issue 866733002: Add FakeAffiliationFetcher and factory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing file. Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "components/password_manager/core/browser/affiliation_fetcher_delegate. h" 12 #include "components/password_manager/core/browser/affiliation_fetcher_delegate. h"
13 #include "components/password_manager/core/browser/affiliation_utils.h" 13 #include "components/password_manager/core/browser/affiliation_utils.h"
14 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
15 15
16 class GURL; 16 class GURL;
17 17
18 namespace net { 18 namespace net {
19 class URLRequestContextGetter; 19 class URLRequestContextGetter;
20 } // namespace net 20 } // namespace net
21 21
22 namespace password_manager { 22 namespace password_manager {
23 23
24 class TestAffiliationFetcherFactory;
25
24 // Fetches authoritative information regarding which facets are affiliated with 26 // Fetches authoritative information regarding which facets are affiliated with
25 // each other, that is, which facets belong to the same logical application. 27 // each other, that is, which facets belong to the same logical application.
26 // See affiliation_utils.h for a definition of what this means. 28 // See affiliation_utils.h for a definition of what this means.
27 // 29 //
28 // An instance is good for exactly one fetch, and may be used from any thread 30 // 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). 31 // that runs a message loop (i.e. not a worker pool thread).
30 class AffiliationFetcher : net::URLFetcherDelegate { 32 class AffiliationFetcher : net::URLFetcherDelegate {
31 public: 33 public:
32 ~AffiliationFetcher() override; 34 ~AffiliationFetcher() override;
33 35
34 // Constructs a fetcher to retrieve affiliations for each facet in |facet_ids| 36 // Constructs a fetcher to retrieve affiliations for each facet in |facet_ids|
35 // using the specified |request_context_getter|, and will provide the results 37 // using the specified |request_context_getter|, and will provide the results
36 // to the |delegate| on the same thread that creates the instance. 38 // to the |delegate| on the same thread that creates the instance.
37 static AffiliationFetcher* Create( 39 static AffiliationFetcher* Create(
38 net::URLRequestContextGetter* request_context_getter, 40 net::URLRequestContextGetter* request_context_getter,
39 const std::vector<FacetURI>& facet_uris, 41 const std::vector<FacetURI>& facet_uris,
40 AffiliationFetcherDelegate* delegate); 42 AffiliationFetcherDelegate* delegate);
41 43
44 // Sets the |factory| to be used by Create() to construct AffiliationFetcher
45 // instances. To be used only for testing.
46 //
47 // The caller must ensure that the |factory| outlives all potential Create()
48 // calls. The caller may pass in NULL to resume using the default factory.
49 static void SetFactoryForTesting(TestAffiliationFetcherFactory* factory);
50
42 // Actually starts the request, and will call the delegate with the results on 51 // 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 52 // 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. 53 // in-flight request is cancelled, and the delegate will not be called.
45 // Further details: 54 // Further details:
46 // * No cookies are sent/saved with the request. 55 // * No cookies are sent/saved with the request.
47 // * In case of network/server errors, the request will not be retried. 56 // * 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. 57 // * Results are guaranteed to be always fresh and will never be cached.
49 virtual void StartRequest(); 58 virtual void StartRequest();
50 59
51 const std::vector<FacetURI>& requested_facet_uris() const { 60 const std::vector<FacetURI>& requested_facet_uris() const {
(...skipping 29 matching lines...) Expand all
81 AffiliationFetcherDelegate* const delegate_; 90 AffiliationFetcherDelegate* const delegate_;
82 91
83 scoped_ptr<net::URLFetcher> fetcher_; 92 scoped_ptr<net::URLFetcher> fetcher_;
84 93
85 DISALLOW_COPY_AND_ASSIGN(AffiliationFetcher); 94 DISALLOW_COPY_AND_ASSIGN(AffiliationFetcher);
86 }; 95 };
87 96
88 } // namespace password_manager 97 } // namespace password_manager
89 98
90 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_ 99 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_FETCHER_H_
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/BUILD.gn ('k') | components/password_manager/core/browser/affiliation_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698