Commit 01c007bd authored by sky's avatar sky Committed by Commit bot

chromeos: makes WindowManager not delete shell when connection to mus is lost

Chrome also detects when the connection to mus is lost and further
chrome needs to control when the shell it shutdown, so adds the option
to set a callback that controls what should happen when connection to
mus is lost.

I think there is more that needs to happen, but this is a good start.

BUG=709593
TEST=covered by tests
R=jonross@chromium.org

Review-Url: https://codereview.chromium.org/2846893004
Cr-Commit-Position: refs/heads/master@{#468013}
parent 52a0bdcd
...@@ -155,6 +155,10 @@ void WindowManager::Init( ...@@ -155,6 +155,10 @@ void WindowManager::Init(
shell_delegate_ = std::move(shell_delegate); shell_delegate_ = std::move(shell_delegate);
} }
void WindowManager::SetLostConnectionCallback(base::OnceClosure closure) {
lost_connection_callback_ = std::move(closure);
}
bool WindowManager::WaitForInitialDisplays() { bool WindowManager::WaitForInitialDisplays() {
return window_manager_client_->WaitForInitialDisplays(); return window_manager_client_->WaitForInitialDisplays();
} }
...@@ -309,6 +313,10 @@ void WindowManager::OnEmbedRootDestroyed( ...@@ -309,6 +313,10 @@ void WindowManager::OnEmbedRootDestroyed(
void WindowManager::OnLostConnection(aura::WindowTreeClient* client) { void WindowManager::OnLostConnection(aura::WindowTreeClient* client) {
DCHECK_EQ(client, window_tree_client_.get()); DCHECK_EQ(client, window_tree_client_.get());
if (!lost_connection_callback_.is_null()) {
base::ResetAndReturn(&lost_connection_callback_).Run();
return;
}
Shutdown(); Shutdown();
// TODO(sky): this case should trigger shutting down WindowManagerApplication // TODO(sky): this case should trigger shutting down WindowManagerApplication
// too. // too.
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "services/ui/common/types.h" #include "services/ui/common/types.h"
...@@ -74,6 +75,10 @@ class WindowManager : public aura::WindowManagerDelegate, ...@@ -74,6 +75,10 @@ class WindowManager : public aura::WindowManagerDelegate,
const scoped_refptr<base::SequencedWorkerPool>& blocking_pool, const scoped_refptr<base::SequencedWorkerPool>& blocking_pool,
std::unique_ptr<ash::ShellDelegate> shell_delegate = nullptr); std::unique_ptr<ash::ShellDelegate> shell_delegate = nullptr);
// Sets the callback that is run once the connection to mus is lost. If not
// set shutdown occurs when the connection is lost (the Shell is deleted).
void SetLostConnectionCallback(base::OnceClosure closure);
// Blocks waiting for the initial set of displays. // Blocks waiting for the initial set of displays.
bool WaitForInitialDisplays(); bool WaitForInitialDisplays();
...@@ -197,6 +202,8 @@ class WindowManager : public aura::WindowManagerDelegate, ...@@ -197,6 +202,8 @@ class WindowManager : public aura::WindowManagerDelegate,
const Config config_; const Config config_;
base::OnceClosure lost_connection_callback_;
std::unique_ptr<::wm::WMState> wm_state_; std::unique_ptr<::wm::WMState> wm_state_;
std::unique_ptr<aura::PropertyConverter> property_converter_; std::unique_ptr<aura::PropertyConverter> property_converter_;
......
...@@ -67,6 +67,11 @@ std::unique_ptr<ash::mus::WindowManager> CreateMusShell() { ...@@ -67,6 +67,11 @@ std::unique_ptr<ash::mus::WindowManager> CreateMusShell() {
content::ServiceManagerConnection::GetForProcess()->GetConnector(); content::ServiceManagerConnection::GetForProcess()->GetConnector();
std::unique_ptr<ash::mus::WindowManager> window_manager = std::unique_ptr<ash::mus::WindowManager> window_manager =
base::MakeUnique<ash::mus::WindowManager>(connector, ash::Config::MUS); base::MakeUnique<ash::mus::WindowManager>(connector, ash::Config::MUS);
// The WindowManager normally deletes the Shell when it loses its connection
// to mus. Disable that by installing an empty callback. Chrome installs
// its own callback to detect when the connection to mus is lost and that is
// what shuts everything down.
window_manager->SetLostConnectionCallback(base::BindOnce(&base::DoNothing));
std::unique_ptr<aura::WindowTreeClient> window_tree_client = std::unique_ptr<aura::WindowTreeClient> window_tree_client =
base::MakeUnique<aura::WindowTreeClient>(connector, window_manager.get(), base::MakeUnique<aura::WindowTreeClient>(connector, window_manager.get(),
window_manager.get()); window_manager.get());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment