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

Unified Diff: content/browser/aura/image_transport_factory.cc

Issue 45963003: Move test-only ContextFactory implementations out of production targets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert bad ui/base changes Created 7 years, 2 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/browser/aura/image_transport_factory.cc
diff --git a/content/browser/aura/image_transport_factory.cc b/content/browser/aura/image_transport_factory.cc
index ca831495e47616234f4755842d6042e98da8e8fe..4a20e7d9af19c302c15a047ebf72688fef7a852d 100644
--- a/content/browser/aura/image_transport_factory.cc
+++ b/content/browser/aura/image_transport_factory.cc
@@ -4,56 +4,32 @@
#include "content/browser/aura/image_transport_factory.h"
-#include "base/command_line.h"
-#include "base/sys_info.h"
#include "content/browser/aura/gpu_process_transport_factory.h"
#include "content/browser/aura/no_transport_image_transport_factory.h"
-#include "content/public/common/content_switches.h"
#include "ui/compositor/compositor.h"
-#include "ui/compositor/compositor_switches.h"
namespace content {
namespace {
-ImageTransportFactory* g_factory;
-}
-
-
-static bool UseTestContextAndTransportFactory() {
-#if defined(OS_CHROMEOS)
- // If the test is running on the chromeos envrionment (such as
- // device or vm bots), always use real contexts.
- if (base::SysInfo::IsRunningOnChromeOS())
- return false;
-#endif
-
- // Only used if the enable command line flag is used.
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (!command_line->HasSwitch(switches::kTestCompositor))
- return false;
-
- // The disable command line flag preempts the enable flag.
- if (!command_line->HasSwitch(switches::kDisableTestCompositor))
- return true;
-
- return false;
+ImageTransportFactory* g_factory = NULL;
+bool g_initialized_for_unit_tests = false;
}
// static
void ImageTransportFactory::Initialize() {
- DCHECK(!g_factory);
- if (UseTestContextAndTransportFactory()) {
- g_factory =
- new NoTransportImageTransportFactory(new ui::TestContextFactory);
- } else {
- g_factory = new GpuProcessTransportFactory;
- }
+ DCHECK(!g_factory || g_initialized_for_unit_tests);
+ if (g_initialized_for_unit_tests)
+ return;
+ g_factory = new GpuProcessTransportFactory;
ui::ContextFactory::SetInstance(g_factory->AsContextFactory());
}
-void ImageTransportFactory::InitializeForUnitTests() {
+void ImageTransportFactory::InitializeForUnitTests(
+ scoped_ptr<ui::ContextFactory> test_factory) {
DCHECK(!g_factory);
- g_factory = new NoTransportImageTransportFactory(new ui::TestContextFactory);
+ DCHECK(!g_initialized_for_unit_tests);
+ g_initialized_for_unit_tests = true;
+ g_factory = new NoTransportImageTransportFactory(test_factory.Pass());
ui::ContextFactory::SetInstance(g_factory->AsContextFactory());
}
@@ -62,6 +38,7 @@ void ImageTransportFactory::Terminate() {
ui::ContextFactory::SetInstance(NULL);
delete g_factory;
g_factory = NULL;
+ g_initialized_for_unit_tests = false;
}
// static

Powered by Google App Engine
This is Rietveld 408576698