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

Side by Side Diff: net/base/fuzzer_test_support.cc

Issue 1941933002: net: Prevent fuzzers from leaking on each iteration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/i18n/icu_util.h" 6 #include "base/i18n/icu_util.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/statistics_recorder.h"
9 10
10 namespace { 11 namespace {
11 12
12 // Set up globals that a number of network tests use. 13 // Set up globals that a number of network tests use.
13 // 14 //
14 // Note that in general static initializers are not allowed, however this is 15 // Note that in general static initializers are not allowed, however this is
15 // just being used by test code. 16 // just being used by test code.
16 struct InitGlobals { 17 struct InitGlobals {
17 InitGlobals() { 18 InitGlobals() {
18 // Set up ICU. ICU is used internally by GURL, which is used throughout the 19 // Set up ICU. ICU is used internally by GURL, which is used throughout the
19 // //net code. Initializing ICU is important to prevent fuzztests from 20 // //net code. Initializing ICU is important to prevent fuzztests from
20 // asserting when handling non-ASCII urls. 21 // asserting when handling non-ASCII urls.
21 CHECK(base::i18n::InitializeICU()); 22 CHECK(base::i18n::InitializeICU());
23
24 // Prevent every call to get a Histogram* from leaking memory. Instead, only
25 // the fist call to get each Histogram* leaks memory.
26 base::StatisticsRecorder::Initialize();
22 } 27 }
23 28
24 // A number of tests use async code which depends on there being a message 29 // A number of tests use async code which depends on there being a message
25 // loop. Setting one up here allows tests to reuse the message loop between 30 // loop. Setting one up here allows tests to reuse the message loop between
26 // runs. 31 // runs.
27 base::MessageLoopForIO message_loop; 32 base::MessageLoopForIO message_loop;
28 33
29 base::AtExitManager at_exit_manager; 34 base::AtExitManager at_exit_manager;
30 }; 35 };
31 36
32 InitGlobals* init_globals = new InitGlobals(); 37 InitGlobals* init_globals = new InitGlobals();
33 38
34 } // namespace 39 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698