Skip to content

Commit

Permalink
Merge ui::ContextFactoryPrivate with ui::ContextFactory
Browse files Browse the repository at this point in the history
All ContextFactoryPrivate implementations are also ContextFactory
implementations. Move the two remaining ContextFactoryPrivate functions
into ContextFactory and clean up usage.

Bug: 1042259
Change-Id: I48063717cd6e51ccfc94e0a160d50d95d7629388
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047728
Commit-Queue: Sean Gilhuly <sgilhuly@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744444}
  • Loading branch information
Sean Gilhuly authored and Commit Bot committed Feb 25, 2020
1 parent 6f9aed8 commit dc0b9fd
Show file tree
Hide file tree
Showing 75 changed files with 140 additions and 378 deletions.
6 changes: 1 addition & 5 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ Shell* Shell::instance_ = nullptr;
Shell* Shell::CreateInstance(ShellInitParams init_params) {
CHECK(!instance_);
instance_ = new Shell(std::move(init_params.delegate));
instance_->Init(init_params.context_factory,
init_params.context_factory_private, init_params.local_state,
instance_->Init(init_params.context_factory, init_params.local_state,
std::move(init_params.keyboard_ui_factory),
init_params.dbus_bus);
return instance_;
Expand Down Expand Up @@ -865,7 +864,6 @@ Shell::~Shell() {

void Shell::Init(
ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private,
PrefService* local_state,
std::unique_ptr<keyboard::KeyboardUIFactory> keyboard_ui_factory,
scoped_refptr<dbus::Bus> dbus_bus) {
Expand Down Expand Up @@ -934,8 +932,6 @@ void Shell::Init(
aura::Env* env = aura::Env::GetInstance();
if (context_factory)
env->set_context_factory(context_factory);
if (context_factory_private)
env->set_context_factory_private(context_factory_private);

// Night Light depends on the display manager, the display color manager, and
// aura::Env, so initialize it after all have been initialized.
Expand Down
2 changes: 0 additions & 2 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class KeyboardUIFactory;

namespace ui {
class ContextFactory;
class ContextFactoryPrivate;
class UserActivityDetector;
class UserActivityPowerManagerNotifier;
} // namespace ui
Expand Down Expand Up @@ -583,7 +582,6 @@ class ASH_EXPORT Shell : public SessionObserver,
~Shell() override;

void Init(ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private,
PrefService* local_state,
std::unique_ptr<keyboard::KeyboardUIFactory> keyboard_ui_factory,
scoped_refptr<dbus::Bus> dbus_bus);
Expand Down
6 changes: 2 additions & 4 deletions ash/shell/content/client/shell_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,16 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
AshTestHelper::InitParams init_params;
// TODO(oshima): Separate the class for ash_shell to reduce the test binary
// size.
if (parameters_.ui_task)
if (parameters_.ui_task) {
init_params.config_type = AshTestHelper::kPerfTest;
else {
} else {
new_window_delegate_ = std::make_unique<ShellNewWindowDelegate>();
init_params.config_type = AshTestHelper::kShell;
}

ShellInitParams shell_init_params;
shell_init_params.delegate = std::make_unique<ShellDelegateImpl>();
shell_init_params.context_factory = content::GetContextFactory();
shell_init_params.context_factory_private =
content::GetContextFactoryPrivate();
shell_init_params.keyboard_ui_factory =
std::make_unique<TestKeyboardUIFactory>();

Expand Down
2 changes: 0 additions & 2 deletions ash/shell_init_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class KeyboardUIFactory;

namespace ui {
class ContextFactory;
class ContextFactoryPrivate;
}

namespace ash {
Expand All @@ -33,7 +32,6 @@ struct ASH_EXPORT ShellInitParams {

std::unique_ptr<ShellDelegate> delegate;
ui::ContextFactory* context_factory = nullptr; // Non-owning.
ui::ContextFactoryPrivate* context_factory_private = nullptr; // Non-owning.
PrefService* local_state = nullptr; // Non-owning.

// Factory for creating the virtual keyboard UI. Must be non-null.
Expand Down
13 changes: 4 additions & 9 deletions ash/test/ash_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,11 @@ void AshTestHelper::TearDown() {

context_factories_.reset();

// Context factory (and context factory private) referenced by Env are now
// destroyed. Reset Env's members in case some other test tries to use it.
// This matters if someone else created Env (such as the test suite) and is
// long lived.
if (aura::Env::HasInstance()) {
// Context factory referenced by Env is now destroyed. Reset Env's members in
// case some other test tries to use it. This matters if someone else created
// Env (such as the test suite) and is long lived.
if (aura::Env::HasInstance())
aura::Env::GetInstance()->set_context_factory(nullptr);
aura::Env::GetInstance()->set_context_factory_private(nullptr);
}

ui::ShutdownInputMethodForTesting();
zero_duration_mode_.reset();
Expand Down Expand Up @@ -310,8 +307,6 @@ void AshTestHelper::CreateShell(base::Optional<ShellInitParams> init_params,
init_params.emplace(ShellInitParams());
init_params->delegate.reset(test_shell_delegate_);
init_params->context_factory = context_factories_->GetContextFactory();
init_params->context_factory_private =
context_factories_->GetContextFactoryPrivate();
init_params->keyboard_ui_factory =
std::make_unique<TestKeyboardUIFactory>();
}
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/video_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void VideoDetector::EstablishConnectionToViz() {
receiver_.set_disconnect_handler(base::BindOnce(
&VideoDetector::OnConnectionError, base::Unretained(this)));
aura::Env::GetInstance()
->context_factory_private()
->context_factory()
->GetHostFrameSinkManager()
->AddVideoDetectorObserver(std::move(observer));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ AdaptiveScreenBrightnessManager::CreateInstance() {
.InitWithNewPipeAndPassReceiver(),
std::make_unique<base::RepeatingTimer>());
aura::Env::GetInstance()
->context_factory_private()
->context_factory()
->GetHostFrameSinkManager()
->AddVideoDetectorObserver(
std::move(video_observer_screen_brightness_logger));
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/power/ml/user_activity_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ UserActivityController::UserActivityController() {
power_manager_client, detector,
video_observer_idle_notifier.InitWithNewPipeAndPassReceiver());
aura::Env::GetInstance()
->context_factory_private()
->context_factory()
->GetHostFrameSinkManager()
->AddVideoDetectorObserver(std::move(video_observer_idle_notifier));

Expand All @@ -53,7 +53,7 @@ UserActivityController::UserActivityController() {
video_observer_user_logger.InitWithNewPipeAndPassReceiver(),
chromeos::ChromeUserManager::Get(), &smart_dim_model_);
aura::Env::GetInstance()
->context_factory_private()
->context_factory()
->GetHostFrameSinkManager()
->AddVideoDetectorObserver(std::move(video_observer_user_logger));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ std::unique_ptr<SmartChargingManager> SmartChargingManager::CreateInstance() {
std::make_unique<base::RepeatingTimer>());

aura::Env::GetInstance()
->context_factory_private()
->context_factory()
->GetHostFrameSinkManager()
->AddVideoDetectorObserver(std::move(video_observer));

Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/ui/ash/ash_shell_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ void CreateShell() {
ash::ShellInitParams shell_init_params;
shell_init_params.delegate = std::make_unique<ChromeShellDelegate>();
shell_init_params.context_factory = content::GetContextFactory();
shell_init_params.context_factory_private =
content::GetContextFactoryPrivate();
shell_init_params.local_state = g_browser_process->local_state();
shell_init_params.keyboard_ui_factory =
std::make_unique<ChromeKeyboardUIFactory>();
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/ui/views/chrome_views_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ ui::ContextFactory* ChromeViewsDelegate::GetContextFactory() {
return content::GetContextFactory();
}

ui::ContextFactoryPrivate* ChromeViewsDelegate::GetContextFactoryPrivate() {
return content::GetContextFactoryPrivate();
}

std::string ChromeViewsDelegate::GetApplicationName() {
return version_info::GetProductName();
}
1 change: 0 additions & 1 deletion chrome/browser/ui/views/chrome_views_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class ChromeViewsDelegate : public views::ViewsDelegate {
views::Widget::InitParams* params,
views::internal::NativeWidgetDelegate* delegate) override;
ui::ContextFactory* GetContextFactory() override;
ui::ContextFactoryPrivate* GetContextFactoryPrivate() override;
std::string GetApplicationName() override;

private:
Expand Down
5 changes: 1 addition & 4 deletions chrome/browser/ui/views/test/view_event_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ void ViewEventTestBase::SetUp() {
std::make_unique<ui::TestContextFactories>(enable_pixel_output);

views_delegate_.set_context_factory(context_factories_->GetContextFactory());
views_delegate_.set_context_factory_private(
context_factories_->GetContextFactoryPrivate());
views_delegate_.set_use_desktop_native_widgets(true);

platform_part_.reset(ViewEventTestPlatformPart::Create(
context_factories_->GetContextFactory(),
context_factories_->GetContextFactoryPrivate()));
context_factories_->GetContextFactory()));
gfx::NativeWindow context = platform_part_->GetContext();
window_ = views::Widget::CreateWindowWithContext(this, context);
window_->Show();
Expand Down
5 changes: 1 addition & 4 deletions chrome/browser/ui/views/test/view_event_test_platform_part.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace ui {
class ContextFactory;
class ContextFactoryPrivate;
} // namespace ui

// A helper class owned by tests that performs platform specific initialization.
Expand All @@ -23,9 +22,7 @@ class ViewEventTestPlatformPart {

// Set up the platform-specific environment. Teardown is performed in the
// destructor.
static ViewEventTestPlatformPart* Create(
ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private);
static ViewEventTestPlatformPart* Create(ui::ContextFactory* context_factory);

// The Widget context for creating the test window. This will be the Ash root
// window on ChromeOS environments. Otherwise it should return NULL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ namespace {
// ViewEventTestPlatformPart implementation for ChromeOS (chromeos=1).
class ViewEventTestPlatformPartChromeOS : public ViewEventTestPlatformPart {
public:
ViewEventTestPlatformPartChromeOS(
ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private);
explicit ViewEventTestPlatformPartChromeOS(
ui::ContextFactory* context_factory);
~ViewEventTestPlatformPartChromeOS() override;

// Overridden from ViewEventTestPlatformPart:
Expand All @@ -48,8 +47,7 @@ class ViewEventTestPlatformPartChromeOS : public ViewEventTestPlatformPart {
};

ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private) {
ui::ContextFactory* context_factory) {
chromeos::DBusThreadManager::Initialize();
chromeos::PowerManagerClient::InitializeFake();
// ash::Shell::CreateInstance needs chromeos::PowerPolicyController
Expand All @@ -65,7 +63,6 @@ ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
ash::ShellInitParams init_params;
init_params.delegate = std::make_unique<ash::TestShellDelegate>();
init_params.context_factory = context_factory;
init_params.context_factory_private = context_factory_private;
init_params.keyboard_ui_factory = std::make_unique<ChromeKeyboardUIFactory>();
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kHostWindowBounds, "0+0-1280x800");
Expand All @@ -92,8 +89,6 @@ ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() {

// static
ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create(
ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private) {
return new ViewEventTestPlatformPartChromeOS(context_factory,
context_factory_private);
ui::ContextFactory* context_factory) {
return new ViewEventTestPlatformPartChromeOS(context_factory);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ namespace {
// ViewEventTestPlatformPart implementation for Views, but non-CrOS.
class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart {
public:
ViewEventTestPlatformPartDefault(
ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private) {
explicit ViewEventTestPlatformPartDefault(
ui::ContextFactory* context_factory) {
#if defined(USE_AURA)
DCHECK(!display::Screen::GetScreen());
#if defined(USE_X11)
Expand All @@ -35,7 +34,6 @@ class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart {
#endif
env_ = aura::Env::CreateInstance();
env_->set_context_factory(context_factory);
env_->set_context_factory_private(context_factory_private);
#endif
}

Expand All @@ -60,8 +58,6 @@ class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart {

// static
ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create(
ui::ContextFactory* context_factory,
ui::ContextFactoryPrivate* context_factory_private) {
return new ViewEventTestPlatformPartDefault(context_factory,
context_factory_private);
ui::ContextFactory* context_factory) {
return new ViewEventTestPlatformPartDefault(context_factory);
}
2 changes: 1 addition & 1 deletion components/exo/notification_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void NotificationSurface::OnWindowRemovingFromRootWindow(
// compositor frame when showing the message center. This is to prevent
// flashes when opening the message center.
aura::Env::GetInstance()
->context_factory_private()
->context_factory()
->GetHostFrameSinkManager()
->EvictSurfaces({host_window()->GetSurfaceId()});

Expand Down
2 changes: 1 addition & 1 deletion components/exo/test/exo_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void ExoTestBase::TearDown() {

viz::SurfaceManager* ExoTestBase::GetSurfaceManager() {
return static_cast<ui::InProcessContextFactory*>(
aura::Env::GetInstance()->context_factory_private())
aura::Env::GetInstance()->context_factory())
->GetFrameSinkManager()
->surface_manager();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void SoftwareOutputDeviceOzoneTest::SetUp() {

const gfx::Size size(500, 400);
compositor_ = std::make_unique<ui::Compositor>(
FrameSinkId(1, 1), context_factories_->GetContextFactory(), nullptr,
FrameSinkId(1, 1), context_factories_->GetContextFactory(),
base::ThreadTaskRunnerHandle::Get(), false /* enable_pixel_canvas */);
compositor_->SetAcceleratedWidget(window_delegate_.GetAcceleratedWidget());
compositor_->SetScaleAndSize(1.0f, size, LocalSurfaceIdAllocation());
Expand Down
1 change: 0 additions & 1 deletion content/browser/browser_main_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ int BrowserMainLoop::BrowserThreadsStarted() {

#if defined(USE_AURA)
env_->set_context_factory(GetContextFactory());
env_->set_context_factory_private(GetContextFactoryPrivate());
#endif // defined(USE_AURA)
#endif // !defined(OS_ANDROID)

Expand Down
6 changes: 0 additions & 6 deletions content/browser/compositor/image_transport_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

namespace ui {
class ContextFactory;
class ContextFactoryPrivate;
}

namespace content {
Expand Down Expand Up @@ -40,11 +39,6 @@ class CONTENT_EXPORT ImageTransportFactory {

// Gets the image transport factory as a context factory for the compositor.
virtual ui::ContextFactory* GetContextFactory() = 0;

// Gets the image transport factory as the privileged context factory for the
// compositor. TODO(fsamuel): This interface should eventually go away once
// Mus subsumes this functionality.
virtual ui::ContextFactoryPrivate* GetContextFactoryPrivate() = 0;
};

} // namespace content
Expand Down
4 changes: 2 additions & 2 deletions content/browser/compositor/surface_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ viz::FrameSinkId AllocateFrameSinkId() {
return CompositorDependenciesAndroid::Get().AllocateFrameSinkId();
#else
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
return factory->GetContextFactoryPrivate()->AllocateFrameSinkId();
return factory->GetContextFactory()->AllocateFrameSinkId();
#endif
}

Expand All @@ -32,7 +32,7 @@ viz::HostFrameSinkManager* GetHostFrameSinkManager() {
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
if (!factory)
return nullptr;
return factory->GetContextFactoryPrivate()->GetHostFrameSinkManager();
return factory->GetContextFactory()->GetHostFrameSinkManager();
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,4 @@ ui::ContextFactory* TestImageTransportFactory::GetContextFactory() {
return this;
}

ui::ContextFactoryPrivate*
TestImageTransportFactory::GetContextFactoryPrivate() {
return this;
}

} // namespace content
Loading

0 comments on commit dc0b9fd

Please sign in to comment.