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

Side by Side Diff: net/test/url_request/url_request_mock_data_job.h

Issue 1459993003: [Cronet] Continue UrlRequest with NULL certificate if Client cert is requested. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use UrlRequestMockDataJob for testing. Created 5 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
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 NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 #include "net/url_request/url_request_job.h" 12 #include "net/url_request/url_request_job.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 class URLRequest; 16 class URLRequest;
17 17
18 // Mock data job, which synchronously returns data repeated multiple times. 18 // Mock data job, which synchronously returns data repeated multiple times.
xunjieli 2015/11/20 21:04:25 Maybe also say that when |request_client_certifica
mef 2015/11/20 22:01:23 Done.
19 class URLRequestMockDataJob : public URLRequestJob { 19 class URLRequestMockDataJob : public URLRequestJob {
20 public: 20 public:
21 URLRequestMockDataJob(URLRequest* request, 21 URLRequestMockDataJob(URLRequest* request,
22 NetworkDelegate* network_delegate, 22 NetworkDelegate* network_delegate,
23 const std::string& data, 23 const std::string& data,
24 int data_repeat_count); 24 int data_repeat_count,
25 bool request_client_certificate);
25 26
26 void Start() override; 27 void Start() override;
27 int ReadRawData(IOBuffer* buf, int buf_size) override; 28 int ReadRawData(IOBuffer* buf, int buf_size) override;
28 int GetResponseCode() const override; 29 int GetResponseCode() const override;
29 void GetResponseInfo(HttpResponseInfo* info) override; 30 void GetResponseInfo(HttpResponseInfo* info) override;
31 void ContinueWithCertificate(X509Certificate* client_cert,
32 SSLPrivateKey* client_private_key) override;
30 33
31 // Adds the testing URLs to the URLRequestFilter. 34 // Adds the testing URLs to the URLRequestFilter.
32 static void AddUrlHandler(); 35 static void AddUrlHandler();
33 static void AddUrlHandlerForHostname(const std::string& hostname); 36 static void AddUrlHandlerForHostname(const std::string& hostname);
34 37
35 // Given data and repeat cound, constructs a mock URL that will return that 38 // Given data and repeat cound, constructs a mock URL that will return that
36 // data repeated |repeat_count| times when started. |data| must be safe for 39 // data repeated |repeat_count| times when started. |data| must be safe for
37 // URL. 40 // URL.
38 static GURL GetMockHttpUrl(const std::string& data, int repeat_count); 41 static GURL GetMockHttpUrl(const std::string& data, int repeat_count);
39 static GURL GetMockHttpsUrl(const std::string& data, int repeat_count); 42 static GURL GetMockHttpsUrl(const std::string& data, int repeat_count);
40 43
44 // Constructs Mock URL which will request client certificate.
xunjieli 2015/11/20 21:04:25 Maybe mention that the response body is the word "
mef 2015/11/20 22:01:23 Done.
45 static GURL GetMockUrlForClientCertificateRequest();
46
41 // URLRequestFailedJob must be added as a handler for |hostname| for 47 // URLRequestFailedJob must be added as a handler for |hostname| for
42 // the returned URL to return |net_error|. 48 // the returned URL to return |net_error|.
43 static GURL GetMockHttpUrlForHostname(const std::string& hostname, 49 static GURL GetMockHttpUrlForHostname(const std::string& hostname,
44 const std::string& data, 50 const std::string& data,
45 int repeat_count); 51 int repeat_count);
46 static GURL GetMockHttpsUrlForHostname(const std::string& hostname, 52 static GURL GetMockHttpsUrlForHostname(const std::string& hostname,
47 const std::string& data, 53 const std::string& data,
48 int repeat_count); 54 int repeat_count);
49 55
50 private: 56 private:
51 void GetResponseInfoConst(HttpResponseInfo* info) const; 57 void GetResponseInfoConst(HttpResponseInfo* info) const;
52 ~URLRequestMockDataJob() override; 58 ~URLRequestMockDataJob() override;
53 59
54 void StartAsync(); 60 void StartAsync();
55 61
56 std::string data_; 62 std::string data_;
57 size_t data_offset_; 63 size_t data_offset_;
64 bool request_client_certificate_;
58 base::WeakPtrFactory<URLRequestMockDataJob> weak_factory_; 65 base::WeakPtrFactory<URLRequestMockDataJob> weak_factory_;
59 }; 66 };
60 67
61 } // namespace net 68 } // namespace net
62 69
63 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_ 70 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698