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

Side by Side Diff: net/test/url_request/ssl_certificate_error_job.cc

Issue 1239543003: [Cronet] Surface SSL cert error through CronetURLRequestAdapter::OnSSLCertificateError (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 5 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/test/url_request/ssl_certificate_error_job.h"
6
7 #include "base/bind.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/thread_task_runner_handle.h"
10 #include "net/url_request/url_request.h"
11 #include "net/url_request/url_request_filter.h"
12 #include "net/url_request/url_request_interceptor.h"
13
14 namespace net {
15
16 namespace {
17
18 const char kMockHostname[] = "mock.ssl.cert.error.request";
19
20 class MockJobInterceptor : public URLRequestInterceptor {
21 public:
22 MockJobInterceptor() {}
23 ~MockJobInterceptor() override {}
24
25 // URLRequestJobFactory::ProtocolHandler implementation:
26 URLRequestJob* MaybeInterceptRequest(
27 URLRequest* request,
28 NetworkDelegate* network_delegate) const override {
29 return new SSLCertificateErrorJob(request, network_delegate);
30 }
31
32 private:
33 DISALLOW_COPY_AND_ASSIGN(MockJobInterceptor);
34 };
35
36 } // namespace
37
38 SSLCertificateErrorJob::SSLCertificateErrorJob(
39 URLRequest* request,
40 NetworkDelegate* network_delegate)
41 : URLRequestTestJob(request, network_delegate, "", "", true),
42 weak_factory_(this) {
43 }
44
45 void SSLCertificateErrorJob::Start() {
46 base::ThreadTaskRunnerHandle::Get()->PostTask(
47 FROM_HERE, base::Bind(&SSLCertificateErrorJob::NotifyError,
48 weak_factory_.GetWeakPtr()));
49 }
50
51 void SSLCertificateErrorJob::AddUrlHandler() {
52 URLRequestFilter* filter = URLRequestFilter::GetInstance();
53 filter->AddHostnameInterceptor(
54 "https", kMockHostname,
55 scoped_ptr<URLRequestInterceptor>(new MockJobInterceptor()));
56 }
57
58 GURL SSLCertificateErrorJob::GetMockUrl() {
59 return GURL(base::StringPrintf("https://%s", kMockHostname));
mmenke 2015/07/17 21:09:18 Should probably include <string>
xunjieli 2015/07/20 14:56:20 Done.
60 }
61
62 SSLCertificateErrorJob::~SSLCertificateErrorJob() {
63 }
64
65 void SSLCertificateErrorJob::NotifyError() {
66 SSLInfo info;
mmenke 2015/07/17 21:09:18 Should include whatever header declares SSLInfo.
xunjieli 2015/07/20 14:56:20 Done.
67 info.cert_status = CERT_STATUS_DATE_INVALID;
68 NotifySSLCertificateError(info, true);
69 }
70
71 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698