Skip to content

Commit

Permalink
Remove url::Initialize() and rename url::Shutdown() to url::ResetForT…
Browse files Browse the repository at this point in the history
…ests()

This is a follow-up cleanup to
https://chromium-review.googlesource.com/c/chromium/src/+/1600497

Change-Id: I27c3719322e96a5c1fca9aad761bb22536fed610
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1754232
Commit-Queue: Victor Vasiliev <vasilvv@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687473}
  • Loading branch information
Victor Vasiliev authored and Commit Bot committed Aug 15, 2019
1 parent 90cdc25 commit e5da609
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 38 deletions.
6 changes: 0 additions & 6 deletions android_webview/lib/webview_jni_onload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "components/version_info/version_info_values.h"
#include "content/public/app/content_jni_onload.h"
#include "content/public/app/content_main.h"
#include "url/url_util.h"

namespace android_webview {

Expand All @@ -19,11 +18,6 @@ bool OnJNIOnLoadInit() {

base::android::SetVersionNumber(PRODUCT_VERSION);
content::SetContentMainDelegate(new android_webview::AwMainDelegate());

// Initialize url lib here while we are still single-threaded, in case we use
// CookieManager before initializing Chromium (which would normally have done
// this). It's safe to call this multiple times.
url::Initialize();
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions components/cronet/android/cronet_library_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "third_party/zlib/zlib.h"
#include "url/buildflags.h"
#include "url/url_util.h"

#if !BUILDFLAG(USE_PLATFORM_ICU_ALTERNATIVES)
#include "base/i18n/icu_util.h" // nogncheck
Expand Down Expand Up @@ -74,7 +73,6 @@ void NativeInit() {

if (!base::ThreadPoolInstance::Get())
base::ThreadPoolInstance::CreateAndStartWithDefaultParams("Cronet");
url::Initialize();
}

} // namespace
Expand Down
3 changes: 0 additions & 3 deletions components/cronet/cronet_global_state_stubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "base/task/thread_pool/thread_pool.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "url/url_util.h"

// This file provides minimal "stub" implementations of the Cronet global-state
// functions for the native library build, sufficient to have cronet_tests and
Expand All @@ -29,8 +28,6 @@ scoped_refptr<base::SingleThreadTaskRunner> InitializeAndCreateTaskRunner() {

base::FeatureList::InitializeInstance(std::string(), std::string());

url::Initialize();

// Note that in component builds this ThreadPoolInstance will be shared with
// the calling process, if it also depends on //base. In particular this means
// that the Cronet test binaries must avoid initializing or shutting-down the
Expand Down
3 changes: 0 additions & 3 deletions components/cronet/ios/cronet_global_state_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "ios/web/public/init/ios_global_state_configuration.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "url/url_util.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
Expand All @@ -31,8 +30,6 @@ void InitializeOnMainThread() {
ios_global_state::Create(create_params);
ios_global_state::StartThreadPool();

url::Initialize();

ios_global_state::BuildSingleThreadTaskExecutor();
ios_global_state::CreateNetworkChangeNotifier();
}
Expand Down
2 changes: 1 addition & 1 deletion components/test/components_test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ComponentsTestSuite : public base::TestSuite {
mojo::core::Init();

// Before registering any schemes, clear GURL's internal state.
url::Shutdown();
url::ResetForTests();

#if !defined(OS_IOS)
gl::GLSurfaceTestSupport::InitializeOneOff();
Expand Down
5 changes: 0 additions & 5 deletions content/public/test/blink_test_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "third_party/blink/public/platform/web_cache.h"
#include "third_party/blink/public/platform/web_runtime_features.h"
#include "third_party/blink/public/web/blink.h"
#include "url/url_util.h"

#if defined(OS_WIN)
#include "ui/display/win/dpi.h"
Expand Down Expand Up @@ -81,10 +80,6 @@ void SetUpBlinkTestEnvironment() {
display::win::SetDefaultDeviceScaleFactor(1.0f);
#endif

// Explicitly initialize the GURL library before spawning any threads.
// Otherwise crash may happend when different threads try to create a GURL
// at same time.
url::Initialize();
test_environment = new TestEnvironment;
}

Expand Down
3 changes: 1 addition & 2 deletions content/public/test/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ void IsolateAllSitesForTesting(base::CommandLine* command_line) {
}

void ResetSchemesAndOriginsWhitelist() {
url::Shutdown();
url::ResetForTests();
RegisterContentSchemes(false);
url::Initialize();
}

GURL GetWebUIURL(const std::string& host) {
Expand Down
2 changes: 1 addition & 1 deletion google_apis/drive/drive_api_url_generator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DriveApiUrlGeneratorTest : public testing::Test {
url::AddStandardScheme("chrome-extension", url::SCHEME_WITH_HOST);
}

~DriveApiUrlGeneratorTest() override { url::Shutdown(); }
~DriveApiUrlGeneratorTest() override { url::ResetForTests(); }

protected:
DriveApiUrlGenerator url_generator_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ TEST_F(SecurityOriginTest, NonStandardSchemeWithAndroidWebViewHack) {
EXPECT_EQ("cow", origin->Protocol());
EXPECT_EQ("", origin->Host());
EXPECT_EQ(0, origin->Port());
url::Shutdown();
url::ResetForTests();
}

TEST_F(SecurityOriginTest, OpaqueIsolatedCopy) {
Expand Down
4 changes: 2 additions & 2 deletions url/origin_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class OriginTest : public ::testing::Test {
AddStandardScheme("standard-but-noaccess", SchemeType::SCHEME_WITH_HOST);
AddNoAccessScheme("standard-but-noaccess");
}
void TearDown() override { url::Shutdown(); }
void TearDown() override { url::ResetForTests(); }

::testing::AssertionResult DoEqualityComparisons(const url::Origin& a,
const url::Origin& b,
Expand Down Expand Up @@ -667,7 +667,7 @@ TEST_F(OriginTest, NonStandardSchemeWithAndroidWebViewHack) {
EXPECT_EQ("cow", origin.scheme());
EXPECT_EQ("", origin.host());
EXPECT_EQ(0, origin.port());
Shutdown();
ResetForTests();
}

TEST_F(OriginTest, CanBeDerivedFrom) {
Expand Down
2 changes: 1 addition & 1 deletion url/scheme_host_port_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SchemeHostPortTest : public testing::Test {
SchemeHostPortTest() = default;
~SchemeHostPortTest() override {
// Reset any added schemes.
url::Shutdown();
url::ResetForTests();
}

private:
Expand Down
6 changes: 1 addition & 5 deletions url/url_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,7 @@ void DoAddSchemeWithType(const char* new_scheme,

} // namespace

void Initialize() {
// Deprecated.
}

void Shutdown() {
void ResetForTests() {
*GetSchemeRegistry() = SchemeRegistry();
}

Expand Down
5 changes: 1 addition & 4 deletions url/url_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ namespace url {

// Init ------------------------------------------------------------------------

// Deprecated. Does not do anything.
COMPONENT_EXPORT(URL) void Initialize();

// Resets all custom schemes to the default values. Not thread-safe.
COMPONENT_EXPORT(URL) void Shutdown();
COMPONENT_EXPORT(URL) void ResetForTests();

// Schemes ---------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions url/url_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class URLUtilTest : public testing::Test {
URLUtilTest() = default;
~URLUtilTest() override {
// Reset any added schemes.
Shutdown();
ResetForTests();
}

private:
Expand Down Expand Up @@ -106,7 +106,7 @@ TEST_F(URLUtilTest, ShutdownCleansUpSchemes) {
AddReferrerScheme(kFooScheme, url::SCHEME_WITH_HOST);
EXPECT_TRUE(IsReferrerScheme(kFooScheme, Component(0, strlen(kFooScheme))));

Shutdown();
ResetForTests();
EXPECT_FALSE(IsReferrerScheme(kFooScheme, Component(0, strlen(kFooScheme))));
}

Expand Down

0 comments on commit e5da609

Please sign in to comment.