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

Side by Side Diff: content/browser/compositor/image_transport_factory.cc

Issue 369923003: NoTransportImageTransportFactory is compiled into only test targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: InitializeForUnitTests get scoped_ptr Created 6 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/compositor/image_transport_factory.h" 5 #include "content/browser/compositor/image_transport_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/compositor/gpu_process_transport_factory.h" 8 #include "content/browser/compositor/gpu_process_transport_factory.h"
9 #include "content/browser/compositor/no_transport_image_transport_factory.h"
10 #include "ui/compositor/compositor.h" 9 #include "ui/compositor/compositor.h"
11 #include "ui/compositor/compositor_switches.h" 10 #include "ui/compositor/compositor_switches.h"
12 #include "ui/gl/gl_implementation.h" 11 #include "ui/gl/gl_implementation.h"
13 12
14 namespace content { 13 namespace content {
15 14
16 namespace { 15 namespace {
17 ImageTransportFactory* g_factory = NULL; 16 ImageTransportFactory* g_factory = NULL;
18 bool g_initialized_for_unit_tests = false; 17 bool g_initialized_for_unit_tests = false;
19 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; 18 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL;
20 19
21 void SetFactory(ImageTransportFactory* factory) { 20 void SetFactory(ImageTransportFactory* factory) {
22 g_factory = factory; 21 g_factory = factory;
23 } 22 }
24 23
25 } 24 }
26 25
27 // static 26 // static
28 void ImageTransportFactory::Initialize() { 27 void ImageTransportFactory::Initialize() {
29 DCHECK(!g_factory || g_initialized_for_unit_tests); 28 DCHECK(!g_factory || g_initialized_for_unit_tests);
30 if (g_initialized_for_unit_tests) 29 if (g_initialized_for_unit_tests)
31 return; 30 return;
32 SetFactory(new GpuProcessTransportFactory); 31 SetFactory(new GpuProcessTransportFactory);
33 } 32 }
34 33
35 void ImageTransportFactory::InitializeForUnitTests( 34 void ImageTransportFactory::InitializeForUnitTests(
36 scoped_ptr<ui::ContextFactory> test_factory) { 35 scoped_ptr<ImageTransportFactory> factory) {
37 DCHECK(!g_factory); 36 DCHECK(!g_factory);
38 DCHECK(!g_initialized_for_unit_tests); 37 DCHECK(!g_initialized_for_unit_tests);
39 g_initialized_for_unit_tests = true; 38 g_initialized_for_unit_tests = true;
40 39
41 CommandLine* command_line = CommandLine::ForCurrentProcess(); 40 CommandLine* command_line = CommandLine::ForCurrentProcess();
42 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) 41 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests))
43 g_disable_null_draw = new gfx::DisableNullDrawGLBindings; 42 g_disable_null_draw = new gfx::DisableNullDrawGLBindings;
44 43
45 SetFactory(new NoTransportImageTransportFactory(test_factory.Pass())); 44 SetFactory(factory.release());
46 } 45 }
47 46
48 // static 47 // static
49 void ImageTransportFactory::Terminate() { 48 void ImageTransportFactory::Terminate() {
50 delete g_factory; 49 delete g_factory;
51 g_factory = NULL; 50 g_factory = NULL;
52 delete g_disable_null_draw; 51 delete g_disable_null_draw;
53 g_disable_null_draw = NULL; 52 g_disable_null_draw = NULL;
54 g_initialized_for_unit_tests = false; 53 g_initialized_for_unit_tests = false;
55 } 54 }
56 55
57 // static 56 // static
58 ImageTransportFactory* ImageTransportFactory::GetInstance() { 57 ImageTransportFactory* ImageTransportFactory::GetInstance() {
59 return g_factory; 58 return g_factory;
60 } 59 }
61 60
62 } // namespace content 61 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698