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

Side by Side Diff: net/cert_net/cert_net_fetcher_impl.h

Issue 2453093004: Remove dependence on a message loop for net::PathBuilder. (Closed)
Patch Set: remove unnecessary forward decl Created 4 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
« no previous file with comments | « net/cert/internal/trust_store_test_helpers.cc ('k') | net/cert_net/cert_net_fetcher_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 NET_CERT_NET_CERT_NET_FETCHER_H_ 5 #ifndef NET_CERT_NET_CERT_NET_FETCHER_H_
6 #define NET_CERT_NET_CERT_NET_FETCHER_H_ 6 #define NET_CERT_NET_CERT_NET_FETCHER_H_
7 7
8 #include <map>
9 #include <memory> 8 #include <memory>
10 9
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/threading/thread_checker.h"
14 #include "net/base/net_errors.h"
15 #include "net/base/net_export.h" 10 #include "net/base/net_export.h"
16 #include "net/cert/cert_net_fetcher.h"
17 11
18 namespace net { 12 namespace net {
19 13
20 class URLRequestContext; 14 class CertNetFetcher;
15 class URLRequestContextGetter;
21 16
22 // CertNetFetcherImpl is an implementation of CertNetFetcher that uses the 17 // Creates a CertNetFetcher that issues requests through the provided
23 // network stack. 18 // URLRequestContext.
24 // 19 //
25 // For more details refer to the documentation for the interface. 20 // The returned CertNetFetcher is to be operated on a thread *other* than the
26 class NET_EXPORT CertNetFetcherImpl : public CertNetFetcher { 21 // thread used for the URLRequestContext (since it gives a blocking interface
27 public: 22 // to URL fetching).
28 // Initializes CertNetFetcherImpl using the specified URLRequestContext for 23 NET_EXPORT std::unique_ptr<CertNetFetcher> CreateCertNetFetcher(
29 // issuing requests. |context| must remain valid for the entire lifetime of 24 URLRequestContextGetter* context_getter);
30 // the CertNetFetcherImpl.
31 explicit CertNetFetcherImpl(URLRequestContext* context);
32
33 // Deletion implicitly cancels any outstanding requests.
34 ~CertNetFetcherImpl() override;
35
36 WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers(
37 const GURL& url,
38 int timeout_milliseconds,
39 int max_response_bytes,
40 const FetchCallback& callback) override;
41
42 WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl(
43 const GURL& url,
44 int timeout_milliseconds,
45 int max_response_bytes,
46 const FetchCallback& callback) override;
47
48 WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp(
49 const GURL& url,
50 int timeout_milliseconds,
51 int max_response_bytes,
52 const FetchCallback& callback) override;
53
54 private:
55 class RequestImpl;
56 class Job;
57 struct JobToRequestParamsComparator;
58 struct RequestParams;
59
60 struct JobComparator {
61 bool operator()(const Job* job1, const Job* job2) const;
62 };
63
64 // Would be a set<unique_ptr> but extraction of owned objects from a set of
65 // owned types doesn't come until C++17.
66 using JobSet = std::map<Job*, std::unique_ptr<Job>, JobComparator>;
67
68 // Starts an asynchronous request to fetch the given URL. On completion
69 // |callback| will be invoked.
70 //
71 // Completion of the request will never occur synchronously. In other words it
72 // is guaranteed that |callback| will only be invoked once the Fetch*() method
73 // has returned.
74 WARN_UNUSED_RESULT std::unique_ptr<Request> Fetch(
75 std::unique_ptr<RequestParams> request_params,
76 const FetchCallback& callback);
77
78 // Finds a job with a matching RequestPararms or returns nullptr if there was
79 // no match.
80 Job* FindJob(const RequestParams& params);
81
82 // Removes |job| from the in progress jobs and transfers ownership to the
83 // caller.
84 std::unique_ptr<Job> RemoveJob(Job* job);
85
86 // Indicates which Job is currently executing inside of OnJobCompleted().
87 void SetCurrentlyCompletingJob(Job* job);
88 void ClearCurrentlyCompletingJob(Job* job);
89 bool IsCurrentlyCompletingJob(Job* job);
90
91 // The in-progress jobs. This set does not contain the job which is actively
92 // invoking callbacks (OnJobCompleted). Instead that is tracked by
93 // |currently_completing_job_|.
94 JobSet jobs_;
95
96 // The Job that is currently executing OnJobCompleted(). There can be at most
97 // one such job. This pointer is not owned.
98 Job* currently_completing_job_;
99
100 // Not owned. CertNetFetcherImpl must outlive the URLRequestContext.
101 URLRequestContext* context_;
102
103 base::ThreadChecker thread_checker_;
104
105 DISALLOW_COPY_AND_ASSIGN(CertNetFetcherImpl);
106 };
107 25
108 } // namespace net 26 } // namespace net
109 27
110 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_ 28 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_
OLDNEW
« no previous file with comments | « net/cert/internal/trust_store_test_helpers.cc ('k') | net/cert_net/cert_net_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698