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

Side by Side Diff: net/url_request/url_request_data_job_fuzzer.cc

Issue 2259823002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 12 matching lines...) Expand all
23 23
24 // This class tests creating and reading to completion a URLRequest with fuzzed 24 // This class tests creating and reading to completion a URLRequest with fuzzed
25 // input. The fuzzer provides a data: URL and optionally generates custom Range 25 // input. The fuzzer provides a data: URL and optionally generates custom Range
26 // headers. The amount of data read in each Read call is also fuzzed, as is 26 // headers. The amount of data read in each Read call is also fuzzed, as is
27 // the size of the IOBuffer to read data into. 27 // the size of the IOBuffer to read data into.
28 class URLRequestDataJobFuzzerHarness : public net::URLRequest::Delegate { 28 class URLRequestDataJobFuzzerHarness : public net::URLRequest::Delegate {
29 public: 29 public:
30 URLRequestDataJobFuzzerHarness() 30 URLRequestDataJobFuzzerHarness()
31 : context_(true), task_runner_(base::ThreadTaskRunnerHandle::Get()) { 31 : context_(true), task_runner_(base::ThreadTaskRunnerHandle::Get()) {
32 job_factory_.SetProtocolHandler( 32 job_factory_.SetProtocolHandler(
33 "data", base::WrapUnique(new net::DataProtocolHandler())); 33 "data", base::MakeUnique<net::DataProtocolHandler>());
34 context_.set_job_factory(&job_factory_); 34 context_.set_job_factory(&job_factory_);
35 context_.Init(); 35 context_.Init();
36 } 36 }
37 37
38 static URLRequestDataJobFuzzerHarness* GetInstance() { 38 static URLRequestDataJobFuzzerHarness* GetInstance() {
39 return base::Singleton<URLRequestDataJobFuzzerHarness>::get(); 39 return base::Singleton<URLRequestDataJobFuzzerHarness>::get();
40 } 40 }
41 41
42 int CreateAndReadFromDataURLRequest(const uint8_t* data, size_t size) { 42 int CreateAndReadFromDataURLRequest(const uint8_t* data, size_t size) {
43 base::FuzzedDataProvider provider(data, size); 43 base::FuzzedDataProvider provider(data, size);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 base::RunLoop* read_loop_; 162 base::RunLoop* read_loop_;
163 163
164 DISALLOW_COPY_AND_ASSIGN(URLRequestDataJobFuzzerHarness); 164 DISALLOW_COPY_AND_ASSIGN(URLRequestDataJobFuzzerHarness);
165 }; 165 };
166 166
167 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 167 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
168 // Using a static singleton test harness lets the test run ~3-4x faster. 168 // Using a static singleton test harness lets the test run ~3-4x faster.
169 return URLRequestDataJobFuzzerHarness::GetInstance() 169 return URLRequestDataJobFuzzerHarness::GetInstance()
170 ->CreateAndReadFromDataURLRequest(data, size); 170 ->CreateAndReadFromDataURLRequest(data, size);
171 } 171 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_context_builder_unittest.cc ('k') | net/url_request/url_request_ftp_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698