summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben <ben@chromium.org>2015-12-01 16:12:19 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-02 00:15:01 +0000
commit5a4099e1d40ab1863bedf2e18d233e99cbde333f (patch)
tree4a5af82f1e561f5d0315bb3ce309b28ab5bc9e79
parentfd54ec793fabb046e5b057027e5b7e6376a8ac8d (diff)
downloadchromium_src-5a4099e1d40ab1863bedf2e18d233e99cbde333f.zip
chromium_src-5a4099e1d40ab1863bedf2e18d233e99cbde333f.tar.gz
chromium_src-5a4099e1d40ab1863bedf2e18d233e99cbde333f.tar.bz2
Introduce mash/shell
. restarts the services that it starts if they die . moves mock_sysui -> mash/system_ui. may as well build it into the real thing. TBD: shutdown, restart loops, etc. Also looks like sadrul's code to clean up windows doesn't work for sysui. R=sky@chromium.org http://crbug.com/563733 Review URL: https://codereview.chromium.org/1492563002 Cr-Commit-Position: refs/heads/master@{#362561}
-rw-r--r--mash/example/BUILD.gn1
-rw-r--r--mash/example/main/BUILD.gn1
-rw-r--r--mash/example/main/main_application_delegate.cc3
-rw-r--r--mash/shell/BUILD.gn30
-rw-r--r--mash/shell/main.cc12
-rw-r--r--mash/shell/shell_application_delegate.cc54
-rw-r--r--mash/shell/shell_application_delegate.h50
-rw-r--r--mash/system_ui/BUILD.gn (renamed from mash/example/mock_sysui/BUILD.gn)6
-rw-r--r--mash/system_ui/main.cc (renamed from mash/example/mock_sysui/main.cc)4
-rw-r--r--mash/system_ui/system_ui.cc (renamed from mash/example/mock_sysui/mock_sysui.cc)18
-rw-r--r--mash/system_ui/system_ui.h (renamed from mash/example/mock_sysui/mock_sysui.h)20
-rw-r--r--mash/wm/BUILD.gn2
-rw-r--r--mash/wm/background_layout.cc6
-rw-r--r--mash/wm/background_layout.h1
-rw-r--r--mash/wm/shelf_layout.cc6
-rw-r--r--mash/wm/shelf_layout.h1
-rw-r--r--mash/wm/window_manager_apptest.cc2
17 files changed, 186 insertions, 31 deletions
diff --git a/mash/example/BUILD.gn b/mash/example/BUILD.gn
index 07198dd..a63760a 100644
--- a/mash/example/BUILD.gn
+++ b/mash/example/BUILD.gn
@@ -9,7 +9,6 @@ group("example") {
deps = [
"//mash/example/main",
- "//mash/example/mock_sysui",
"//mash/example/views_examples",
"//mash/example/window_type_launcher",
"//mash/wm",
diff --git a/mash/example/main/BUILD.gn b/mash/example/main/BUILD.gn
index 60c6c3c..a4e65ae 100644
--- a/mash/example/main/BUILD.gn
+++ b/mash/example/main/BUILD.gn
@@ -25,6 +25,7 @@ mojo_native_application("main") {
]
data_deps = [
+ "//mash/shell",
"//mash/example/views_examples",
"//mash/example/window_type_launcher",
]
diff --git a/mash/example/main/main_application_delegate.cc b/mash/example/main/main_application_delegate.cc
index 3ac499a..3fc15ce 100644
--- a/mash/example/main/main_application_delegate.cc
+++ b/mash/example/main/main_application_delegate.cc
@@ -12,8 +12,7 @@ MainApplicationDelegate::MainApplicationDelegate() {}
MainApplicationDelegate::~MainApplicationDelegate() {}
void MainApplicationDelegate::Initialize(mojo::ApplicationImpl* app) {
- connections_.push_back(app->ConnectToApplication("mojo:mash_wm"));
- connections_.push_back(app->ConnectToApplication("mojo:mock_sysui"));
+ connections_.push_back(app->ConnectToApplication("mojo:mash_shell"));
connections_.push_back(app->ConnectToApplication("mojo:views_examples"));
connections_.push_back(
app->ConnectToApplication("exe:window_type_launcher_exe"));
diff --git a/mash/shell/BUILD.gn b/mash/shell/BUILD.gn
new file mode 100644
index 0000000..d1ef272
--- /dev/null
+++ b/mash/shell/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/ui.gni")
+import("//mojo/public/mojo_application.gni")
+import("//mojo/public/tools/bindings/mojom.gni")
+import("//tools/grit/repack.gni")
+
+mojo_native_application("shell") {
+ output_name = "mash_shell"
+
+ sources = [
+ "main.cc",
+ "shell_application_delegate.cc",
+ "shell_application_delegate.h",
+ ]
+
+ deps = [
+ "//base",
+ "//mojo/application/public/cpp",
+ "//mojo/application/public/cpp:sources",
+ "//mojo/public/cpp/bindings",
+ ]
+
+ data_deps = [
+ "//mash/system_ui",
+ "//mash/wm",
+ ]
+}
diff --git a/mash/shell/main.cc b/mash/shell/main.cc
new file mode 100644
index 0000000..1e257b8
--- /dev/null
+++ b/mash/shell/main.cc
@@ -0,0 +1,12 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mash/shell/shell_application_delegate.h"
+#include "mojo/application/public/cpp/application_runner.h"
+#include "mojo/public/c/system/main.h"
+
+MojoResult MojoMain(MojoHandle shell_handle) {
+ mojo::ApplicationRunner runner(new mash::shell::ShellApplicationDelegate);
+ return runner.Run(shell_handle);
+}
diff --git a/mash/shell/shell_application_delegate.cc b/mash/shell/shell_application_delegate.cc
new file mode 100644
index 0000000..702adc4
--- /dev/null
+++ b/mash/shell/shell_application_delegate.cc
@@ -0,0 +1,54 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mash/shell/shell_application_delegate.h"
+
+#include "base/bind.h"
+#include "mojo/application/public/cpp/application_connection.h"
+#include "mojo/application/public/cpp/application_impl.h"
+
+namespace mash {
+namespace shell {
+
+ShellApplicationDelegate::ShellApplicationDelegate() : app_(nullptr) {}
+
+ShellApplicationDelegate::~ShellApplicationDelegate() {}
+
+void ShellApplicationDelegate::Initialize(mojo::ApplicationImpl* app) {
+ app_ = app;
+ StartWindowManager();
+ StartSystemUI();
+}
+
+bool ShellApplicationDelegate::ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) {
+ return false;
+}
+
+void ShellApplicationDelegate::StartWindowManager() {
+ StartRestartableService(
+ "mojo:desktop_wm",
+ base::Bind(&ShellApplicationDelegate::StartWindowManager,
+ base::Unretained(this)));
+}
+
+void ShellApplicationDelegate::StartSystemUI() {
+ StartRestartableService("mojo:system_ui",
+ base::Bind(&ShellApplicationDelegate::StartSystemUI,
+ base::Unretained(this)));
+}
+
+void ShellApplicationDelegate::StartRestartableService(
+ const std::string& url,
+ const base::Closure& restart_callback) {
+ // TODO(beng): This would be the place to insert logic that counted restarts
+ // to avoid infinite crash-restart loops.
+ scoped_ptr<mojo::ApplicationConnection> connection =
+ app_->ConnectToApplication(url);
+ connection->SetRemoteServiceProviderConnectionErrorHandler(restart_callback);
+ connections_[url] = std::move(connection);
+}
+
+} // namespace shell
+} // namespace main
diff --git a/mash/shell/shell_application_delegate.h b/mash/shell/shell_application_delegate.h
new file mode 100644
index 0000000..471f4a1
--- /dev/null
+++ b/mash/shell/shell_application_delegate.h
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MASH_SHELL_SHELL_APPLICATION_DELEGATE_H_
+#define MASH_SHELL_SHELL_APPLICATION_DELEGATE_H_
+
+#include <map>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "mojo/application/public/cpp/application_delegate.h"
+
+namespace mojo {
+class ApplicationConnection;
+}
+
+namespace mash {
+namespace shell {
+
+class ShellApplicationDelegate : public mojo::ApplicationDelegate {
+ public:
+ ShellApplicationDelegate();
+ ~ShellApplicationDelegate() override;
+
+ private:
+ // mojo::ApplicationDelegate:
+ void Initialize(mojo::ApplicationImpl* app) override;
+ bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) override;
+
+ void StartWindowManager();
+ void StartSystemUI();
+
+ // Starts the application at |url|, running |restart_callback| if the
+ // connection to the application is closed.
+ void StartRestartableService(const std::string& url,
+ const base::Closure& restart_callback);
+
+ mojo::ApplicationImpl* app_;
+ std::map<std::string, scoped_ptr<mojo::ApplicationConnection>> connections_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellApplicationDelegate);
+};
+
+} // namespace shell
+} // namespace mash
+
+#endif // MASH_SHELL_SHELL_APPLICATION_DELEGATE_H_
diff --git a/mash/example/mock_sysui/BUILD.gn b/mash/system_ui/BUILD.gn
index 2e8305e..f8c4cc4 100644
--- a/mash/example/mock_sysui/BUILD.gn
+++ b/mash/system_ui/BUILD.gn
@@ -6,11 +6,11 @@ import("//build/config/ui.gni")
import("//mojo/public/mojo_application.gni")
import("//mojo/public/tools/bindings/mojom.gni")
-mojo_native_application("mock_sysui") {
+mojo_native_application("system_ui") {
sources = [
"main.cc",
- "mock_sysui.cc",
- "mock_sysui.h",
+ "system_ui.cc",
+ "system_ui.h",
]
deps = [
diff --git a/mash/example/mock_sysui/main.cc b/mash/system_ui/main.cc
index 44d00e9..d36c2e0 100644
--- a/mash/example/mock_sysui/main.cc
+++ b/mash/system_ui/main.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mash/example/mock_sysui/mock_sysui.h"
+#include "mash/system_ui/system_ui.h"
#include "mojo/application/public/cpp/application_runner.h"
#include "mojo/public/c/system/main.h"
MojoResult MojoMain(MojoHandle shell_handle) {
- mojo::ApplicationRunner runner(new MockSysUI);
+ mojo::ApplicationRunner runner(new mash::system_ui::SystemUI);
return runner.Run(shell_handle);
}
diff --git a/mash/example/mock_sysui/mock_sysui.cc b/mash/system_ui/system_ui.cc
index 57146b8..117e5a3 100644
--- a/mash/example/mock_sysui/mock_sysui.cc
+++ b/mash/system_ui/system_ui.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mash/example/mock_sysui/mock_sysui.h"
+#include "mash/system_ui/system_ui.h"
#include "components/mus/public/cpp/property_type_converters.h"
#include "mash/wm/public/interfaces/container.mojom.h"
@@ -14,6 +14,9 @@
#include "ui/views/mus/window_manager_connection.h"
#include "ui/views/widget/widget_delegate.h"
+namespace mash {
+namespace system_ui {
+
namespace {
class DesktopBackground : public views::WidgetDelegateView {
@@ -89,12 +92,12 @@ class Shelf : public views::WidgetDelegateView {
} // namespace
-MockSysUI::MockSysUI() {}
+SystemUI::SystemUI() {}
-MockSysUI::~MockSysUI() {
+SystemUI::~SystemUI() {
}
-void MockSysUI::Initialize(mojo::ApplicationImpl* app) {
+void SystemUI::Initialize(mojo::ApplicationImpl* app) {
tracing_.Initialize(app);
aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak"));
@@ -104,7 +107,10 @@ void MockSysUI::Initialize(mojo::ApplicationImpl* app) {
Shelf::Create(app->shell());
}
-bool MockSysUI::ConfigureIncomingConnection(
+bool SystemUI::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
- return false;
+ return true;
}
+
+} // namespace system_ui
+} // namespace mash
diff --git a/mash/example/mock_sysui/mock_sysui.h b/mash/system_ui/system_ui.h
index 23e068b..ffab417 100644
--- a/mash/example/mock_sysui/mock_sysui.h
+++ b/mash/system_ui/system_ui.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MASH_EXAMPLE_MOCK_SYSUI_MOCK_SYSUI_H_
-#define MASH_EXAMPLE_MOCK_SYSUI_MOCK_SYSUI_H_
+#ifndef MASH_SYSTEM_UI_SYSTEM_UI_H_
+#define MASH_SYSTEM_UI_SYSTEM_UI_H_
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
@@ -14,10 +14,13 @@ namespace views {
class AuraInit;
}
-class MockSysUI : public mojo::ApplicationDelegate {
+namespace mash {
+namespace system_ui {
+
+class SystemUI : public mojo::ApplicationDelegate {
public:
- MockSysUI();
- ~MockSysUI() override;
+ SystemUI();
+ ~SystemUI() override;
private:
// mojo::ApplicationDelegate:
@@ -29,7 +32,10 @@ class MockSysUI : public mojo::ApplicationDelegate {
scoped_ptr<views::AuraInit> aura_init_;
- DISALLOW_COPY_AND_ASSIGN(MockSysUI);
+ DISALLOW_COPY_AND_ASSIGN(SystemUI);
};
-#endif // MASH_EXAMPLE_MOCK_SYSUI_MOCK_SYSUI_H_
+} // namespace system_ui
+} // namespace mash
+
+#endif // MASH_SYSTEM_UI_SYSTEM_UI_H_
diff --git a/mash/wm/BUILD.gn b/mash/wm/BUILD.gn
index 30f27cc7..e9ca51e 100644
--- a/mash/wm/BUILD.gn
+++ b/mash/wm/BUILD.gn
@@ -78,7 +78,7 @@ source_set("lib") {
}
mojo_native_application("wm") {
- output_name = "mash_wm"
+ output_name = "desktop_wm"
sources = [
"main.cc",
diff --git a/mash/wm/background_layout.cc b/mash/wm/background_layout.cc
index da6e193..93c085a 100644
--- a/mash/wm/background_layout.cc
+++ b/mash/wm/background_layout.cc
@@ -12,9 +12,9 @@ namespace wm {
BackgroundLayout::BackgroundLayout(mus::Window* owner) : LayoutManager(owner) {}
BackgroundLayout::~BackgroundLayout() {}
-void BackgroundLayout::WindowAdded(mus::Window* window) {
- DCHECK_EQ(owner()->children().size(), 1U);
-}
+// We explicitly don't make assertions about the number of children in this
+// layout as the number of children can vary when the application providing the
+// background restarts.
void BackgroundLayout::LayoutWindow(mus::Window* window) {
window->SetBounds(gfx::Rect(owner()->bounds().size()));
diff --git a/mash/wm/background_layout.h b/mash/wm/background_layout.h
index 75a41f5..40c2a35 100644
--- a/mash/wm/background_layout.h
+++ b/mash/wm/background_layout.h
@@ -19,7 +19,6 @@ class BackgroundLayout : public LayoutManager {
private:
// Overridden from LayoutManager:
- void WindowAdded(mus::Window* window) override;
void LayoutWindow(mus::Window* window) override;
DISALLOW_COPY_AND_ASSIGN(BackgroundLayout);
diff --git a/mash/wm/shelf_layout.cc b/mash/wm/shelf_layout.cc
index cdabe53..1b341cc 100644
--- a/mash/wm/shelf_layout.cc
+++ b/mash/wm/shelf_layout.cc
@@ -18,9 +18,9 @@ ShelfLayout::ShelfLayout(mus::Window* owner) : LayoutManager(owner) {
}
ShelfLayout::~ShelfLayout() {}
-void ShelfLayout::WindowAdded(mus::Window* window) {
- DCHECK_EQ(owner()->children().size(), 1U);
-}
+// We explicitly don't make assertions about the number of children in this
+// layout as the number of children can vary when the application providing the
+// shelf restarts.
void ShelfLayout::LayoutWindow(mus::Window* window) {
gfx::Size preferred_size = GetWindowPreferredSize(window);
diff --git a/mash/wm/shelf_layout.h b/mash/wm/shelf_layout.h
index 0a82e32..44f3182 100644
--- a/mash/wm/shelf_layout.h
+++ b/mash/wm/shelf_layout.h
@@ -19,7 +19,6 @@ class ShelfLayout : public LayoutManager {
private:
// Overridden from LayoutManager:
- void WindowAdded(mus::Window* window) override;
void LayoutWindow(mus::Window* window) override;
DISALLOW_COPY_AND_ASSIGN(ShelfLayout);
diff --git a/mash/wm/window_manager_apptest.cc b/mash/wm/window_manager_apptest.cc
index 15584af..5e235fc 100644
--- a/mash/wm/window_manager_apptest.cc
+++ b/mash/wm/window_manager_apptest.cc
@@ -22,7 +22,7 @@ class WindowManagerAppTest : public mojo::test::ApplicationTestBase,
protected:
void ConnectToWindowManager(mus::mojom::WindowManagerPtr* window_manager) {
- application_impl()->ConnectToService("mojo:mash_wm", window_manager);
+ application_impl()->ConnectToService("mojo:desktop_wm", window_manager);
}
mus::Window* OpenWindow(mus::mojom::WindowManager* window_manager) {