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

Side by Side Diff: net/cert/cert_net_fetcher.h

Issue 2595723002: Allow CertNetFetcher to be shutdown from the network thread (Closed)
Patch Set: fix AIA tests 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
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_CERT_NET_FETCHER_H_ 5 #ifndef NET_CERT_CERT_NET_FETCHER_H_
6 #define NET_CERT_CERT_NET_FETCHER_H_ 6 #define NET_CERT_CERT_NET_FETCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
17 17
18 class GURL; 18 class GURL;
19 19
20 namespace net { 20 namespace net {
21 21
22 // CertNetFetcher is a synchronous interface for fetching AIA URLs and CRL 22 // CertNetFetcher is a synchronous interface for fetching AIA URLs and CRL
23 // URLs. 23 // URLs. It is shared between a caller thread (which starts and waits for
24 // fetches), and a network thread (which does the actual fetches). It can be
25 // shutdown from the network thread to cancel outstanding requests.
24 // 26 //
25 // A Request object is returned when starting a fetch. The consumer can 27 // A Request object is returned when starting a fetch. The consumer can
26 // use this as a handle for aborting the request (by freeing it), or reading 28 // use this as a handle for aborting the request (by freeing it), or reading
27 // the result of the request (WaitForResult) 29 // the result of the request (WaitForResult)
28 // 30 class NET_EXPORT CertNetFetcher
29 // This interface is expected to be operated from a single thread. 31 : public base::RefCountedThreadSafe<CertNetFetcher> {
30 //
31 // The CertNetFetcher must outlive all Request objects it creates.
32 class NET_EXPORT CertNetFetcher {
33 public: 32 public:
34 class Request { 33 class Request {
35 public: 34 public:
36 virtual ~Request() {} 35 virtual ~Request() {}
37 36
38 // WaitForResult() can be called at most once. 37 // WaitForResult() can be called at most once.
39 // 38 //
40 // It will block and wait for the (network) request to complete, and 39 // It will block and wait for the (network) request to complete, and
41 // then write the result into the provided out-parameters. 40 // then write the result into the provided out-parameters.
42 virtual void WaitForResult(Error* error, std::vector<uint8_t>* bytes) = 0; 41 virtual void WaitForResult(Error* error, std::vector<uint8_t>* bytes) = 0;
43 }; 42 };
44 43
45 // This value can be used in place of timeout or max size limits. 44 // This value can be used in place of timeout or max size limits.
46 enum { DEFAULT = -1 }; 45 enum { DEFAULT = -1 };
47 46
48 CertNetFetcher() {} 47 CertNetFetcher() {}
49 48
50 virtual ~CertNetFetcher() {} 49 // Shuts down the CertNetFetcher and cancels outstanding network
50 // requests. It is not guaranteed that any outstanding or subsequent
51 // Request::WaitForResult() calls will be completed.
eroman 2017/01/11 01:56:59 Could you add some comments that answer the questi
estark 2017/01/12 01:06:30 Done.
52 virtual void Shutdown() = 0;
51 53
52 // The Fetch*() methods start a request which can be cancelled by 54 // The Fetch*() methods start a request which can be cancelled by
53 // deleting the returned Request. Here is the meaning of the common 55 // deleting the returned Request. Here is the meaning of the common
54 // parameters: 56 // parameters:
55 // 57 //
56 // * url -- The http:// URL to fetch. 58 // * url -- The http:// URL to fetch.
57 // * timeout_seconds -- The maximum allowed duration for the fetch job. If 59 // * timeout_seconds -- The maximum allowed duration for the fetch job. If
58 // this delay is exceeded then the request will fail. To use a default 60 // this delay is exceeded then the request will fail. To use a default
59 // timeout pass DEFAULT. 61 // timeout pass DEFAULT.
60 // * max_response_bytes -- The maximum size of the response body. If this 62 // * max_response_bytes -- The maximum size of the response body. If this
61 // size is exceeded then the request will fail. To use a default timeout 63 // size is exceeded then the request will fail. To use a default timeout
62 // pass DEFAULT. 64 // pass DEFAULT.
63 65
64 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers( 66 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers(
65 const GURL& url, 67 const GURL& url,
66 int timeout_milliseconds, 68 int timeout_milliseconds,
67 int max_response_bytes) = 0; 69 int max_response_bytes) = 0;
68 70
69 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl( 71 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl(
70 const GURL& url, 72 const GURL& url,
71 int timeout_milliseconds, 73 int timeout_milliseconds,
72 int max_response_bytes) = 0; 74 int max_response_bytes) = 0;
73 75
74 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp( 76 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp(
75 const GURL& url, 77 const GURL& url,
76 int timeout_milliseconds, 78 int timeout_milliseconds,
77 int max_response_bytes) = 0; 79 int max_response_bytes) = 0;
78 80
81 protected:
82 virtual ~CertNetFetcher() {}
83
79 private: 84 private:
85 friend class base::RefCountedThreadSafe<CertNetFetcher>;
80 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher); 86 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher);
81 }; 87 };
82 88
83 } // namespace net 89 } // namespace net
84 90
85 #endif // NET_CERT_CERT_NET_FETCHER_H_ 91 #endif // NET_CERT_CERT_NET_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | net/cert/internal/cert_issuer_source_aia.h » ('j') | net/cert/internal/cert_issuer_source_aia.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698