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

Unified Diff: content/public/test/test_renderer_host.cc

Issue 2785523002: Reduce/remove usage of BrowserThread in content/browser/loader. (Closed)
Patch Set: Fix unittests redness Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/public/test/test_renderer_host.cc
diff --git a/content/public/test/test_renderer_host.cc b/content/public/test/test_renderer_host.cc
index 538a2ccbff5ccb373e97f3fe458e113df2f68736..8ac2eeb1dd2325bae7e07ce3fed67487dcd2f9d7 100644
--- a/content/public/test/test_renderer_host.cc
+++ b/content/public/test/test_renderer_host.cc
@@ -12,6 +12,7 @@
#include "build/build_config.h"
#include "content/browser/compositor/test/no_transport_image_transport_factory.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
+#include "content/browser/loader/loader_globals.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/site_instance_impl.h"
@@ -141,6 +142,19 @@ RenderViewHostTestEnabler::RenderViewHostTestEnabler()
if (base::ThreadTaskRunnerHandle::IsSet())
ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get());
#endif // OS_MACOSX
+ // TODO(ananta)
+ // Tests which use the RenderViewHostTestEnabler can run
+ // content/browser/loader code which assumes UI thread, IO thread task runner
+ // availability. As a workaround we instantiate the
+ // content/browser/loader/LoaderGlobals class which provides access to these
+ // task runners to the relevant code. This hack will go away when the loader
+ // code becomes part of the network service. We don't want to create the
+ // LoaderGlobals class if it already exists.
+ if (!LoaderGlobals::Get()) {
+ loader_globals_.reset(new content::LoaderGlobals(
+ BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
+ BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
+ }
}
RenderViewHostTestEnabler::~RenderViewHostTestEnabler() {
@@ -158,7 +172,6 @@ RenderViewHostTestEnabler::~RenderViewHostTestEnabler() {
// RenderViewHostTestHarness --------------------------------------------------
-
RenderViewHostTestHarness::RenderViewHostTestHarness()
: thread_bundle_options_(TestBrowserThreadBundle::DEFAULT) {}
@@ -284,6 +297,20 @@ void RenderViewHostTestHarness::SetUp() {
if (IsBrowserSideNavigationEnabled())
BrowserSideNavigationSetUp();
+
+ // TODO(ananta)
+ // Tests which use the RenderViewHostTestHarness can run
+ // content/browser/loader code which assumes UI thread, IO thread task runner
+ // availability. As a workaround we instantiate the
+ // content/browser/loader/LoaderGlobals class which provides access to these
+ // task runners to the relevant code. This hack will go away when the loader
+ // code becomes part of the network service. We don't want to create the
+ // LoaderGlobals class if it already exists.
+ if (!LoaderGlobals::Get()) {
+ loader_globals_.reset(new content::LoaderGlobals(
+ BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
+ BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
+ }
}
void RenderViewHostTestHarness::TearDown() {
« content/browser/loader/temporary_file_stream.cc ('K') | « content/public/test/test_renderer_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698