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() { |