xref: /aosp_15_r20/external/cronet/net/test/url_request/ssl_certificate_error_job.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2015 The Chromium Authors
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 NET_TEST_URL_REQUEST_SSL_CERTIFICATE_ERROR_JOB_H_
6 #define NET_TEST_URL_REQUEST_SSL_CERTIFICATE_ERROR_JOB_H_
7 
8 #include "base/memory/weak_ptr.h"
9 #include "net/url_request/url_request_job.h"
10 #include "url/gurl.h"
11 
12 namespace net {
13 
14 class URLRequest;
15 
16 // SSLCertificateErrorJob simulates a ERR_CERT_DATE_INVALID error.
17 class SSLCertificateErrorJob : public URLRequestJob {
18  public:
19   explicit SSLCertificateErrorJob(URLRequest* request);
20 
21   SSLCertificateErrorJob(const SSLCertificateErrorJob&) = delete;
22   SSLCertificateErrorJob& operator=(const SSLCertificateErrorJob&) = delete;
23 
24   ~SSLCertificateErrorJob() override;
25 
26   // URLRequestJob implementation:
27   void Start() override;
28 
29   // Adds the testing URLs to the URLRequestFilter.
30   static void AddUrlHandler();
31 
32   static GURL GetMockUrl();
33 
34  private:
35   void NotifyError();
36 
37   base::WeakPtrFactory<SSLCertificateErrorJob> weak_factory_{this};
38 };
39 
40 }  // namespace net
41 
42 #endif  // NET_TEST_URL_REQUEST_SSL_CERTIFICATE_ERROR_JOB_H_
43