summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben <ben@chromium.org>2016-02-25 23:30:25 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-26 07:31:39 +0000
commite4a2bc4fb161d8d2ea673d5f55119d36be2cf06f (patch)
treea09be63e6724713539bd7065ecdcb38b0233a73e
parent0d78506780d9bf1e5e80a0bfca6099a80fd355e0 (diff)
downloadchromium_src-e4a2bc4fb161d8d2ea673d5f55119d36be2cf06f.zip
chromium_src-e4a2bc4fb161d8d2ea673d5f55119d36be2cf06f.tar.gz
chromium_src-e4a2bc4fb161d8d2ea673d5f55119d36be2cf06f.tar.bz2
Replace with mojo::Connector (already exists) now that Shell is gone.
Requires: - Move AppRefCount to a different class, MessageLoopRef, which is optionally used by applications that wish to quit the current message loop started by application runner when the ref drops to zero. - Changing the signature of Initialize() to take a Connector. This is what most of the change in this CL is. BUG= Review URL: https://codereview.chromium.org/1725353003 Cr-Commit-Position: refs/heads/master@{#377841}
-rw-r--r--ash/mus/keyboard_ui_mus.cc10
-rw-r--r--ash/mus/keyboard_ui_mus.h6
-rw-r--r--ash/mus/shelf_delegate_mus.cc7
-rw-r--r--ash/mus/sysui_application.cc13
-rw-r--r--ash/mus/sysui_application.h2
-rw-r--r--chrome/app/mash/mash_runner.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_mus.cc2
-rw-r--r--components/bitmap_uploader/bitmap_uploader.cc6
-rw-r--r--components/bitmap_uploader/bitmap_uploader.h4
-rw-r--r--components/filesystem/file_system_app.cc11
-rw-r--r--components/filesystem/file_system_app.h5
-rw-r--r--components/filesystem/files_test_base.cc4
-rw-r--r--components/filesystem/public/cpp/prefs/pref_service_factory.cc6
-rw-r--r--components/filesystem/public/cpp/prefs/pref_service_factory.h4
-rw-r--r--components/font_service/font_service_app.cc5
-rw-r--r--components/font_service/font_service_app.h2
-rw-r--r--components/font_service/public/cpp/font_loader.cc6
-rw-r--r--components/font_service/public/cpp/font_loader.h4
-rw-r--r--components/leveldb/leveldb_app.cc4
-rw-r--r--components/leveldb/leveldb_app.h2
-rw-r--r--components/leveldb/leveldb_apptest.cc4
-rw-r--r--components/mus/mus_app.cc20
-rw-r--r--components/mus/mus_app.h8
-rw-r--r--components/mus/public/cpp/lib/window_tree_client_impl.cc10
-rw-r--r--components/mus/public/cpp/lib/window_tree_client_impl.h2
-rw-r--r--components/mus/public/cpp/lib/window_tree_host_factory.cc6
-rw-r--r--components/mus/public/cpp/tests/window_server_test_base.cc4
-rw-r--r--components/mus/public/cpp/window_tree_connection.h4
-rw-r--r--components/mus/public/cpp/window_tree_host_factory.h4
-rw-r--r--components/mus/ws/display_manager.cc12
-rw-r--r--components/mus/ws/display_manager.h8
-rw-r--r--components/mus/ws/display_manager_factory.h4
-rw-r--r--components/mus/ws/window_manager_client_apptest.cc4
-rw-r--r--components/mus/ws/window_tree_apptest.cc16
-rw-r--r--components/mus/ws/window_tree_host_impl.cc4
-rw-r--r--components/mus/ws/window_tree_host_impl.h2
-rw-r--r--components/mus/ws/window_tree_unittest.cc2
-rw-r--r--components/resource_provider/public/cpp/resource_loader.cc6
-rw-r--r--components/resource_provider/public/cpp/resource_loader.h5
-rw-r--r--components/resource_provider/resource_provider_app.cc5
-rw-r--r--components/resource_provider/resource_provider_app.h6
-rw-r--r--components/resource_provider/resource_provider_apptest.cc2
-rw-r--r--content/browser/browser_main_loop.cc3
-rw-r--r--content/browser/mojo/mojo_shell_client_host.cc4
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mus.cc4
-rw-r--r--content/common/mojo/mojo_shell_connection_impl.cc6
-rw-r--r--content/common/mojo/mojo_shell_connection_impl.h4
-rw-r--r--content/public/common/mojo_shell_connection.h5
-rw-r--r--content/public/test/test_mojo_app.cc13
-rw-r--r--content/public/test/test_mojo_app.h5
-rw-r--r--content/renderer/mus/render_widget_mus_connection.cc6
-rw-r--r--mash/browser_driver/browser_driver_application_delegate.cc12
-rw-r--r--mash/browser_driver/browser_driver_application_delegate.h4
-rw-r--r--mash/example/views_examples/views_examples_application_delegate.cc10
-rw-r--r--mash/example/views_examples/views_examples_application_delegate.h2
-rw-r--r--mash/example/window_type_launcher/window_type_launcher.cc19
-rw-r--r--mash/example/window_type_launcher/window_type_launcher.h2
-rw-r--r--mash/quick_launch/quick_launch_application.cc20
-rw-r--r--mash/quick_launch/quick_launch_application.h2
-rw-r--r--mash/screenlock/screenlock.cc29
-rw-r--r--mash/screenlock/screenlock.h3
-rw-r--r--mash/shell/shell_application_delegate.cc10
-rw-r--r--mash/shell/shell_application_delegate.h4
-rw-r--r--mash/task_viewer/task_viewer.cc23
-rw-r--r--mash/task_viewer/task_viewer.h2
-rw-r--r--mash/wm/accelerator_registrar_apptest.cc2
-rw-r--r--mash/wm/non_client_frame_controller.cc8
-rw-r--r--mash/wm/non_client_frame_controller.h4
-rw-r--r--mash/wm/root_window_controller.cc10
-rw-r--r--mash/wm/root_window_controller.h4
-rw-r--r--mash/wm/window_manager.cc2
-rw-r--r--mash/wm/window_manager_application.cc14
-rw-r--r--mash/wm/window_manager_application.h6
-rw-r--r--mash/wm/window_manager_apptest.cc4
-rw-r--r--media/mojo/services/media_apptest.cc2
-rw-r--r--media/mojo/services/mojo_media_application.cc10
-rw-r--r--media/mojo/services/mojo_media_application.h8
-rw-r--r--media/mojo/services/service_factory_impl.cc2
-rw-r--r--media/mojo/services/service_factory_impl.h9
-rw-r--r--media/test/pipeline_integration_test.cc2
-rw-r--r--mojo/public/cpp/bindings/tests/versioning_apptest.cc4
-rw-r--r--mojo/services/network/cookie_store_impl.cc2
-rw-r--r--mojo/services/network/cookie_store_impl.h6
-rw-r--r--mojo/services/network/http_server_apptest.cc2
-rw-r--r--mojo/services/network/http_server_impl.cc4
-rw-r--r--mojo/services/network/http_server_impl.h8
-rw-r--r--mojo/services/network/network_service_delegate.cc38
-rw-r--r--mojo/services/network/network_service_delegate.h13
-rw-r--r--mojo/services/network/network_service_impl.cc2
-rw-r--r--mojo/services/network/network_service_impl.h6
-rw-r--r--mojo/services/network/tcp_bound_socket_impl.cc2
-rw-r--r--mojo/services/network/tcp_bound_socket_impl.h6
-rw-r--r--mojo/services/network/tcp_connected_socket_impl.cc2
-rw-r--r--mojo/services/network/tcp_connected_socket_impl.h6
-rw-r--r--mojo/services/network/tcp_server_socket_impl.cc2
-rw-r--r--mojo/services/network/tcp_server_socket_impl.h6
-rw-r--r--mojo/services/network/udp_socket_apptest.cc2
-rw-r--r--mojo/services/network/udp_socket_impl.cc2
-rw-r--r--mojo/services/network/udp_socket_impl.h6
-rw-r--r--mojo/services/network/url_loader_factory_impl.cc2
-rw-r--r--mojo/services/network/url_loader_factory_impl.h6
-rw-r--r--mojo/services/network/url_loader_impl.cc2
-rw-r--r--mojo/services/network/url_loader_impl.h6
-rw-r--r--mojo/services/network/url_loader_impl_apptest.cc3
-rw-r--r--mojo/services/network/web_socket_factory_impl.cc2
-rw-r--r--mojo/services/network/web_socket_factory_impl.h6
-rw-r--r--mojo/services/network/web_socket_impl.cc2
-rw-r--r--mojo/services/network/web_socket_impl.h6
-rw-r--r--mojo/services/package_manager/package_manager.cc3
-rw-r--r--mojo/services/package_manager/package_manager.h3
-rw-r--r--mojo/services/test_service/test_request_tracker_application.cc9
-rw-r--r--mojo/services/test_service/test_request_tracker_application.h4
-rw-r--r--mojo/services/test_service/test_service_application.cc11
-rw-r--r--mojo/services/test_service/test_service_application.h4
-rw-r--r--mojo/services/test_service/test_service_impl.cc10
-rw-r--r--mojo/services/test_service/test_service_impl.h6
-rw-r--r--mojo/services/test_service/test_time_service_impl.cc8
-rw-r--r--mojo/services/test_service/test_time_service_impl.h6
-rw-r--r--mojo/services/tracing/public/cpp/tracing_impl.cc6
-rw-r--r--mojo/services/tracing/public/cpp/tracing_impl.h4
-rw-r--r--mojo/services/tracing/tracing_app.cc5
-rw-r--r--mojo/services/tracing/tracing_app.h1
-rw-r--r--mojo/shell/background/tests/background_shell_unittest.cc5
-rw-r--r--mojo/shell/background/tests/test_service.cc4
-rw-r--r--mojo/shell/public/cpp/BUILD.gn2
-rw-r--r--mojo/shell/public/cpp/application_test_base.h13
-rw-r--r--mojo/shell/public/cpp/lib/message_loop_ref.cc98
-rw-r--r--mojo/shell/public/cpp/lib/shell_client.cc4
-rw-r--r--mojo/shell/public/cpp/lib/shell_connection.cc114
-rw-r--r--mojo/shell/public/cpp/message_loop_ref.h57
-rw-r--r--mojo/shell/public/cpp/shell.h58
-rw-r--r--mojo/shell/public/cpp/shell_client.h16
-rw-r--r--mojo/shell/public/cpp/shell_connection.h23
-rw-r--r--mojo/shell/runner/child/native_apptest.cc4
-rw-r--r--mojo/shell/runner/child/native_apptest_target.cc3
-rw-r--r--mojo/shell/tests/application_manager_apptest.cc8
-rw-r--r--mojo/shell/tests/application_manager_apptest_driver.cc13
-rw-r--r--mojo/shell/tests/application_manager_apptest_target.cc6
-rw-r--r--mojo/shell/tests/application_manager_unittest.cc7
-rw-r--r--mojo/shell/tests/capability_filter_test.cc19
-rw-r--r--mojo/shell/tests/capability_filter_test.h4
-rw-r--r--mojo/shell/tests/package_apptest.cc8
-rw-r--r--mojo/shell/tests/package_test_package.cc26
-rw-r--r--ui/views/mus/aura_init.cc12
-rw-r--r--ui/views/mus/aura_init.h6
-rw-r--r--ui/views/mus/native_widget_mus.cc6
-rw-r--r--ui/views/mus/native_widget_mus.h4
-rw-r--r--ui/views/mus/platform_test_helper_mus.cc7
-rw-r--r--ui/views/mus/platform_window_mus.cc4
-rw-r--r--ui/views/mus/platform_window_mus.h4
-rw-r--r--ui/views/mus/screen_mus.cc6
-rw-r--r--ui/views/mus/screen_mus.h4
-rw-r--r--ui/views/mus/surface_binding.cc23
-rw-r--r--ui/views/mus/surface_binding.h4
-rw-r--r--ui/views/mus/surface_context_factory.cc4
-rw-r--r--ui/views/mus/surface_context_factory.h4
-rw-r--r--ui/views/mus/window_manager_connection.cc16
-rw-r--r--ui/views/mus/window_manager_connection.h10
-rw-r--r--ui/views/mus/window_tree_host_mus.cc4
-rw-r--r--ui/views/mus/window_tree_host_mus.h4
160 files changed, 663 insertions, 709 deletions
diff --git a/ash/mus/keyboard_ui_mus.cc b/ash/mus/keyboard_ui_mus.cc
index f8a1ab7..1a16aae 100644
--- a/ash/mus/keyboard_ui_mus.cc
+++ b/ash/mus/keyboard_ui_mus.cc
@@ -7,22 +7,22 @@
#include "ash/keyboard/keyboard_ui_observer.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace ash {
-KeyboardUIMus::KeyboardUIMus(mojo::Shell* mojo_shell)
+KeyboardUIMus::KeyboardUIMus(mojo::Connector* connector)
: is_enabled_(false), observer_binding_(this) {
// TODO(sky): should be something like mojo://keyboard, but need mapping.
- mojo_shell->ConnectToInterface("exe://chrome", &keyboard_);
+ connector->ConnectToInterface("exe://chrome", &keyboard_);
keyboard_->AddObserver(observer_binding_.CreateInterfacePtrAndBind());
}
KeyboardUIMus::~KeyboardUIMus() {}
// static
-scoped_ptr<KeyboardUI> KeyboardUIMus::Create(mojo::Shell* mojo_shell) {
- return make_scoped_ptr(new KeyboardUIMus(mojo_shell));
+scoped_ptr<KeyboardUI> KeyboardUIMus::Create(mojo::Connector* connector) {
+ return make_scoped_ptr(new KeyboardUIMus(connector));
}
void KeyboardUIMus::Hide() {
diff --git a/ash/mus/keyboard_ui_mus.h b/ash/mus/keyboard_ui_mus.h
index 3ebf826..c7bcb24 100644
--- a/ash/mus/keyboard_ui_mus.h
+++ b/ash/mus/keyboard_ui_mus.h
@@ -11,7 +11,7 @@
#include "ui/keyboard/keyboard.mojom.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace ash {
@@ -19,10 +19,10 @@ namespace ash {
class KeyboardUIMus : public KeyboardUI,
public keyboard::mojom::KeyboardObserver {
public:
- explicit KeyboardUIMus(mojo::Shell* mojo_shell);
+ explicit KeyboardUIMus(mojo::Connector* connector);
~KeyboardUIMus() override;
- static scoped_ptr<KeyboardUI> Create(mojo::Shell* mojo_shell);
+ static scoped_ptr<KeyboardUI> Create(mojo::Connector* connector);
// KeyboardUI:
void Hide() override;
diff --git a/ash/mus/shelf_delegate_mus.cc b/ash/mus/shelf_delegate_mus.cc
index d75f85a..c405fb7 100644
--- a/ash/mus/shelf_delegate_mus.cc
+++ b/ash/mus/shelf_delegate_mus.cc
@@ -16,7 +16,7 @@
#include "components/mus/public/cpp/window.h"
#include "components/mus/public/cpp/window_property.h"
#include "mojo/common/common_type_converters.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/aura/mus/mus_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/resources/grit/ui_resources.h"
@@ -90,8 +90,9 @@ class ShelfItemDelegateMus : public ShelfItemDelegate {
ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model)
: model_(model), binding_(this) {
- mojo::Shell* shell = views::WindowManagerConnection::Get()->shell();
- shell->ConnectToInterface("mojo:desktop_wm", &user_window_controller_);
+ mojo::Connector* connector =
+ views::WindowManagerConnection::Get()->connector();
+ connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_);
user_window_controller_->AddUserWindowObserver(
binding_.CreateInterfacePtrAndBind());
}
diff --git a/ash/mus/sysui_application.cc b/ash/mus/sysui_application.cc
index 361821b..c55482a 100644
--- a/ash/mus/sysui_application.cc
+++ b/ash/mus/sysui_application.cc
@@ -174,9 +174,9 @@ class AshInit {
aura::Window* root() { return ash::Shell::GetPrimaryRootWindow(); }
- void Initialize(mojo::Shell* shell) {
- aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak"));
- views::WindowManagerConnection::Create(shell);
+ void Initialize(mojo::Connector* connector) {
+ aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
+ views::WindowManagerConnection::Create(connector);
gfx::Screen* screen = gfx::Screen::GetScreen();
DCHECK(screen);
@@ -201,7 +201,8 @@ class AshInit {
init_params.context_factory = new StubContextFactory;
init_params.blocking_pool = worker_pool_.get();
init_params.in_mus = true;
- init_params.keyboard_factory = base::Bind(&KeyboardUIMus::Create, shell);
+ init_params.keyboard_factory =
+ base::Bind(&KeyboardUIMus::Create, connector);
ash::Shell::CreateInstance(init_params);
ash::Shell::GetInstance()->CreateShelf();
ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(
@@ -276,12 +277,12 @@ SysUIApplication::SysUIApplication() {}
SysUIApplication::~SysUIApplication() {}
-void SysUIApplication::Initialize(mojo::Shell* shell,
+void SysUIApplication::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
ash_init_.reset(new AshInit());
- ash_init_->Initialize(shell);
+ ash_init_->Initialize(connector);
}
bool SysUIApplication::AcceptConnection(mojo::Connection* connection) {
diff --git a/ash/mus/sysui_application.h b/ash/mus/sysui_application.h
index c09804e..c597651 100644
--- a/ash/mus/sysui_application.h
+++ b/ash/mus/sysui_application.h
@@ -22,7 +22,7 @@ class SysUIApplication : public mojo::ShellClient {
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell,
+ void Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) override;
diff --git a/chrome/app/mash/mash_runner.cc b/chrome/app/mash/mash_runner.cc
index c8804d3..3dc916d 100644
--- a/chrome/app/mash/mash_runner.cc
+++ b/chrome/app/mash/mash_runner.cc
@@ -24,6 +24,7 @@
#include "mojo/shell/background/background_shell.h"
#include "mojo/shell/identity.h"
#include "mojo/shell/native_runner_delegate.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "mojo/shell/public/interfaces/shell_client_factory.mojom.h"
@@ -190,8 +191,7 @@ void MashRunner::RunMain() {
shell_client_.get(),
background_shell.CreateShellClientRequest(GURL("exe:chrome_mash"))));
shell_connection_->WaitForInitialize();
- static_cast<mojo::Shell*>(shell_connection_.get())
- ->Connect("mojo:mash_shell");
+ shell_connection_->connector()->Connect("mojo:mash_shell");
base::MessageLoop::current()->Run();
}
diff --git a/chrome/browser/ui/views/frame/browser_frame_mus.cc b/chrome/browser/ui/views/frame/browser_frame_mus.cc
index 8975f16..e0b2030 100644
--- a/chrome/browser/ui/views/frame/browser_frame_mus.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_mus.cc
@@ -35,7 +35,7 @@ BrowserFrameMus::BrowserFrameMus(BrowserFrame* browser_frame,
BrowserView* browser_view)
: views::NativeWidgetMus(
browser_frame,
- views::WindowManagerConnection::Get()->shell(),
+ views::WindowManagerConnection::Get()->connector(),
CreateMusWindow(browser_view),
mus::mojom::SurfaceType::DEFAULT),
browser_view_(browser_view) {}
diff --git a/components/bitmap_uploader/bitmap_uploader.cc b/components/bitmap_uploader/bitmap_uploader.cc
index 8a3a80f..acca97b 100644
--- a/components/bitmap_uploader/bitmap_uploader.cc
+++ b/components/bitmap_uploader/bitmap_uploader.cc
@@ -16,7 +16,7 @@
#include "mojo/converters/surfaces/surfaces_utils.h"
#include "mojo/public/c/gles2/chromium_extension.h"
#include "mojo/public/c/gles2/gles2.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace bitmap_uploader {
namespace {
@@ -46,11 +46,11 @@ BitmapUploader::~BitmapUploader() {
MojoGLES2DestroyContext(gles2_context_);
}
-void BitmapUploader::Init(mojo::Shell* shell) {
+void BitmapUploader::Init(mojo::Connector* connector) {
surface_ = window_->RequestSurface(mus::mojom::SurfaceType::DEFAULT);
surface_->BindToThread();
- shell->ConnectToInterface("mojo:mus", &gpu_service_);
+ connector->ConnectToInterface("mojo:mus", &gpu_service_);
mus::mojom::CommandBufferPtr gles2_client;
gpu_service_->CreateOffscreenGLES2Context(GetProxy(&gles2_client));
gles2_context_ = MojoGLES2CreateContext(
diff --git a/components/bitmap_uploader/bitmap_uploader.h b/components/bitmap_uploader/bitmap_uploader.h
index cee37d6..65162ac 100644
--- a/components/bitmap_uploader/bitmap_uploader.h
+++ b/components/bitmap_uploader/bitmap_uploader.h
@@ -19,7 +19,7 @@
#include "mojo/public/c/gles2/gles2.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace bitmap_uploader {
@@ -34,7 +34,7 @@ class BITMAP_UPLOADER_EXPORT BitmapUploader
explicit BitmapUploader(mus::Window* window);
~BitmapUploader() override;
- void Init(mojo::Shell* shell);
+ void Init(mojo::Connector* connector);
// Sets the color which is RGBA.
void SetColor(uint32_t color);
diff --git a/components/filesystem/file_system_app.cc b/components/filesystem/file_system_app.cc
index 0de2211..8bb5354 100644
--- a/components/filesystem/file_system_app.cc
+++ b/components/filesystem/file_system_app.cc
@@ -8,7 +8,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#if defined(OS_WIN)
#include "base/base_paths_win.h"
@@ -33,15 +33,14 @@ const char kUserDataDir[] = "user-data-dir";
} // namespace filesystem
-FileSystemApp::FileSystemApp()
- : shell_(nullptr), lock_table_(new LockTable) {}
+FileSystemApp::FileSystemApp() : lock_table_(new LockTable) {}
FileSystemApp::~FileSystemApp() {}
-void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url,
+void FileSystemApp::Initialize(mojo::Connector* connector,
+ const std::string& url,
uint32_t id, uint32_t user_id) {
- shell_ = shell;
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
}
bool FileSystemApp::AcceptConnection(mojo::Connection* connection) {
diff --git a/components/filesystem/file_system_app.h b/components/filesystem/file_system_app.h
index 3279415..f71eae9 100644
--- a/components/filesystem/file_system_app.h
+++ b/components/filesystem/file_system_app.h
@@ -15,7 +15,7 @@
#include "mojo/shell/public/cpp/shell_client.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace filesystem {
@@ -31,7 +31,7 @@ class FileSystemApp : public mojo::ShellClient,
static base::FilePath GetUserDataDir();
// |mojo::ShellClient| override:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
@@ -39,7 +39,6 @@ class FileSystemApp : public mojo::ShellClient,
void Create(mojo::Connection* connection,
mojo::InterfaceRequest<FileSystem> request) override;
- mojo::Shell* shell_;
mojo::TracingImpl tracing_;
scoped_ptr<LockTable> lock_table_;
diff --git a/components/filesystem/files_test_base.cc b/components/filesystem/files_test_base.cc
index d47be02..15399c3 100644
--- a/components/filesystem/files_test_base.cc
+++ b/components/filesystem/files_test_base.cc
@@ -8,7 +8,7 @@
#include "components/filesystem/public/interfaces/directory.mojom.h"
#include "components/filesystem/public/interfaces/types.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/util/capture_util.h"
namespace filesystem {
@@ -21,7 +21,7 @@ FilesTestBase::~FilesTestBase() {
void FilesTestBase::SetUp() {
ApplicationTestBase::SetUp();
- shell()->ConnectToInterface("mojo:filesystem", &files_);
+ connector()->ConnectToInterface("mojo:filesystem", &files_);
}
void FilesTestBase::GetTemporaryRoot(DirectoryPtr* directory) {
diff --git a/components/filesystem/public/cpp/prefs/pref_service_factory.cc b/components/filesystem/public/cpp/prefs/pref_service_factory.cc
index 5c75bb6..add4532 100644
--- a/components/filesystem/public/cpp/prefs/pref_service_factory.cc
+++ b/components/filesystem/public/cpp/prefs/pref_service_factory.cc
@@ -12,7 +12,7 @@
#include "components/prefs/pref_value_store.h"
#include "components/prefs/value_map_pref_store.h"
#include "components/prefs/writeable_pref_store.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace filesystem {
@@ -23,10 +23,10 @@ void DoNothingHandleReadError(PersistentPrefStore::PrefReadError error) {}
} // namespace
-scoped_ptr<PrefService> CreatePrefService(mojo::Shell* shell,
+scoped_ptr<PrefService> CreatePrefService(mojo::Connector* connector,
PrefRegistry* pref_registry) {
filesystem::FileSystemPtr filesystem;
- shell->ConnectToInterface("mojo:filesystem", &filesystem);
+ connector->ConnectToInterface("mojo:filesystem", &filesystem);
scoped_refptr<FilesystemJsonPrefStore> user_prefs =
new FilesystemJsonPrefStore("preferences.json", std::move(filesystem),
diff --git a/components/filesystem/public/cpp/prefs/pref_service_factory.h b/components/filesystem/public/cpp/prefs/pref_service_factory.h
index bff3908..23ee9ff 100644
--- a/components/filesystem/public/cpp/prefs/pref_service_factory.h
+++ b/components/filesystem/public/cpp/prefs/pref_service_factory.h
@@ -9,7 +9,7 @@
#include "components/prefs/pref_service.h"
namespace mojo {
-class Shell;
+class Connector;
}
class PrefRegistry;
@@ -19,7 +19,7 @@ namespace filesystem {
// This factory method creates a PrefService for the local process based on the
// preference registry passed in. This PrefService will synchronize with a JSON
// file in the mojo:filesystem.
-scoped_ptr<PrefService> CreatePrefService(mojo::Shell* shell,
+scoped_ptr<PrefService> CreatePrefService(mojo::Connector* connector,
PrefRegistry* registry);
} // namespace filesystem
diff --git a/components/font_service/font_service_app.cc b/components/font_service/font_service_app.cc
index 83cbb37..d599b09 100644
--- a/components/font_service/font_service_app.cc
+++ b/components/font_service/font_service_app.cc
@@ -58,9 +58,10 @@ FontServiceApp::FontServiceApp() {}
FontServiceApp::~FontServiceApp() {}
-void FontServiceApp::Initialize(mojo::Shell* shell, const std::string& url,
+void FontServiceApp::Initialize(mojo::Connector* connector,
+ const std::string& url,
uint32_t id, uint32_t user_id) {
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
}
bool FontServiceApp::AcceptConnection(mojo::Connection* connection) {
diff --git a/components/font_service/font_service_app.h b/components/font_service/font_service_app.h
index 2963720..71d29cc 100644
--- a/components/font_service/font_service_app.h
+++ b/components/font_service/font_service_app.h
@@ -27,7 +27,7 @@ class FontServiceApp : public mojo::ShellClient,
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
diff --git a/components/font_service/public/cpp/font_loader.cc b/components/font_service/public/cpp/font_loader.cc
index 719d63d..03df30f 100644
--- a/components/font_service/public/cpp/font_loader.cc
+++ b/components/font_service/public/cpp/font_loader.cc
@@ -9,13 +9,13 @@
#include "base/bind.h"
#include "base/trace_event/trace_event.h"
#include "components/font_service/public/cpp/font_service_thread.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace font_service {
-FontLoader::FontLoader(mojo::Shell* shell) {
+FontLoader::FontLoader(mojo::Connector* connector) {
FontServicePtr font_service;
- shell->ConnectToInterface("mojo:font_service", &font_service);
+ connector->ConnectToInterface("mojo:font_service", &font_service);
thread_ = new internal::FontServiceThread(std::move(font_service));
}
diff --git a/components/font_service/public/cpp/font_loader.h b/components/font_service/public/cpp/font_loader.h
index 838b8ec..557241f 100644
--- a/components/font_service/public/cpp/font_loader.h
+++ b/components/font_service/public/cpp/font_loader.h
@@ -18,7 +18,7 @@
#include "third_party/skia/include/ports/SkFontConfigInterface.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace font_service {
@@ -35,7 +35,7 @@ class FontServiceThread;
class FontLoader : public SkFontConfigInterface,
public internal::MappedFontFile::Observer {
public:
- explicit FontLoader(mojo::Shell* shell);
+ explicit FontLoader(mojo::Connector* connector);
~FontLoader() override;
// Shuts down the background thread.
diff --git a/components/leveldb/leveldb_app.cc b/components/leveldb/leveldb_app.cc
index 01fd2ff..952d4f3 100644
--- a/components/leveldb/leveldb_app.cc
+++ b/components/leveldb/leveldb_app.cc
@@ -13,11 +13,11 @@ LevelDBApp::LevelDBApp() {}
LevelDBApp::~LevelDBApp() {}
-void LevelDBApp::Initialize(mojo::Shell* shell,
+void LevelDBApp::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
service_.reset(new LevelDBServiceImpl);
}
diff --git a/components/leveldb/leveldb_app.h b/components/leveldb/leveldb_app.h
index d1cd684..d9877d9 100644
--- a/components/leveldb/leveldb_app.h
+++ b/components/leveldb/leveldb_app.h
@@ -21,7 +21,7 @@ class LevelDBApp : public mojo::ShellClient,
private:
// |ShellClient| override:
- void Initialize(mojo::Shell* shell,
+ void Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) override;
diff --git a/components/leveldb/leveldb_apptest.cc b/components/leveldb/leveldb_apptest.cc
index 076e9f7..2a99adc 100644
--- a/components/leveldb/leveldb_apptest.cc
+++ b/components/leveldb/leveldb_apptest.cc
@@ -28,8 +28,8 @@ class LevelDBApptest : public mojo::test::ApplicationTestBase {
// Overridden from mojo::test::ApplicationTestBase:
void SetUp() override {
ApplicationTestBase::SetUp();
- shell()->ConnectToInterface("mojo:filesystem", &files_);
- shell()->ConnectToInterface("mojo:leveldb", &leveldb_);
+ connector()->ConnectToInterface("mojo:filesystem", &files_);
+ connector()->ConnectToInterface("mojo:leveldb", &leveldb_);
}
// Note: This has an out parameter rather than returning the |DirectoryPtr|,
diff --git a/components/mus/mus_app.cc b/components/mus/mus_app.cc
index ea2410b..3d98051 100644
--- a/components/mus/mus_app.cc
+++ b/components/mus/mus_app.cc
@@ -21,7 +21,7 @@
#include "mojo/public/c/system/main.h"
#include "mojo/services/tracing/public/cpp/tracing_impl.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/events/event_switches.h"
@@ -58,7 +58,7 @@ struct MandolineUIServicesApp::PendingRequest {
};
MandolineUIServicesApp::MandolineUIServicesApp()
- : shell_(nullptr) {}
+ : connector_(nullptr) {}
MandolineUIServicesApp::~MandolineUIServicesApp() {
if (gpu_state_)
@@ -67,7 +67,7 @@ MandolineUIServicesApp::~MandolineUIServicesApp() {
connection_manager_.reset();
}
-void MandolineUIServicesApp::InitializeResources(mojo::Shell* shell) {
+void MandolineUIServicesApp::InitializeResources(mojo::Connector* connector) {
if (ui::ResourceBundle::HasSharedInstance())
return;
@@ -76,7 +76,7 @@ void MandolineUIServicesApp::InitializeResources(mojo::Shell* shell) {
resource_paths.insert(kResourceFile100);
resource_paths.insert(kResourceFile200);
- resource_provider::ResourceLoader resource_loader(shell, resource_paths);
+ resource_provider::ResourceLoader resource_loader(connector, resource_paths);
if (!resource_loader.BlockUntilLoaded())
return;
CHECK(resource_loader.loaded());
@@ -92,11 +92,11 @@ void MandolineUIServicesApp::InitializeResources(mojo::Shell* shell) {
resource_loader.ReleaseFile(kResourceFile200), ui::SCALE_FACTOR_200P);
}
-void MandolineUIServicesApp::Initialize(mojo::Shell* shell,
+void MandolineUIServicesApp::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- shell_ = shell;
+ connector_ = connector;
surfaces_state_ = new SurfacesState;
base::PlatformThread::SetName("mus");
@@ -109,7 +109,7 @@ void MandolineUIServicesApp::Initialize(mojo::Shell* shell,
}
#endif
- InitializeResources(shell);
+ InitializeResources(connector);
#if defined(USE_OZONE)
// The ozone platform can provide its own event source. So initialize the
@@ -132,7 +132,7 @@ void MandolineUIServicesApp::Initialize(mojo::Shell* shell,
gpu_state_ = new GpuState();
connection_manager_.reset(new ws::ConnectionManager(this, surfaces_state_));
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
}
bool MandolineUIServicesApp::AcceptConnection(Connection* connection) {
@@ -156,7 +156,7 @@ void MandolineUIServicesApp::OnFirstRootConnectionCreated() {
}
void MandolineUIServicesApp::OnNoMoreRootConnections() {
- shell_->Quit();
+ base::MessageLoop::current()->QuitWhenIdle();
}
ws::ClientConnection*
@@ -230,7 +230,7 @@ void MandolineUIServicesApp::CreateWindowTreeHost(
// TODO(fsamuel): We need to make sure that only the window manager can create
// new roots.
ws::WindowTreeHostImpl* host_impl = new ws::WindowTreeHostImpl(
- connection_manager_.get(), shell_, gpu_state_, surfaces_state_);
+ connection_manager_.get(), connector_, gpu_state_, surfaces_state_);
// WindowTreeHostConnection manages its own lifetime.
host_impl->Init(new ws::WindowTreeHostConnectionImpl(
diff --git a/components/mus/mus_app.h b/components/mus/mus_app.h
index 5a349c5..5c80f47 100644
--- a/components/mus/mus_app.h
+++ b/components/mus/mus_app.h
@@ -24,7 +24,7 @@
#include "mojo/shell/public/cpp/shell_client.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace ui {
@@ -60,10 +60,10 @@ class MandolineUIServicesApp
// has been established.
struct PendingRequest;
- void InitializeResources(mojo::Shell* shell);
+ void InitializeResources(mojo::Connector* connector);
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
@@ -105,7 +105,7 @@ class MandolineUIServicesApp
mojom::WindowTreeClientPtr tree_client) override;
mojo::BindingSet<mojom::WindowTreeHostFactory> factory_bindings_;
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
scoped_ptr<ws::ConnectionManager> connection_manager_;
scoped_refptr<GpuState> gpu_state_;
scoped_ptr<ui::PlatformEventSource> event_source_;
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc
index b1107af..cdcd7b6 100644
--- a/components/mus/public/cpp/lib/window_tree_client_impl.cc
+++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
@@ -19,7 +19,7 @@
#include "components/mus/public/cpp/window_tree_connection_observer.h"
#include "components/mus/public/cpp/window_tree_delegate.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/size.h"
@@ -80,10 +80,10 @@ Window* BuildWindowTree(WindowTreeClientImpl* client,
}
WindowTreeConnection* WindowTreeConnection::Create(WindowTreeDelegate* delegate,
- mojo::Shell* shell) {
+ mojo::Connector* connector) {
WindowTreeClientImpl* client =
new WindowTreeClientImpl(delegate, nullptr, nullptr);
- client->ConnectViaWindowTreeFactory(shell);
+ client->ConnectViaWindowTreeFactory(connector);
return client;
}
@@ -159,7 +159,7 @@ WindowTreeClientImpl::~WindowTreeClientImpl() {
}
void WindowTreeClientImpl::ConnectViaWindowTreeFactory(
- mojo::Shell* shell) {
+ mojo::Connector* connector) {
// Clients created with no root shouldn't delete automatically.
delete_on_no_roots_ = false;
@@ -167,7 +167,7 @@ void WindowTreeClientImpl::ConnectViaWindowTreeFactory(
connection_id_ = 101;
mojom::WindowTreeFactoryPtr factory;
- shell->ConnectToInterface("mojo:mus", &factory);
+ connector->ConnectToInterface("mojo:mus", &factory);
factory->CreateWindowTree(GetProxy(&tree_ptr_),
binding_.CreateInterfacePtrAndBind());
tree_ = tree_ptr_.get();
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.h b/components/mus/public/cpp/lib/window_tree_client_impl.h
index 991473b..9d75fa7 100644
--- a/components/mus/public/cpp/lib/window_tree_client_impl.h
+++ b/components/mus/public/cpp/lib/window_tree_client_impl.h
@@ -45,7 +45,7 @@ class WindowTreeClientImpl : public WindowTreeConnection,
~WindowTreeClientImpl() override;
// Establishes the connection by way of the WindowTreeFactory.
- void ConnectViaWindowTreeFactory(mojo::Shell* shell);
+ void ConnectViaWindowTreeFactory(mojo::Connector* connector);
// Wait for OnEmbed(), returning when done.
void WaitForEmbed();
diff --git a/components/mus/public/cpp/lib/window_tree_host_factory.cc b/components/mus/public/cpp/lib/window_tree_host_factory.cc
index 88c45d7..54e4d3c 100644
--- a/components/mus/public/cpp/lib/window_tree_host_factory.cc
+++ b/components/mus/public/cpp/lib/window_tree_host_factory.cc
@@ -6,7 +6,7 @@
#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/public/cpp/window_tree_delegate.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mus {
@@ -22,12 +22,12 @@ void CreateWindowTreeHost(mojom::WindowTreeHostFactory* factory,
factory->CreateWindowTreeHost(GetProxy(host), std::move(tree_client));
}
-void CreateWindowTreeHost(mojo::Shell* shell,
+void CreateWindowTreeHost(mojo::Connector* connector,
WindowTreeDelegate* delegate,
mojom::WindowTreeHostPtr* host,
WindowManagerDelegate* window_manager_delegate) {
mojom::WindowTreeHostFactoryPtr factory;
- shell->ConnectToInterface("mojo:mus", &factory);
+ connector->ConnectToInterface("mojo:mus", &factory);
CreateWindowTreeHost(factory.get(), delegate, host, window_manager_delegate);
}
diff --git a/components/mus/public/cpp/tests/window_server_test_base.cc b/components/mus/public/cpp/tests/window_server_test_base.cc
index ab47629..affbf31 100644
--- a/components/mus/public/cpp/tests/window_server_test_base.cc
+++ b/components/mus/public/cpp/tests/window_server_test_base.cc
@@ -11,7 +11,7 @@
#include "components/mus/public/cpp/window.h"
#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/public/cpp/window_tree_host_factory.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mus {
namespace {
@@ -65,7 +65,7 @@ bool WindowServerTestBase::QuitRunLoop() {
void WindowServerTestBase::SetUp() {
ApplicationTestBase::SetUp();
- CreateWindowTreeHost(shell(), this, &host_, this);
+ CreateWindowTreeHost(connector(), this, &host_, this);
ASSERT_TRUE(DoRunLoopWithTimeout()); // RunLoop should be quit by OnEmbed().
std::swap(window_manager_, most_recent_connection_);
diff --git a/components/mus/public/cpp/window_tree_connection.h b/components/mus/public/cpp/window_tree_connection.h
index 31528ac..d99eda2 100644
--- a/components/mus/public/cpp/window_tree_connection.h
+++ b/components/mus/public/cpp/window_tree_connection.h
@@ -16,7 +16,7 @@
#include "mojo/public/cpp/bindings/interface_request.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -43,7 +43,7 @@ class WindowTreeConnection {
// Creates a WindowTreeConnection with no roots. Use this to establish a
// connection directly to mus and create top level windows.
static WindowTreeConnection* Create(WindowTreeDelegate* delegate,
- mojo::Shell* shell);
+ mojo::Connector* connector);
// Creates a WindowTreeConnection to service the specified request for
// a WindowTreeClient. Use this to be embedded in another app.
diff --git a/components/mus/public/cpp/window_tree_host_factory.h b/components/mus/public/cpp/window_tree_host_factory.h
index 1c75de8..b3a5bab 100644
--- a/components/mus/public/cpp/window_tree_host_factory.h
+++ b/components/mus/public/cpp/window_tree_host_factory.h
@@ -11,7 +11,7 @@
#include "mojo/public/cpp/bindings/binding.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -26,7 +26,7 @@ void CreateWindowTreeHost(mojom::WindowTreeHostFactory* factory,
WindowTreeDelegate* delegate,
mojom::WindowTreeHostPtr* host,
WindowManagerDelegate* window_manager_delegate);
-void CreateWindowTreeHost(mojo::Shell* shell,
+void CreateWindowTreeHost(mojo::Connector* connector,
WindowTreeDelegate* delegate,
mojom::WindowTreeHostPtr* host,
WindowManagerDelegate* window_manager_delegate);
diff --git a/components/mus/ws/display_manager.cc b/components/mus/ws/display_manager.cc
index a35e08b..8b991f8 100644
--- a/components/mus/ws/display_manager.cc
+++ b/components/mus/ws/display_manager.cc
@@ -29,7 +29,7 @@
#include "mojo/converters/surfaces/surfaces_utils.h"
#include "mojo/converters/transform/transform_type_converters.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/base/cursor/cursor_loader.h"
#include "ui/events/event.h"
@@ -155,19 +155,19 @@ DisplayManagerFactory* DisplayManager::factory_ = nullptr;
// static
DisplayManager* DisplayManager::Create(
- mojo::Shell* shell,
+ mojo::Connector* connector,
const scoped_refptr<GpuState>& gpu_state,
const scoped_refptr<SurfacesState>& surfaces_state) {
if (factory_)
- return factory_->CreateDisplayManager(shell, gpu_state, surfaces_state);
- return new DefaultDisplayManager(shell, gpu_state, surfaces_state);
+ return factory_->CreateDisplayManager(connector, gpu_state, surfaces_state);
+ return new DefaultDisplayManager(connector, gpu_state, surfaces_state);
}
DefaultDisplayManager::DefaultDisplayManager(
- mojo::Shell* shell,
+ mojo::Connector* connector,
const scoped_refptr<GpuState>& gpu_state,
const scoped_refptr<SurfacesState>& surfaces_state)
- : shell_(shell),
+ : connector_(connector),
gpu_state_(gpu_state),
surfaces_state_(surfaces_state),
delegate_(nullptr),
diff --git a/components/mus/ws/display_manager.h b/components/mus/ws/display_manager.h
index 49a1f92..ce93485 100644
--- a/components/mus/ws/display_manager.h
+++ b/components/mus/ws/display_manager.h
@@ -35,7 +35,7 @@ class GpuState;
} // namespace gles2
namespace mojo {
-class Shell;
+class Connector;
} // namespace mojo
namespace ui {
@@ -63,7 +63,7 @@ class DisplayManager {
virtual ~DisplayManager() {}
static DisplayManager* Create(
- mojo::Shell* shell,
+ mojo::Connector* connector,
const scoped_refptr<GpuState>& gpu_state,
const scoped_refptr<SurfacesState>& surfaces_state);
@@ -112,7 +112,7 @@ class DisplayManager {
class DefaultDisplayManager : public DisplayManager,
public ui::PlatformWindowDelegate {
public:
- DefaultDisplayManager(mojo::Shell* shell,
+ DefaultDisplayManager(mojo::Connector* connector,
const scoped_refptr<GpuState>& gpu_state,
const scoped_refptr<SurfacesState>& surfaces_state);
~DefaultDisplayManager() override;
@@ -162,7 +162,7 @@ class DefaultDisplayManager : public DisplayManager,
void OnAcceleratedWidgetDestroyed() override;
void OnActivationChanged(bool active) override;
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
scoped_refptr<GpuState> gpu_state_;
scoped_refptr<SurfacesState> surfaces_state_;
DisplayManagerDelegate* delegate_;
diff --git a/components/mus/ws/display_manager_factory.h b/components/mus/ws/display_manager_factory.h
index 49bc734..f73ac80 100644
--- a/components/mus/ws/display_manager_factory.h
+++ b/components/mus/ws/display_manager_factory.h
@@ -9,7 +9,7 @@
#include "mojo/public/cpp/bindings/callback.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -23,7 +23,7 @@ class DisplayManager;
class DisplayManagerFactory {
public:
virtual DisplayManager* CreateDisplayManager(
- mojo::Shell* shell,
+ mojo::Connector* connector,
const scoped_refptr<mus::GpuState>& gpu_state,
const scoped_refptr<mus::SurfacesState>& surfaces_state) = 0;
};
diff --git a/components/mus/ws/window_manager_client_apptest.cc b/components/mus/ws/window_manager_client_apptest.cc
index 5d9f111..8bc7972 100644
--- a/components/mus/ws/window_manager_client_apptest.cc
+++ b/components/mus/ws/window_manager_client_apptest.cc
@@ -275,7 +275,7 @@ class WindowServerTest : public WindowServerTestBase {
// WindowTreeClient.
mus::mojom::WindowTreeClientPtr ConnectAndGetWindowServerClient() {
mus::mojom::WindowTreeClientPtr client;
- shell()->ConnectToInterface(shell_url(), &client);
+ connector()->ConnectToInterface(test_url(), &client);
return client;
}
@@ -1159,7 +1159,7 @@ TEST_F(WindowServerTest, EstablishConnectionViaFactory) {
EstablishConnectionViaFactoryDelegate delegate(window_manager());
set_window_manager_delegate(&delegate);
scoped_ptr<WindowTreeConnection> second_connection(
- WindowTreeConnection::Create(this, shell()));
+ WindowTreeConnection::Create(this, connector()));
Window* window_in_second_connection =
second_connection->NewTopLevelWindow(nullptr);
ASSERT_TRUE(window_in_second_connection);
diff --git a/components/mus/ws/window_tree_apptest.cc b/components/mus/ws/window_tree_apptest.cc
index ee2a186..cc18e0d 100644
--- a/components/mus/ws/window_tree_apptest.cc
+++ b/components/mus/ws/window_tree_apptest.cc
@@ -63,7 +63,7 @@ void EmbedCallbackImpl(base::RunLoop* run_loop,
// -----------------------------------------------------------------------------
-bool EmbedUrl(mojo::Shell* shell,
+bool EmbedUrl(mojo::Connector* connector,
WindowTree* ws,
const String& url,
Id root_id) {
@@ -71,7 +71,7 @@ bool EmbedUrl(mojo::Shell* shell,
base::RunLoop run_loop;
{
mojom::WindowTreeClientPtr client;
- shell->ConnectToInterface(url.get(), &client);
+ connector->ConnectToInterface(url.get(), &client);
ws->Embed(root_id, std::move(client),
mojom::WindowTree::kAccessPolicyDefault,
base::Bind(&EmbedCallbackImpl, &run_loop, &result));
@@ -547,7 +547,7 @@ class WindowTreeAppTest : public mojo::test::ApplicationTestBase,
Id root_id,
uint32_t policy_bitmask,
int* connection_id) {
- if (!EmbedUrl(shell(), owner, shell_url(), root_id)) {
+ if (!EmbedUrl(connector(), owner, test_url(), root_id)) {
ADD_FAILURE() << "Embed() failed";
return nullptr;
}
@@ -573,7 +573,7 @@ class WindowTreeAppTest : public mojo::test::ApplicationTestBase,
client_factory_.reset(new WindowTreeClientFactory());
mojom::WindowTreeHostFactoryPtr factory;
- shell()->ConnectToInterface("mojo:mus", &factory);
+ connector()->ConnectToInterface("mojo:mus", &factory);
mojom::WindowTreeClientPtr tree_client_ptr;
ws_client1_.reset(new TestWindowTreeClientImpl());
@@ -1724,7 +1724,7 @@ TEST_F(WindowTreeAppTest, EmbedFailsFromOtherConnection) {
// 2 should not be able to embed in window_3_3 as window_3_3 was not created
// by
// 2.
- EXPECT_FALSE(EmbedUrl(shell(), ws2(), shell_url(), window_3_3));
+ EXPECT_FALSE(EmbedUrl(connector(), ws2(), test_url(), window_3_3));
}
// Verifies Embed() from window manager on another connections window works.
@@ -1747,7 +1747,7 @@ TEST_F(WindowTreeAppTest, EmbedFromOtherConnection) {
TEST_F(WindowTreeAppTest, CantEmbedFromConnectionRoot) {
// Shouldn't be able to embed into the root.
- ASSERT_FALSE(EmbedUrl(shell(), ws1(), shell_url(), root_window_id()));
+ ASSERT_FALSE(EmbedUrl(connector(), ws1(), test_url(), root_window_id()));
// Even though the call above failed a WindowTreeClient was obtained. We need
// to
@@ -1756,7 +1756,7 @@ TEST_F(WindowTreeAppTest, CantEmbedFromConnectionRoot) {
// Don't allow a connection to embed into its own root.
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
- EXPECT_FALSE(EmbedUrl(shell(), ws2(), shell_url(),
+ EXPECT_FALSE(EmbedUrl(connector(), ws2(), test_url(),
BuildWindowId(connection_id_1(), 1)));
// Need to wait for a WindowTreeClient for same reason as above.
@@ -1773,7 +1773,7 @@ TEST_F(WindowTreeAppTest, CantEmbedFromConnectionRoot) {
// window_1_2 is ws3's root, so even though v3 is an embed root it should not
// be able to Embed into itself.
- ASSERT_FALSE(EmbedUrl(shell(), ws3(), shell_url(), window_1_2));
+ ASSERT_FALSE(EmbedUrl(connector(), ws3(), test_url(), window_1_2));
}
// Verifies that a transient window tracks its parent's lifetime.
diff --git a/components/mus/ws/window_tree_host_impl.cc b/components/mus/ws/window_tree_host_impl.cc
index d80ef83..46f3e91 100644
--- a/components/mus/ws/window_tree_host_impl.cc
+++ b/components/mus/ws/window_tree_host_impl.cc
@@ -87,7 +87,7 @@ WindowTreeHostImpl::QueuedEvent::~QueuedEvent() {}
WindowTreeHostImpl::WindowTreeHostImpl(
ConnectionManager* connection_manager,
- mojo::Shell* shell,
+ mojo::Connector* connector,
const scoped_refptr<GpuState>& gpu_state,
const scoped_refptr<SurfacesState>& surfaces_state)
: id_(next_id++),
@@ -95,7 +95,7 @@ WindowTreeHostImpl::WindowTreeHostImpl(
connection_manager_(connection_manager),
event_dispatcher_(this),
display_manager_(
- DisplayManager::Create(shell, gpu_state, surfaces_state)),
+ DisplayManager::Create(connector, gpu_state, surfaces_state)),
tree_awaiting_input_ack_(nullptr),
last_cursor_(0) {
frame_decoration_values_ = mojom::FrameDecorationValues::New();
diff --git a/components/mus/ws/window_tree_host_impl.h b/components/mus/ws/window_tree_host_impl.h
index cace4be..a1f93d1 100644
--- a/components/mus/ws/window_tree_host_impl.h
+++ b/components/mus/ws/window_tree_host_impl.h
@@ -48,7 +48,7 @@ class WindowTreeHostImpl : public DisplayManagerDelegate,
// DisplayManagers. We should probably just store these common parameters
// in the DisplayManagerFactory and pass them along on DisplayManager::Create.
WindowTreeHostImpl(ConnectionManager* connection_manager,
- mojo::Shell* shell,
+ mojo::Connector* connector,
const scoped_refptr<GpuState>& gpu_state,
const scoped_refptr<SurfacesState>& surfaces_state);
~WindowTreeHostImpl() override;
diff --git a/components/mus/ws/window_tree_unittest.cc b/components/mus/ws/window_tree_unittest.cc
index 99e53a5..bafcf2d 100644
--- a/components/mus/ws/window_tree_unittest.cc
+++ b/components/mus/ws/window_tree_unittest.cc
@@ -352,7 +352,7 @@ class TestDisplayManagerFactory : public DisplayManagerFactory {
: cursor_id_storage_(cursor_id_storage) {}
~TestDisplayManagerFactory() {}
DisplayManager* CreateDisplayManager(
- mojo::Shell* shell,
+ mojo::Connector* connector,
const scoped_refptr<GpuState>& gpu_state,
const scoped_refptr<mus::SurfacesState>& surfaces_state) override {
return new TestDisplayManager(cursor_id_storage_);
diff --git a/components/resource_provider/public/cpp/resource_loader.cc b/components/resource_provider/public/cpp/resource_loader.cc
index 1bd8b7c..fc33a36 100644
--- a/components/resource_provider/public/cpp/resource_loader.cc
+++ b/components/resource_provider/public/cpp/resource_loader.cc
@@ -11,7 +11,7 @@
#include "base/files/file.h"
#include "mojo/common/common_type_converters.h"
#include "mojo/platform_handle/platform_handle_functions.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/interfaces/interface_provider.mojom.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
@@ -26,10 +26,10 @@ base::File GetFileFromHandle(mojo::ScopedHandle handle) {
}
}
-ResourceLoader::ResourceLoader(mojo::Shell* shell,
+ResourceLoader::ResourceLoader(mojo::Connector* connector,
const std::set<std::string>& paths)
: loaded_(false), did_block_(false) {
- shell->ConnectToInterface("mojo:resource_provider", &resource_provider_);
+ connector->ConnectToInterface("mojo:resource_provider", &resource_provider_);
std::vector<std::string> paths_vector(paths.begin(), paths.end());
resource_provider_->GetResources(
mojo::Array<mojo::String>::From(paths_vector),
diff --git a/components/resource_provider/public/cpp/resource_loader.h b/components/resource_provider/public/cpp/resource_loader.h
index e355d6e..033cfdd 100644
--- a/components/resource_provider/public/cpp/resource_loader.h
+++ b/components/resource_provider/public/cpp/resource_loader.h
@@ -22,7 +22,7 @@ class File;
}
namespace mojo {
-class Shell;
+class Connector;
}
namespace resource_provider {
@@ -33,7 +33,8 @@ namespace resource_provider {
// have been obtained.
class ResourceLoader {
public:
- ResourceLoader(mojo::Shell* shell, const std::set<std::string>& paths);
+ ResourceLoader(mojo::Connector* connector,
+ const std::set<std::string>& paths);
~ResourceLoader();
// Uses WaitForIncomingMessage() to block until the results are available, or
diff --git a/components/resource_provider/resource_provider_app.cc b/components/resource_provider/resource_provider_app.cc
index b3723ab..85e6e28 100644
--- a/components/resource_provider/resource_provider_app.cc
+++ b/components/resource_provider/resource_provider_app.cc
@@ -21,9 +21,10 @@ ResourceProviderApp::ResourceProviderApp(
ResourceProviderApp::~ResourceProviderApp() {
}
-void ResourceProviderApp::Initialize(mojo::Shell* shell, const std::string& url,
+void ResourceProviderApp::Initialize(mojo::Connector* connector,
+ const std::string& url,
uint32_t id, uint32_t user_id) {
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
}
bool ResourceProviderApp::AcceptConnection(mojo::Connection* connection) {
diff --git a/components/resource_provider/resource_provider_app.h b/components/resource_provider/resource_provider_app.h
index 056c97f..0f2d0f0 100644
--- a/components/resource_provider/resource_provider_app.h
+++ b/components/resource_provider/resource_provider_app.h
@@ -15,10 +15,6 @@
#include "mojo/shell/public/cpp/interface_factory.h"
#include "mojo/shell/public/cpp/shell_client.h"
-namespace mojo {
-class Shell;
-}
-
namespace resource_provider {
class ResourceProviderApp : public mojo::ShellClient,
@@ -29,7 +25,7 @@ class ResourceProviderApp : public mojo::ShellClient,
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
diff --git a/components/resource_provider/resource_provider_apptest.cc b/components/resource_provider/resource_provider_apptest.cc
index cc5bfe1..aecd282 100644
--- a/components/resource_provider/resource_provider_apptest.cc
+++ b/components/resource_provider/resource_provider_apptest.cc
@@ -55,7 +55,7 @@ class ResourceProviderApplicationTest : public mojo::test::ApplicationTestBase {
// resources are returned. The return map maps from the path to the contents
// of the file at the specified path.
ResourceContentsMap GetResources(const std::set<std::string>& paths) {
- ResourceLoader loader(shell(), paths);
+ ResourceLoader loader(connector(), paths);
loader.BlockUntilLoaded();
// Load the contents of each of the handles.
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index d7a4638..f7cfb45 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -179,6 +179,7 @@
#endif
#if defined(MOJO_SHELL_CLIENT)
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/views/mus/window_manager_connection.h"
#endif
@@ -919,7 +920,7 @@ int BrowserMainLoop::PreMainMessageLoopRun() {
MojoShellConnectionImpl::Get()->BindToCommandLinePlatformChannel();
#if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA)
views::WindowManagerConnection::Create(
- MojoShellConnection::Get()->GetShell());
+ MojoShellConnection::Get()->GetConnector());
#endif
}
diff --git a/content/browser/mojo/mojo_shell_client_host.cc b/content/browser/mojo/mojo_shell_client_host.cc
index 6a7b707..2cc0da6 100644
--- a/content/browser/mojo/mojo_shell_client_host.cc
+++ b/content/browser/mojo/mojo_shell_client_host.cc
@@ -21,7 +21,7 @@
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/interfaces/application_manager.mojom.h"
namespace content {
@@ -134,7 +134,7 @@ void RegisterChildWithExternalShell(int child_process_id,
mojo::edk::CreateMessagePipe(std::move(parent_pipe));
mojo::shell::mojom::ApplicationManagerPtr application_manager;
- MojoShellConnection::Get()->GetShell()->ConnectToInterface(
+ MojoShellConnection::Get()->GetConnector()->ConnectToInterface(
"mojo:shell", &application_manager);
// The content of the URL/qualifier we pass is actually meaningless, it's only
diff --git a/content/browser/renderer_host/render_widget_host_view_mus.cc b/content/browser/renderer_host/render_widget_host_view_mus.cc
index 4bd3d57..9ddef3e 100644
--- a/content/browser/renderer_host/render_widget_host_view_mus.cc
+++ b/content/browser/renderer_host/render_widget_host_view_mus.cc
@@ -14,7 +14,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/render_widget_window_tree_client_factory.mojom.h"
#include "content/public/common/mojo_shell_connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
@@ -40,7 +40,7 @@ RenderWidgetHostViewMus::RenderWidgetHostViewMus(mus::Window* parent_window,
// and embed that client inside our mus window.
std::string url = GetMojoApplicationInstanceURL(host_->GetProcess());
mojom::RenderWidgetWindowTreeClientFactoryPtr factory;
- MojoShellConnection::Get()->GetShell()->ConnectToInterface(url, &factory);
+ MojoShellConnection::Get()->GetConnector()->ConnectToInterface(url, &factory);
mus::mojom::WindowTreeClientPtr window_tree_client;
factory->CreateWindowTreeClientForRenderWidget(
diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc
index 8531205..6b19b3f2 100644
--- a/content/common/mojo/mojo_shell_connection_impl.cc
+++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -93,7 +93,7 @@ void MojoShellConnectionImpl::WaitForShell(
shell_connection_->WaitForInitialize();
}
-void MojoShellConnectionImpl::Initialize(mojo::Shell* shell,
+void MojoShellConnectionImpl::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
@@ -107,9 +107,9 @@ bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) {
return found;
}
-mojo::Shell* MojoShellConnectionImpl::GetShell() {
+mojo::Connector* MojoShellConnectionImpl::GetConnector() {
DCHECK(initialized_);
- return shell_connection_.get();
+ return shell_connection_->connector();
}
bool MojoShellConnectionImpl::UsingExternalShell() const {
diff --git a/content/common/mojo/mojo_shell_connection_impl.h b/content/common/mojo/mojo_shell_connection_impl.h
index dd588e0..73ae507 100644
--- a/content/common/mojo/mojo_shell_connection_impl.h
+++ b/content/common/mojo/mojo_shell_connection_impl.h
@@ -56,12 +56,12 @@ class MojoShellConnectionImpl : public MojoShellConnection,
~MojoShellConnectionImpl() override;
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
// MojoShellConnection:
- mojo::Shell* GetShell() override;
+ mojo::Connector* GetConnector() override;
bool UsingExternalShell() const override;
void AddListener(Listener* listener) override;
void RemoveListener(Listener* listener) override;
diff --git a/content/public/common/mojo_shell_connection.h b/content/public/common/mojo_shell_connection.h
index 59c38b3..50827a9 100644
--- a/content/public/common/mojo_shell_connection.h
+++ b/content/public/common/mojo_shell_connection.h
@@ -9,7 +9,7 @@
namespace mojo {
class Connection;
-class Shell;
+class Connector;
}
namespace content {
@@ -41,8 +41,7 @@ class CONTENT_EXPORT MojoShellConnection {
// created on.
static void Destroy();
- // Returns an Initialized() Shell.
- virtual mojo::Shell* GetShell() = 0;
+ virtual mojo::Connector* GetConnector() = 0;
// Indicates whether the shell connection is to an external shell (true) or
// a shell embedded in the browser process (false).
diff --git a/content/public/test/test_mojo_app.cc b/content/public/test/test_mojo_app.cc
index cc80175..4fb1b27 100644
--- a/content/public/test/test_mojo_app.cc
+++ b/content/public/test/test_mojo_app.cc
@@ -7,24 +7,20 @@
#include <utility>
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace content {
const char kTestMojoAppUrl[] = "system:content_mojo_test";
-TestMojoApp::TestMojoApp() : service_binding_(this), shell_(nullptr) {
+TestMojoApp::TestMojoApp() : service_binding_(this) {
}
TestMojoApp::~TestMojoApp() {
}
-void TestMojoApp::Initialize(mojo::Shell* shell, const std::string& url,
- uint32_t id, uint32_t user_id) {
- shell_ = shell;
-}
-
bool TestMojoApp::AcceptConnection(mojo::Connection* connection) {
requestor_url_ = GURL(connection->GetRemoteApplicationURL());
connection->AddInterface<TestMojoService>(this);
@@ -39,8 +35,7 @@ void TestMojoApp::Create(mojo::Connection* connection,
void TestMojoApp::DoSomething(const DoSomethingCallback& callback) {
callback.Run();
- DCHECK(shell_);
- shell_->Quit();
+ base::MessageLoop::current()->QuitWhenIdle();
}
void TestMojoApp::GetRequestorURL(const GetRequestorURLCallback& callback) {
diff --git a/content/public/test/test_mojo_app.h b/content/public/test/test_mojo_app.h
index edf0ad28..0ce330a 100644
--- a/content/public/test/test_mojo_app.h
+++ b/content/public/test/test_mojo_app.h
@@ -27,8 +27,6 @@ class TestMojoApp : public mojo::ShellClient,
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
- uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
// mojo::InterfaceFactory<TestMojoService>:
@@ -41,9 +39,6 @@ class TestMojoApp : public mojo::ShellClient,
mojo::Binding<TestMojoService> service_binding_;
- // Not owned.
- mojo::Shell* shell_;
-
// The URL of the app connecting to us.
GURL requestor_url_;
diff --git a/content/renderer/mus/render_widget_mus_connection.cc b/content/renderer/mus/render_widget_mus_connection.cc
index 3ac0808..c2dc1d1 100644
--- a/content/renderer/mus/render_widget_mus_connection.cc
+++ b/content/renderer/mus/render_widget_mus_connection.cc
@@ -20,7 +20,7 @@
#include "content/renderer/render_view_impl.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/surfaces/surfaces_utils.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace content {
@@ -49,8 +49,8 @@ scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!window_surface_binding_);
mus::mojom::GpuPtr gpu_service;
- MojoShellConnection::Get()->GetShell()->ConnectToInterface("mojo:mus",
- &gpu_service);
+ MojoShellConnection::Get()->GetConnector()->ConnectToInterface("mojo:mus",
+ &gpu_service);
mus::mojom::CommandBufferPtr cb;
gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
scoped_refptr<cc::ContextProvider> context_provider(
diff --git a/mash/browser_driver/browser_driver_application_delegate.cc b/mash/browser_driver/browser_driver_application_delegate.cc
index 674be25..e5ea59a 100644
--- a/mash/browser_driver/browser_driver_application_delegate.cc
+++ b/mash/browser_driver/browser_driver_application_delegate.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "components/mus/public/cpp/event_matcher.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mash {
namespace browser_driver {
@@ -45,16 +45,16 @@ void AssertTrue(bool success) {
} // namespace
BrowserDriverApplicationDelegate::BrowserDriverApplicationDelegate()
- : shell_(nullptr),
+ : connector_(nullptr),
binding_(this) {}
BrowserDriverApplicationDelegate::~BrowserDriverApplicationDelegate() {}
-void BrowserDriverApplicationDelegate::Initialize(mojo::Shell* shell,
+void BrowserDriverApplicationDelegate::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- shell_ = shell;
+ connector_ = connector;
AddAccelerators();
}
@@ -69,7 +69,7 @@ void BrowserDriverApplicationDelegate::OnAccelerator(
case Accelerator::NewWindow:
case Accelerator::NewTab:
case Accelerator::NewIncognitoWindow:
- shell_->Connect("exe:chrome");
+ connector_->Connect("exe:chrome");
// TODO(beng): have Chrome export a service that allows it to be driven by
// this driver, e.g. to open new tabs, incognito windows, etc.
break;
@@ -83,7 +83,7 @@ void BrowserDriverApplicationDelegate::AddAccelerators() {
// TODO(beng): find some other way to get the window manager. I don't like
// having to specify it by URL because it may differ per display.
mus::mojom::AcceleratorRegistrarPtr registrar;
- shell_->ConnectToInterface("mojo:desktop_wm", &registrar);
+ connector_->ConnectToInterface("mojo:desktop_wm", &registrar);
if (binding_.is_bound())
binding_.Unbind();
diff --git a/mash/browser_driver/browser_driver_application_delegate.h b/mash/browser_driver/browser_driver_application_delegate.h
index ff2aa9a..cbe63cf 100644
--- a/mash/browser_driver/browser_driver_application_delegate.h
+++ b/mash/browser_driver/browser_driver_application_delegate.h
@@ -27,7 +27,7 @@ class BrowserDriverApplicationDelegate : public mojo::ShellClient,
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
@@ -36,7 +36,7 @@ class BrowserDriverApplicationDelegate : public mojo::ShellClient,
void AddAccelerators();
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
mojo::Binding<mus::mojom::AcceleratorHandler> binding_;
DISALLOW_COPY_AND_ASSIGN(BrowserDriverApplicationDelegate);
diff --git a/mash/example/views_examples/views_examples_application_delegate.cc b/mash/example/views_examples/views_examples_application_delegate.cc
index 9be2175..1c4c200 100644
--- a/mash/example/views_examples/views_examples_application_delegate.cc
+++ b/mash/example/views_examples/views_examples_application_delegate.cc
@@ -5,7 +5,7 @@
#include "mash/example/views_examples/views_examples_application_delegate.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/views/examples/example_base.h"
#include "ui/views/examples/examples_window.h"
#include "ui/views/mus/aura_init.h"
@@ -16,14 +16,14 @@ ViewsExamplesApplicationDelegate::ViewsExamplesApplicationDelegate() {}
ViewsExamplesApplicationDelegate::~ViewsExamplesApplicationDelegate() {
}
-void ViewsExamplesApplicationDelegate::Initialize(mojo::Shell* shell,
+void ViewsExamplesApplicationDelegate::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- tracing_.Initialize(shell, url);
- aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak"));
+ tracing_.Initialize(connector, url);
+ aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
- views::WindowManagerConnection::Create(shell);
+ views::WindowManagerConnection::Create(connector);
views::examples::ShowExamplesWindow(views::examples::DO_NOTHING_ON_CLOSE,
nullptr, nullptr);
diff --git a/mash/example/views_examples/views_examples_application_delegate.h b/mash/example/views_examples/views_examples_application_delegate.h
index 90f28ce..e7d9eec 100644
--- a/mash/example/views_examples/views_examples_application_delegate.h
+++ b/mash/example/views_examples/views_examples_application_delegate.h
@@ -21,7 +21,7 @@ class ViewsExamplesApplicationDelegate : public mojo::ShellClient {
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
diff --git a/mash/example/window_type_launcher/window_type_launcher.cc b/mash/example/window_type_launcher/window_type_launcher.cc
index a5dacd0..d4fdc69 100644
--- a/mash/example/window_type_launcher/window_type_launcher.cc
+++ b/mash/example/window_type_launcher/window_type_launcher.cc
@@ -9,7 +9,7 @@
#include "mash/shell/public/interfaces/shell.mojom.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/layer.h"
@@ -164,8 +164,8 @@ class WindowTypeLauncherView : public views::WidgetDelegateView,
public views::MenuDelegate,
public views::ContextMenuController {
public:
- explicit WindowTypeLauncherView(mojo::Shell* shell)
- : shell_(shell),
+ explicit WindowTypeLauncherView(mojo::Connector* connector)
+ : connector_(connector),
create_button_(new views::LabelButton(
this, base::ASCIIToUTF16("Create Window"))),
panel_button_(new views::LabelButton(
@@ -274,7 +274,7 @@ class WindowTypeLauncherView : public views::WidgetDelegateView,
}
else if (sender == lock_button_) {
mash::shell::mojom::ShellPtr shell;
- shell_->ConnectToInterface("mojo:mash_shell", &shell);
+ connector_->ConnectToInterface("mojo:mash_shell", &shell);
shell->LockScreen();
}
else if (sender == widgets_button_) {
@@ -331,7 +331,7 @@ class WindowTypeLauncherView : public views::WidgetDelegateView,
}
}
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
views::LabelButton* create_button_;
views::LabelButton* panel_button_;
views::LabelButton* create_nonresizable_button_;
@@ -355,15 +355,16 @@ class WindowTypeLauncherView : public views::WidgetDelegateView,
WindowTypeLauncher::WindowTypeLauncher() {}
WindowTypeLauncher::~WindowTypeLauncher() {}
-void WindowTypeLauncher::Initialize(mojo::Shell* shell, const std::string& url,
+void WindowTypeLauncher::Initialize(mojo::Connector* connector,
+ const std::string& url,
uint32_t id, uint32_t user_id) {
- aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak"));
+ aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
- views::WindowManagerConnection::Create(shell);
+ views::WindowManagerConnection::Create(connector);
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
- params.delegate = new WindowTypeLauncherView(shell);
+ params.delegate = new WindowTypeLauncherView(connector);
widget->Init(params);
widget->Show();
}
diff --git a/mash/example/window_type_launcher/window_type_launcher.h b/mash/example/window_type_launcher/window_type_launcher.h
index 610c528..b162db7 100644
--- a/mash/example/window_type_launcher/window_type_launcher.h
+++ b/mash/example/window_type_launcher/window_type_launcher.h
@@ -20,7 +20,7 @@ class WindowTypeLauncher : public mojo::ShellClient {
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
scoped_ptr<views::AuraInit> aura_init_;
diff --git a/mash/quick_launch/quick_launch_application.cc b/mash/quick_launch/quick_launch_application.cc
index 8753f50..d378d9e 100644
--- a/mash/quick_launch/quick_launch_application.cc
+++ b/mash/quick_launch/quick_launch_application.cc
@@ -10,7 +10,7 @@
#include "mojo/public/c/system/main.h"
#include "mojo/services/tracing/public/cpp/tracing_impl.h"
#include "mojo/shell/public/cpp/application_runner.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "ui/views/background.h"
#include "ui/views/controls/textfield/textfield.h"
@@ -30,8 +30,8 @@ namespace quick_launch {
class QuickLaunchUI : public views::WidgetDelegateView,
public views::TextfieldController {
public:
- QuickLaunchUI(mojo::Shell* shell)
- : shell_(shell), prompt_(new views::Textfield) {
+ QuickLaunchUI(mojo::Connector* connector)
+ : connector_(connector), prompt_(new views::Textfield) {
set_background(views::Background::CreateStandardPanelBackground());
prompt_->set_controller(this);
AddChildView(prompt_);
@@ -63,7 +63,7 @@ class QuickLaunchUI : public views::WidgetDelegateView,
const ui::KeyEvent& key_event) override {
if (key_event.key_code() == ui::VKEY_RETURN) {
std::string url = Canonicalize(prompt_->text());
- connections_.push_back(shell_->Connect(url));
+ connections_.push_back(connector_->Connect(url));
prompt_->SetText(base::string16());
}
return false;
@@ -78,7 +78,7 @@ class QuickLaunchUI : public views::WidgetDelegateView,
return base::UTF16ToUTF8(working);
}
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
views::Textfield* prompt_;
std::vector<scoped_ptr<mojo::Connection>> connections_;
@@ -88,17 +88,17 @@ class QuickLaunchUI : public views::WidgetDelegateView,
QuickLaunchApplication::QuickLaunchApplication() {}
QuickLaunchApplication::~QuickLaunchApplication() {}
-void QuickLaunchApplication::Initialize(mojo::Shell* shell,
+void QuickLaunchApplication::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
- aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak"));
- views::WindowManagerConnection::Create(shell);
+ aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
+ views::WindowManagerConnection::Create(connector);
views::Widget* window = views::Widget::CreateWindowWithBounds(
- new QuickLaunchUI(shell), gfx::Rect(10, 640, 0, 0));
+ new QuickLaunchUI(connector), gfx::Rect(10, 640, 0, 0));
window->Show();
}
diff --git a/mash/quick_launch/quick_launch_application.h b/mash/quick_launch/quick_launch_application.h
index 07a6eba..c95f2a2 100644
--- a/mash/quick_launch/quick_launch_application.h
+++ b/mash/quick_launch/quick_launch_application.h
@@ -24,7 +24,7 @@ class QuickLaunchApplication : public mojo::ShellClient {
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell,
+ void Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) override;
diff --git a/mash/screenlock/screenlock.cc b/mash/screenlock/screenlock.cc
index e525664..e3bd229 100644
--- a/mash/screenlock/screenlock.cc
+++ b/mash/screenlock/screenlock.cc
@@ -10,7 +10,7 @@
#include "mash/shell/public/interfaces/shell.mojom.h"
#include "mash/wm/public/interfaces/container.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/mus/aura_init.h"
@@ -25,8 +25,8 @@ namespace {
class ScreenlockView : public views::WidgetDelegateView,
public views::ButtonListener {
public:
- explicit ScreenlockView(mojo::Shell* shell)
- : shell_(shell),
+ explicit ScreenlockView(mojo::Connector* connector)
+ : connector_(connector),
unlock_button_(
new views::LabelButton(this, base::ASCIIToUTF16("Unlock"))) {
set_background(views::Background::CreateSolidBackground(SK_ColorYELLOW));
@@ -60,11 +60,11 @@ class ScreenlockView : public views::WidgetDelegateView,
void ButtonPressed(views::Button* sender, const ui::Event& event) override {
DCHECK_EQ(sender, unlock_button_);
mash::shell::mojom::ShellPtr shell;
- shell_->ConnectToInterface("mojo:mash_shell", &shell);
+ connector_->ConnectToInterface("mojo:mash_shell", &shell);
shell->UnlockScreen();
}
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
views::LabelButton* unlock_button_;
DISALLOW_COPY_AND_ASSIGN(ScreenlockView);
@@ -72,26 +72,25 @@ class ScreenlockView : public views::WidgetDelegateView,
} // namespace
-Screenlock::Screenlock() : shell_(nullptr) {}
+Screenlock::Screenlock() {}
Screenlock::~Screenlock() {}
-void Screenlock::Initialize(mojo::Shell* shell, const std::string& url,
+void Screenlock::Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) {
- shell_ = shell;
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
mash::shell::mojom::ShellPtr mash_shell;
- shell_->ConnectToInterface("mojo:mash_shell", &mash_shell);
+ connector->ConnectToInterface("mojo:mash_shell", &mash_shell);
mash_shell->AddScreenlockStateListener(
bindings_.CreateInterfacePtrAndBind(this));
- aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak"));
- views::WindowManagerConnection::Create(shell);
+ aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
+ views::WindowManagerConnection::Create(connector);
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.delegate = new ScreenlockView(shell);
+ params.delegate = new ScreenlockView(connector);
std::map<std::string, std::vector<uint8_t>> properties;
properties[mash::wm::mojom::kWindowContainer_Property] =
@@ -100,14 +99,14 @@ void Screenlock::Initialize(mojo::Shell* shell, const std::string& url,
mus::Window* window =
views::WindowManagerConnection::Get()->NewWindow(properties);
params.native_widget = new views::NativeWidgetMus(
- widget, shell, window, mus::mojom::SurfaceType::DEFAULT);
+ widget, connector, window, mus::mojom::SurfaceType::DEFAULT);
widget->Init(params);
widget->Show();
}
void Screenlock::ScreenlockStateChanged(bool screen_locked) {
if (!screen_locked)
- shell_->Quit();
+ base::MessageLoop::current()->QuitWhenIdle();
}
} // namespace screenlock
diff --git a/mash/screenlock/screenlock.h b/mash/screenlock/screenlock.h
index e05a46c..e87995f 100644
--- a/mash/screenlock/screenlock.h
+++ b/mash/screenlock/screenlock.h
@@ -29,13 +29,12 @@ class Screenlock : public mojo::ShellClient,
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
// mash::shell::mojom::ScreenlockStateListener:
void ScreenlockStateChanged(bool locked) override;
- mojo::Shell* shell_;
mojo::TracingImpl tracing_;
scoped_ptr<views::AuraInit> aura_init_;
mojo::BindingSet<mash::shell::mojom::ScreenlockStateListener> bindings_;
diff --git a/mash/shell/shell_application_delegate.cc b/mash/shell/shell_application_delegate.cc
index 9972514..c37dac9 100644
--- a/mash/shell/shell_application_delegate.cc
+++ b/mash/shell/shell_application_delegate.cc
@@ -7,21 +7,21 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mash {
namespace shell {
ShellApplicationDelegate::ShellApplicationDelegate()
- : shell_(nullptr), screen_locked_(false) {}
+ : connector_(nullptr), screen_locked_(false) {}
ShellApplicationDelegate::~ShellApplicationDelegate() {}
-void ShellApplicationDelegate::Initialize(mojo::Shell* shell,
+void ShellApplicationDelegate::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- shell_ = shell;
+ connector_ = connector;
StartBrowserDriver();
StartWindowManager();
StartSystemUI();
@@ -111,7 +111,7 @@ void ShellApplicationDelegate::StartRestartableService(
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::Connection> connection = shell_->Connect(url);
+ scoped_ptr<mojo::Connection> connection = connector_->Connect(url);
// Note: |connection| may be null if we've lost our connection to the shell.
if (connection) {
connection->SetRemoteInterfaceProviderConnectionErrorHandler(
diff --git a/mash/shell/shell_application_delegate.h b/mash/shell/shell_application_delegate.h
index 524a554..a429f34a 100644
--- a/mash/shell/shell_application_delegate.h
+++ b/mash/shell/shell_application_delegate.h
@@ -33,7 +33,7 @@ class ShellApplicationDelegate
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
@@ -60,7 +60,7 @@ class ShellApplicationDelegate
void StartRestartableService(const std::string& url,
const base::Closure& restart_callback);
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
std::map<std::string, scoped_ptr<mojo::Connection>> connections_;
bool screen_locked_;
mojo::BindingSet<mash::shell::mojom::Shell> bindings_;
diff --git a/mash/task_viewer/task_viewer.cc b/mash/task_viewer/task_viewer.cc
index 552104f..1c2340e 100644
--- a/mash/task_viewer/task_viewer.cc
+++ b/mash/task_viewer/task_viewer.cc
@@ -16,7 +16,7 @@
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/services/package_manager/public/interfaces/catalog.mojom.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/interfaces/application_manager.mojom.h"
#include "ui/base/models/table_model.h"
#include "ui/views/background.h"
@@ -42,11 +42,9 @@ class TaskViewerContents
public mojo::shell::mojom::ApplicationManagerListener {
public:
TaskViewerContents(ListenerRequest request,
- package_manager::mojom::CatalogPtr catalog,
- scoped_ptr<mojo::AppRefCount> app)
+ package_manager::mojom::CatalogPtr catalog)
: binding_(this, std::move(request)),
catalog_(std::move(catalog)),
- app_(std::move(app)),
table_view_(nullptr),
table_view_parent_(nullptr),
kill_button_(
@@ -69,6 +67,7 @@ class TaskViewerContents
}
~TaskViewerContents() override {
table_view_->SetModel(nullptr);
+ base::MessageLoop::current()->QuitWhenIdle();
}
private:
@@ -246,7 +245,6 @@ class TaskViewerContents
mojo::Binding<mojo::shell::mojom::ApplicationManagerListener> binding_;
package_manager::mojom::CatalogPtr catalog_;
- scoped_ptr<mojo::AppRefCount> app_;
views::TableView* table_view_;
views::View* table_view_parent_;
@@ -265,25 +263,26 @@ class TaskViewerContents
TaskViewer::TaskViewer() {}
TaskViewer::~TaskViewer() {}
-void TaskViewer::Initialize(mojo::Shell* shell, const std::string& url,
+void TaskViewer::Initialize(mojo::Connector* connector,
+ const std::string& url,
uint32_t id, uint32_t user_id) {
- tracing_.Initialize(shell, url);
+ tracing_.Initialize(connector, url);
- aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak"));
- views::WindowManagerConnection::Create(shell);
+ aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
+ views::WindowManagerConnection::Create(connector);
mojo::shell::mojom::ApplicationManagerPtr application_manager;
- shell->ConnectToInterface("mojo:shell", &application_manager);
+ connector->ConnectToInterface("mojo:shell", &application_manager);
mojo::shell::mojom::ApplicationManagerListenerPtr listener;
ListenerRequest request = GetProxy(&listener);
application_manager->AddListener(std::move(listener));
package_manager::mojom::CatalogPtr catalog;
- shell->ConnectToInterface("mojo:package_manager", &catalog);
+ connector->ConnectToInterface("mojo:package_manager", &catalog);
TaskViewerContents* task_viewer = new TaskViewerContents(
- std::move(request), std::move(catalog), shell->CreateAppRefCount());
+ std::move(request), std::move(catalog));
views::Widget* window = views::Widget::CreateWindowWithBounds(
task_viewer, gfx::Rect(10, 10, 500, 500));
window->Show();
diff --git a/mash/task_viewer/task_viewer.h b/mash/task_viewer/task_viewer.h
index 0af60ef..5de6028 100644
--- a/mash/task_viewer/task_viewer.h
+++ b/mash/task_viewer/task_viewer.h
@@ -27,7 +27,7 @@ class TaskViewer : public mojo::ShellClient {
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
mojo::TracingImpl tracing_;
diff --git a/mash/wm/accelerator_registrar_apptest.cc b/mash/wm/accelerator_registrar_apptest.cc
index f7c31ae..a16d210 100644
--- a/mash/wm/accelerator_registrar_apptest.cc
+++ b/mash/wm/accelerator_registrar_apptest.cc
@@ -72,7 +72,7 @@ class AcceleratorRegistrarTest : public mojo::test::ApplicationTestBase {
protected:
void ConnectToRegistrar(AcceleratorRegistrarPtr* registrar) {
- shell()->ConnectToInterface("mojo:desktop_wm", registrar);
+ connector()->ConnectToInterface("mojo:desktop_wm", registrar);
}
private:
diff --git a/mash/wm/non_client_frame_controller.cc b/mash/wm/non_client_frame_controller.cc
index b35741f..ed6ad3a 100644
--- a/mash/wm/non_client_frame_controller.cc
+++ b/mash/wm/non_client_frame_controller.cc
@@ -90,9 +90,9 @@ class ContentWindowLayoutManager : public aura::LayoutManager {
class WmNativeWidgetMus : public views::NativeWidgetMus {
public:
WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate,
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::Window* window)
- : NativeWidgetMus(delegate, shell, window,
+ : NativeWidgetMus(delegate, connector, window,
mus::mojom::SurfaceType::UNDERLAY) {}
~WmNativeWidgetMus() override {
}
@@ -166,7 +166,7 @@ class ClientViewMus : public views::ClientView {
} // namespace
NonClientFrameController::NonClientFrameController(
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::Window* window,
mus::WindowManagerClient* window_manager_client)
: widget_(new views::Widget), window_(window) {
@@ -176,7 +176,7 @@ NonClientFrameController::NonClientFrameController(
// We initiate focus at the mus level, not at the views level.
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
params.delegate = this;
- params.native_widget = new WmNativeWidgetMus(widget_, shell, window);
+ params.native_widget = new WmNativeWidgetMus(widget_, connector, window);
widget_->Init(params);
widget_->ShowInactive();
diff --git a/mash/wm/non_client_frame_controller.h b/mash/wm/non_client_frame_controller.h
index b5346f2..c43cf73 100644
--- a/mash/wm/non_client_frame_controller.h
+++ b/mash/wm/non_client_frame_controller.h
@@ -17,7 +17,7 @@ class Insets;
}
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -33,7 +33,7 @@ class NonClientFrameController : public views::WidgetDelegateView,
public mus::WindowObserver {
public:
// NonClientFrameController deletes itself when |window| is destroyed.
- NonClientFrameController(mojo::Shell* shell,
+ NonClientFrameController(mojo::Connector* connector,
mus::Window* window,
mus::WindowManagerClient* window_manager_client);
diff --git a/mash/wm/root_window_controller.cc b/mash/wm/root_window_controller.cc
index d46cd78..03de79e 100644
--- a/mash/wm/root_window_controller.cc
+++ b/mash/wm/root_window_controller.cc
@@ -21,7 +21,7 @@
#include "mash/wm/window_layout.h"
#include "mash/wm/window_manager.h"
#include "mash/wm/window_manager_application.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mash {
namespace wm {
@@ -39,7 +39,7 @@ void AssertTrue(bool success) {
RootWindowController* RootWindowController::CreateUsingWindowTreeHost(
WindowManagerApplication* app) {
RootWindowController* controller = new RootWindowController(app);
- mus::CreateWindowTreeHost(app->shell(), controller,
+ mus::CreateWindowTreeHost(app->connector(), controller,
&controller->window_tree_host_,
controller->window_manager_.get());
return controller;
@@ -69,8 +69,8 @@ void RootWindowController::Destroy() {
}
}
-mojo::Shell* RootWindowController::GetShell() {
- return app_->shell();
+mojo::Connector* RootWindowController::GetConnector() {
+ return app_->connector();
}
mus::Window* RootWindowController::GetWindowForContainer(
@@ -145,7 +145,7 @@ void RootWindowController::OnEmbed(mus::Window* root) {
AddAccelerators();
mash::shell::mojom::ShellPtr shell;
- app_->shell()->ConnectToInterface("mojo:mash_shell", &shell);
+ app_->connector()->ConnectToInterface("mojo:mash_shell", &shell);
window_manager_->Initialize(this, std::move(shell));
shadow_controller_.reset(new ShadowController(root->connection()));
diff --git a/mash/wm/root_window_controller.h b/mash/wm/root_window_controller.h
index 623b2e1..d254da5 100644
--- a/mash/wm/root_window_controller.h
+++ b/mash/wm/root_window_controller.h
@@ -13,7 +13,7 @@
#include "mojo/public/cpp/bindings/binding.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -45,7 +45,7 @@ class RootWindowController : public mus::WindowObserver,
// Deletes this.
void Destroy();
- mojo::Shell* GetShell();
+ mojo::Connector* GetConnector();
mus::Window* root() { return root_; }
diff --git a/mash/wm/window_manager.cc b/mash/wm/window_manager.cc
index d5b28a8..f57af0a 100644
--- a/mash/wm/window_manager.cc
+++ b/mash/wm/window_manager.cc
@@ -113,7 +113,7 @@ mus::Window* WindowManager::NewTopLevelWindow(
if (provide_non_client_frame) {
// NonClientFrameController deletes itself when |window| is destroyed.
- new NonClientFrameController(root_controller_->GetShell(), window,
+ new NonClientFrameController(root_controller_->GetConnector(), window,
root_controller_->window_manager_client());
}
diff --git a/mash/wm/window_manager_application.cc b/mash/wm/window_manager_application.cc
index f02f613..5f5089a 100644
--- a/mash/wm/window_manager_application.cc
+++ b/mash/wm/window_manager_application.cc
@@ -16,7 +16,7 @@
#include "mash/wm/user_window_controller_impl.h"
#include "mojo/services/tracing/public/cpp/tracing_impl.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/mojo/init/ui_init.h"
#include "ui/views/mus/aura_init.h"
#include "ui/views/mus/display_converter.h"
@@ -25,7 +25,7 @@ namespace mash {
namespace wm {
WindowManagerApplication::WindowManagerApplication()
- : shell_(nullptr), window_manager_factory_binding_(this) {}
+ : connector_(nullptr), window_manager_factory_binding_(this) {}
WindowManagerApplication::~WindowManagerApplication() {
// AcceleratorRegistrarImpl removes an observer in its destructor. Destroy
@@ -56,7 +56,7 @@ void WindowManagerApplication::OnRootWindowControllerGotRoot(
ui_init_.reset(new ui::mojo::UIInit(
views::GetDisplaysFromWindow(root_controller->root())));
- aura_init_.reset(new views::AuraInit(shell_, "mash_wm_resources.pak"));
+ aura_init_.reset(new views::AuraInit(connector_, "mash_wm_resources.pak"));
}
void WindowManagerApplication::OnRootWindowControllerDoneInit(
@@ -103,15 +103,15 @@ void WindowManagerApplication::OnAcceleratorRegistrarDestroyed(
accelerator_registrars_.erase(registrar);
}
-void WindowManagerApplication::Initialize(mojo::Shell* shell,
+void WindowManagerApplication::Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- shell_ = shell;
- tracing_.Initialize(shell, url);
+ connector_ = connector;
+ tracing_.Initialize(connector, url);
mus::mojom::WindowManagerFactoryServicePtr wm_factory_service;
- shell_->ConnectToInterface("mojo:mus", &wm_factory_service);
+ connector_->ConnectToInterface("mojo:mus", &wm_factory_service);
wm_factory_service->SetWindowManagerFactory(
window_manager_factory_binding_.CreateInterfacePtrAndBind());
diff --git a/mash/wm/window_manager_application.h b/mash/wm/window_manager_application.h
index 7f2806f..a716990 100644
--- a/mash/wm/window_manager_application.h
+++ b/mash/wm/window_manager_application.h
@@ -50,7 +50,7 @@ class WindowManagerApplication
WindowManagerApplication();
~WindowManagerApplication() override;
- mojo::Shell* shell() { return shell_; }
+ mojo::Connector* connector() { return connector_; }
// Returns the RootWindowControllers that have valid roots.
//
@@ -78,7 +78,7 @@ class WindowManagerApplication
void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar);
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
@@ -97,7 +97,7 @@ class WindowManagerApplication
mojo::InterfaceRequest<mus::mojom::WindowTreeClient>
client_request) override;
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
mojo::TracingImpl tracing_;
diff --git a/mash/wm/window_manager_apptest.cc b/mash/wm/window_manager_apptest.cc
index 6e6e9fb..7ea0a25 100644
--- a/mash/wm/window_manager_apptest.cc
+++ b/mash/wm/window_manager_apptest.cc
@@ -39,12 +39,12 @@ TEST_F(WindowManagerAppTest, OpenWindow) {
WindowTreeDelegateImpl window_tree_delegate;
// Bring up the the desktop_wm.
- shell()->Connect("mojo:desktop_wm");
+ connector()->Connect("mojo:desktop_wm");
// Connect to mus and create a new top level window. The request goes to
// the |desktop_wm|, but is async.
scoped_ptr<mus::WindowTreeConnection> connection(
- mus::WindowTreeConnection::Create(&window_tree_delegate, shell()));
+ mus::WindowTreeConnection::Create(&window_tree_delegate, connector()));
mus::Window* top_level_window = connection->NewTopLevelWindow(nullptr);
ASSERT_TRUE(top_level_window);
mus::Window* child_window = connection->NewWindow();
diff --git a/media/mojo/services/media_apptest.cc b/media/mojo/services/media_apptest.cc
index 9776508..5c496adb 100644
--- a/media/mojo/services/media_apptest.cc
+++ b/media/mojo/services/media_apptest.cc
@@ -59,7 +59,7 @@ class MediaAppTest : public mojo::test::ApplicationTestBase {
void SetUp() override {
ApplicationTestBase::SetUp();
- connection_ = shell()->Connect("mojo:media");
+ connection_ = connector()->Connect("mojo:media");
connection_->SetRemoteInterfaceProviderConnectionErrorHandler(
base::Bind(&MediaAppTest::ConnectionClosed, base::Unretained(this)));
diff --git a/media/mojo/services/mojo_media_application.cc b/media/mojo/services/mojo_media_application.cc
index d954bdd..0def56a 100644
--- a/media/mojo/services/mojo_media_application.cc
+++ b/media/mojo/services/mojo_media_application.cc
@@ -10,7 +10,7 @@
#include "media/mojo/services/mojo_media_client.h"
#include "media/mojo/services/service_factory_impl.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace media {
@@ -18,18 +18,18 @@ namespace media {
MojoMediaApplication::MojoMediaApplication(
scoped_ptr<MojoMediaClient> mojo_media_client)
: mojo_media_client_(std::move(mojo_media_client)),
- shell_(nullptr),
+ connector_(nullptr),
media_log_(new MediaLog()) {
DCHECK(mojo_media_client_);
}
MojoMediaApplication::~MojoMediaApplication() {}
-void MojoMediaApplication::Initialize(mojo::Shell* shell,
+void MojoMediaApplication::Initialize(mojo::Connector* connector,
const std::string& /* url */,
uint32_t /* id */,
uint32_t user_id) {
- shell_ = shell;
+ connector_ = connector;
mojo_media_client_->Initialize();
}
@@ -43,7 +43,7 @@ void MojoMediaApplication::Create(
mojo::InterfaceRequest<interfaces::ServiceFactory> request) {
// The created object is owned by the pipe.
new ServiceFactoryImpl(std::move(request), connection->GetRemoteInterfaces(),
- media_log_, shell_->CreateAppRefCount(),
+ media_log_, ref_factory_.CreateRef(),
mojo_media_client_.get());
}
diff --git a/media/mojo/services/mojo_media_application.h b/media/mojo/services/mojo_media_application.h
index ece3264..cd5f803 100644
--- a/media/mojo/services/mojo_media_application.h
+++ b/media/mojo/services/mojo_media_application.h
@@ -8,7 +8,8 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "media/mojo/interfaces/service_factory.mojom.h"
-#include "mojo/shell/public/cpp/interface_factory_impl.h"
+#include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "url/gurl.h"
@@ -26,7 +27,7 @@ class MojoMediaApplication
private:
// mojo::ShellClient implementation.
- void Initialize(mojo::Shell* shell,
+ void Initialize(mojo::Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) final;
@@ -41,8 +42,9 @@ class MojoMediaApplication
// a scoped_ptr here.
scoped_ptr<MojoMediaClient> mojo_media_client_;
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
scoped_refptr<MediaLog> media_log_;
+ mojo::MessageLoopRefFactory ref_factory_;
};
} // namespace media
diff --git a/media/mojo/services/service_factory_impl.cc b/media/mojo/services/service_factory_impl.cc
index 5782241..28832be 100644
--- a/media/mojo/services/service_factory_impl.cc
+++ b/media/mojo/services/service_factory_impl.cc
@@ -19,7 +19,7 @@ ServiceFactoryImpl::ServiceFactoryImpl(
mojo::InterfaceRequest<interfaces::ServiceFactory> request,
mojo::shell::mojom::InterfaceProvider* interfaces,
scoped_refptr<MediaLog> media_log,
- scoped_ptr<mojo::AppRefCount> parent_app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> parent_app_refcount,
MojoMediaClient* mojo_media_client)
: binding_(this, std::move(request)),
interfaces_(interfaces),
diff --git a/media/mojo/services/service_factory_impl.h b/media/mojo/services/service_factory_impl.h
index 5120586..37a50ff 100644
--- a/media/mojo/services/service_factory_impl.h
+++ b/media/mojo/services/service_factory_impl.h
@@ -10,10 +10,11 @@
#include "media/mojo/interfaces/service_factory.mojom.h"
#include "media/mojo/services/mojo_cdm_service_context.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
namespace mojo {
-class AppRefCount;
+class MessageLoopRef;
namespace shell {
namespace mojom {
class InterfaceProvider;
@@ -33,7 +34,7 @@ class ServiceFactoryImpl : public interfaces::ServiceFactory {
ServiceFactoryImpl(mojo::InterfaceRequest<interfaces::ServiceFactory> request,
mojo::shell::mojom::InterfaceProvider* interfaces,
scoped_refptr<MediaLog> media_log,
- scoped_ptr<mojo::AppRefCount> parent_app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> parent_app_refcount,
MojoMediaClient* mojo_media_client);
~ServiceFactoryImpl() final;
@@ -52,7 +53,7 @@ class ServiceFactoryImpl : public interfaces::ServiceFactory {
mojo::StrongBinding<interfaces::ServiceFactory> binding_;
mojo::shell::mojom::InterfaceProvider* interfaces_;
scoped_refptr<MediaLog> media_log_;
- scoped_ptr<mojo::AppRefCount> parent_app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> parent_app_refcount_;
MojoMediaClient* mojo_media_client_;
scoped_ptr<RendererFactory> renderer_factory_;
diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc
index 87ee95b..80871f9 100644
--- a/media/test/pipeline_integration_test.cc
+++ b/media/test/pipeline_integration_test.cc
@@ -662,7 +662,7 @@ class PipelineIntegrationTestHost : public mojo::test::ApplicationTestBase,
protected:
scoped_ptr<Renderer> CreateRenderer() override {
- shell()->ConnectToInterface("mojo:media", &media_service_factory_);
+ connector()->ConnectToInterface("mojo:media", &media_service_factory_);
interfaces::RendererPtr mojo_renderer;
media_service_factory_->CreateRenderer(mojo::GetProxy(&mojo_renderer));
diff --git a/mojo/public/cpp/bindings/tests/versioning_apptest.cc b/mojo/public/cpp/bindings/tests/versioning_apptest.cc
index 7c74c45..6b6a3f3 100644
--- a/mojo/public/cpp/bindings/tests/versioning_apptest.cc
+++ b/mojo/public/cpp/bindings/tests/versioning_apptest.cc
@@ -8,7 +8,7 @@
#include "mojo/public/cpp/system/macros.h"
#include "mojo/public/interfaces/bindings/tests/versioning_test_client.mojom.h"
#include "mojo/shell/public/cpp/application_test_base.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mojo {
namespace test {
@@ -24,7 +24,7 @@ class VersioningApplicationTest : public ApplicationTestBase {
void SetUp() override {
ApplicationTestBase::SetUp();
- shell()->ConnectToInterface("mojo:versioning_test_service", &database_);
+ connector()->ConnectToInterface("mojo:versioning_test_service", &database_);
}
HumanResourceDatabasePtr database_;
diff --git a/mojo/services/network/cookie_store_impl.cc b/mojo/services/network/cookie_store_impl.cc
index acee535..ebd0c92 100644
--- a/mojo/services/network/cookie_store_impl.cc
+++ b/mojo/services/network/cookie_store_impl.cc
@@ -28,7 +28,7 @@ void AdaptSetCookieCallback(const Callback<void(bool)>& callback,
CookieStoreImpl::CookieStoreImpl(NetworkContext* context,
const GURL& origin,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<CookieStore> request)
: context_(context),
origin_(origin),
diff --git a/mojo/services/network/cookie_store_impl.h b/mojo/services/network/cookie_store_impl.h
index a4dfb09..224490c 100644
--- a/mojo/services/network/cookie_store_impl.h
+++ b/mojo/services/network/cookie_store_impl.h
@@ -8,7 +8,7 @@
#include "base/macros.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/cookie_store.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "url/gurl.h"
namespace mojo {
@@ -18,7 +18,7 @@ class CookieStoreImpl : public CookieStore {
public:
CookieStoreImpl(NetworkContext* context,
const GURL& origin,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<CookieStore> request);
~CookieStoreImpl() override;
@@ -31,7 +31,7 @@ class CookieStoreImpl : public CookieStore {
NetworkContext* context_;
GURL origin_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
StrongBinding<CookieStore> binding_;
DISALLOW_COPY_AND_ASSIGN(CookieStoreImpl);
diff --git a/mojo/services/network/http_server_apptest.cc b/mojo/services/network/http_server_apptest.cc
index b7e47dd..24b070a 100644
--- a/mojo/services/network/http_server_apptest.cc
+++ b/mojo/services/network/http_server_apptest.cc
@@ -557,7 +557,7 @@ class HttpServerAppTest : public test::ApplicationTestBase {
ApplicationTestBase::SetUp();
scoped_ptr<Connection> connection =
- shell()->Connect("mojo:network_service");
+ connector()->Connect("mojo:network_service");
connection->GetInterface(&network_service_);
connection->GetInterface(&web_socket_factory_);
}
diff --git a/mojo/services/network/http_server_impl.cc b/mojo/services/network/http_server_impl.cc
index cc14221..b7e080a 100644
--- a/mojo/services/network/http_server_impl.cc
+++ b/mojo/services/network/http_server_impl.cc
@@ -27,7 +27,7 @@ const int kBackLog = 10;
void HttpServerImpl::Create(
NetAddressPtr local_address,
HttpServerDelegatePtr delegate,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) {
HttpServerImpl* http_server =
new HttpServerImpl(std::move(delegate), std::move(app_refcount));
@@ -42,7 +42,7 @@ void HttpServerImpl::Create(
}
HttpServerImpl::HttpServerImpl(HttpServerDelegatePtr delegate,
- scoped_ptr<mojo::AppRefCount> app_refcount)
+ scoped_ptr<mojo::MessageLoopRef> app_refcount)
: delegate_(std::move(delegate)), app_refcount_(std::move(app_refcount)) {
DCHECK(delegate_);
delegate_.set_connection_error_handler([this]() { delete this; });
diff --git a/mojo/services/network/http_server_impl.h b/mojo/services/network/http_server_impl.h
index a631146..f79b7a8 100644
--- a/mojo/services/network/http_server_impl.h
+++ b/mojo/services/network/http_server_impl.h
@@ -12,7 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/services/network/public/interfaces/http_server.mojom.h"
#include "mojo/services/network/public/interfaces/net_address.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "net/server/http_server.h"
namespace net {
@@ -28,7 +28,7 @@ class HttpServerImpl : public net::HttpServer::Delegate {
static void Create(
NetAddressPtr local_address,
HttpServerDelegatePtr delegate,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback);
net::HttpServer* server() { return server_.get(); }
@@ -39,7 +39,7 @@ class HttpServerImpl : public net::HttpServer::Delegate {
// notified that |delegate|'s pipe is closed. Deleting the object directly
// before that is okay, too.
HttpServerImpl(HttpServerDelegatePtr delegate,
- scoped_ptr<mojo::AppRefCount> app_refcount);
+ scoped_ptr<mojo::MessageLoopRef> app_refcount);
~HttpServerImpl() override;
int Start(NetAddressPtr local_address);
@@ -55,7 +55,7 @@ class HttpServerImpl : public net::HttpServer::Delegate {
void OnClose(int connection_id) override;
HttpServerDelegatePtr delegate_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
scoped_ptr<net::HttpServer> server_;
std::map<int, linked_ptr<HttpConnectionImpl>> connections_;
diff --git a/mojo/services/network/network_service_delegate.cc b/mojo/services/network/network_service_delegate.cc
index a3a0ea3..9f54082 100644
--- a/mojo/services/network/network_service_delegate.cc
+++ b/mojo/services/network/network_service_delegate.cc
@@ -31,12 +31,11 @@ const char kUserDataDir[] = "user-data-dir";
namespace mojo {
-NetworkServiceDelegate::NetworkServiceDelegate()
- : shell_(nullptr) {
-}
-
-NetworkServiceDelegate::~NetworkServiceDelegate() {
+NetworkServiceDelegate::NetworkServiceDelegate() {
+ ref_factory_.set_quit_closure(
+ base::Bind(&NetworkServiceDelegate::Quit, base::Unretained(this)));
}
+NetworkServiceDelegate::~NetworkServiceDelegate() {}
void NetworkServiceDelegate::AddObserver(
NetworkServiceDelegateObserver* observer) {
@@ -48,10 +47,9 @@ void NetworkServiceDelegate::RemoveObserver(
observers_.RemoveObserver(observer);
}
-void NetworkServiceDelegate::Initialize(Shell* shell, const std::string& url,
+void NetworkServiceDelegate::Initialize(Connector* connector,
+ const std::string& url,
uint32_t id, uint32_t user_id) {
- shell_ = shell;
-
// TODO(erg): Find everything else that writes to the filesystem and
// transition it to proxying mojo:filesystem. We shouldn't have any path
// calculation code here, but sadly need it until the transition is done. In
@@ -68,7 +66,7 @@ void NetworkServiceDelegate::Initialize(Shell* shell, const std::string& url,
}
context_.reset(new NetworkContext(base_path, this));
- tracing_.Initialize(shell_, url);
+ tracing_.Initialize(connector, url);
}
bool NetworkServiceDelegate::AcceptConnection(Connection* connection) {
@@ -84,37 +82,37 @@ bool NetworkServiceDelegate::ShellConnectionLost() {
return true;
}
-void NetworkServiceDelegate::Quit() {
- // Destroy the NetworkContext now as it requires MessageLoop::current() upon
- // destruction and it is the last moment we know for sure that it is
- // running.
- context_.reset();
-}
-
void NetworkServiceDelegate::Create(Connection* connection,
InterfaceRequest<NetworkService> request) {
- new NetworkServiceImpl(shell_->CreateAppRefCount(), std::move(request));
+ new NetworkServiceImpl(ref_factory_.CreateRef(), std::move(request));
}
void NetworkServiceDelegate::Create(Connection* connection,
InterfaceRequest<CookieStore> request) {
new CookieStoreImpl(
context_.get(), GURL(connection->GetRemoteApplicationURL()).GetOrigin(),
- shell_->CreateAppRefCount(), std::move(request));
+ ref_factory_.CreateRef(), std::move(request));
}
void NetworkServiceDelegate::Create(
Connection* connection,
InterfaceRequest<WebSocketFactory> request) {
- new WebSocketFactoryImpl(context_.get(), shell_->CreateAppRefCount(),
+ new WebSocketFactoryImpl(context_.get(), ref_factory_.CreateRef(),
std::move(request));
}
void NetworkServiceDelegate::Create(
Connection* connection,
InterfaceRequest<URLLoaderFactory> request) {
- new URLLoaderFactoryImpl(context_.get(), shell_->CreateAppRefCount(),
+ new URLLoaderFactoryImpl(context_.get(), ref_factory_.CreateRef(),
std::move(request));
}
+void NetworkServiceDelegate::Quit() {
+ // Destroy the NetworkContext now as it requires MessageLoop::current() upon
+ // destruction and it is the last moment we know for sure that it is
+ // running.
+ context_.reset();
+}
+
} // namespace mojo
diff --git a/mojo/services/network/network_service_delegate.h b/mojo/services/network/network_service_delegate.h
index 678db5a..4159f2a 100644
--- a/mojo/services/network/network_service_delegate.h
+++ b/mojo/services/network/network_service_delegate.h
@@ -5,6 +5,7 @@
#ifndef MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_
#define MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_
+#include "base/macros.h"
#include "base/observer_list.h"
#include "base/threading/thread.h"
#include "mojo/services/network/network_context.h"
@@ -14,7 +15,7 @@
#include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
#include "mojo/services/tracing/public/cpp/tracing_impl.h"
#include "mojo/shell/public/cpp/interface_factory.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "mojo/shell/public/cpp/shell_client.h"
namespace mojo {
@@ -34,11 +35,10 @@ class NetworkServiceDelegate : public ShellClient,
private:
// mojo::ShellClient implementation.
- void Initialize(Shell* shell, const std::string& url,
+ void Initialize(Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(Connection* connection) override;
bool ShellConnectionLost() override;
- void Quit() override;
// InterfaceFactory<NetworkService> implementation.
void Create(Connection* connection,
@@ -57,13 +57,18 @@ class NetworkServiceDelegate : public ShellClient,
InterfaceRequest<URLLoaderFactory> request) override;
private:
- Shell* shell_;
+ void Quit();
+
mojo::TracingImpl tracing_;
// Observers that want notifications that our worker thread is going away.
base::ObserverList<NetworkServiceDelegateObserver> observers_;
scoped_ptr<NetworkContext> context_;
+
+ mojo::MessageLoopRefFactory ref_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkServiceDelegate);
};
} // namespace mojo
diff --git a/mojo/services/network/network_service_impl.cc b/mojo/services/network/network_service_impl.cc
index cacaf83..1557da8 100644
--- a/mojo/services/network/network_service_impl.cc
+++ b/mojo/services/network/network_service_impl.cc
@@ -16,7 +16,7 @@
namespace mojo {
NetworkServiceImpl::NetworkServiceImpl(
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<NetworkService> request)
: app_refcount_(std::move(app_refcount)),
binding_(this, std::move(request)) {}
diff --git a/mojo/services/network/network_service_impl.h b/mojo/services/network/network_service_impl.h
index fa5ffe02..014ca0f 100644
--- a/mojo/services/network/network_service_impl.h
+++ b/mojo/services/network/network_service_impl.h
@@ -8,14 +8,14 @@
#include "base/compiler_specific.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/network_service.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "url/gurl.h"
namespace mojo {
class NetworkServiceImpl : public NetworkService {
public:
- NetworkServiceImpl(scoped_ptr<mojo::AppRefCount> app_refcount,
+ NetworkServiceImpl(scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<NetworkService> request);
~NetworkServiceImpl() override;
@@ -39,7 +39,7 @@ class NetworkServiceImpl : public NetworkService {
const GetMimeTypeFromFileCallback& callback) override;
private:
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
StrongBinding<NetworkService> binding_;
};
diff --git a/mojo/services/network/tcp_bound_socket_impl.cc b/mojo/services/network/tcp_bound_socket_impl.cc
index d8a60b7..1d8669f 100644
--- a/mojo/services/network/tcp_bound_socket_impl.cc
+++ b/mojo/services/network/tcp_bound_socket_impl.cc
@@ -15,7 +15,7 @@
namespace mojo {
TCPBoundSocketImpl::TCPBoundSocketImpl(
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<TCPBoundSocket> request)
: app_refcount_(std::move(app_refcount)),
binding_(this, std::move(request)) {}
diff --git a/mojo/services/network/tcp_bound_socket_impl.h b/mojo/services/network/tcp_bound_socket_impl.h
index 5cb256e..8e4b2e8 100644
--- a/mojo/services/network/tcp_bound_socket_impl.h
+++ b/mojo/services/network/tcp_bound_socket_impl.h
@@ -8,14 +8,14 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/tcp_bound_socket.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "net/socket/tcp_socket.h"
namespace mojo {
class TCPBoundSocketImpl : public TCPBoundSocket {
public:
- TCPBoundSocketImpl(scoped_ptr<mojo::AppRefCount> app_refcount,
+ TCPBoundSocketImpl(scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<TCPBoundSocket> request);
~TCPBoundSocketImpl() override;
@@ -47,7 +47,7 @@ class TCPBoundSocketImpl : public TCPBoundSocket {
ScopedDataPipeProducerHandle pending_connect_receive_stream_;
InterfaceRequest<TCPConnectedSocket> pending_connect_socket_;
Callback<void(NetworkErrorPtr)> pending_connect_callback_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
StrongBinding<TCPBoundSocket> binding_;
};
diff --git a/mojo/services/network/tcp_connected_socket_impl.cc b/mojo/services/network/tcp_connected_socket_impl.cc
index 8a6d0a0..8da9484 100644
--- a/mojo/services/network/tcp_connected_socket_impl.cc
+++ b/mojo/services/network/tcp_connected_socket_impl.cc
@@ -19,7 +19,7 @@ TCPConnectedSocketImpl::TCPConnectedSocketImpl(
ScopedDataPipeConsumerHandle send_stream,
ScopedDataPipeProducerHandle receive_stream,
InterfaceRequest<TCPConnectedSocket> request,
- scoped_ptr<mojo::AppRefCount> app_refcount)
+ scoped_ptr<mojo::MessageLoopRef> app_refcount)
: socket_(std::move(socket)),
send_stream_(std::move(send_stream)),
receive_stream_(std::move(receive_stream)),
diff --git a/mojo/services/network/tcp_connected_socket_impl.h b/mojo/services/network/tcp_connected_socket_impl.h
index 4611189..1131bf6 100644
--- a/mojo/services/network/tcp_connected_socket_impl.h
+++ b/mojo/services/network/tcp_connected_socket_impl.h
@@ -10,7 +10,7 @@
#include "mojo/message_pump/handle_watcher.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/services/network/public/interfaces/tcp_connected_socket.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "net/socket/tcp_socket.h"
namespace mojo {
@@ -24,7 +24,7 @@ class TCPConnectedSocketImpl : public TCPConnectedSocket {
ScopedDataPipeConsumerHandle send_stream,
ScopedDataPipeProducerHandle receive_stream,
InterfaceRequest<TCPConnectedSocket> request,
- scoped_ptr<mojo::AppRefCount> app_refcount);
+ scoped_ptr<mojo::MessageLoopRef> app_refcount);
~TCPConnectedSocketImpl() override;
private:
@@ -69,7 +69,7 @@ class TCPConnectedSocketImpl : public TCPConnectedSocket {
// To bind to the message pipe.
Binding<TCPConnectedSocket> binding_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_;
};
diff --git a/mojo/services/network/tcp_server_socket_impl.cc b/mojo/services/network/tcp_server_socket_impl.cc
index 2762964..a01feff 100644
--- a/mojo/services/network/tcp_server_socket_impl.cc
+++ b/mojo/services/network/tcp_server_socket_impl.cc
@@ -15,7 +15,7 @@ namespace mojo {
TCPServerSocketImpl::TCPServerSocketImpl(
scoped_ptr<net::TCPSocket> socket,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<TCPServerSocket> request)
: socket_(std::move(socket)),
app_refcount_(std::move(app_refcount)),
diff --git a/mojo/services/network/tcp_server_socket_impl.h b/mojo/services/network/tcp_server_socket_impl.h
index 5149cb1..2078cec 100644
--- a/mojo/services/network/tcp_server_socket_impl.h
+++ b/mojo/services/network/tcp_server_socket_impl.h
@@ -8,7 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/tcp_server_socket.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "net/base/ip_endpoint.h"
#include "net/socket/tcp_socket.h"
@@ -20,7 +20,7 @@ class TCPServerSocketImpl : public TCPServerSocket {
// Passed ownership of a socket already in listening mode.
TCPServerSocketImpl(scoped_ptr<net::TCPSocket> socket,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<TCPServerSocket> request);
~TCPServerSocketImpl() override;
@@ -47,7 +47,7 @@ class TCPServerSocketImpl : public TCPServerSocket {
scoped_ptr<net::TCPSocket> accepted_socket_;
net::IPEndPoint accepted_address_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
StrongBinding<TCPServerSocket> binding_;
};
diff --git a/mojo/services/network/udp_socket_apptest.cc b/mojo/services/network/udp_socket_apptest.cc
index ac800e0..075a29c 100644
--- a/mojo/services/network/udp_socket_apptest.cc
+++ b/mojo/services/network/udp_socket_apptest.cc
@@ -324,7 +324,7 @@ class UDPSocketAppTest : public test::ApplicationTestBase {
void SetUp() override {
ApplicationTestBase::SetUp();
- shell()->ConnectToInterface("mojo:network_service", &network_service_);
+ connector()->ConnectToInterface("mojo:network_service", &network_service_);
network_service_->CreateUDPSocket(GetProxy(&socket_));
}
diff --git a/mojo/services/network/udp_socket_impl.cc b/mojo/services/network/udp_socket_impl.cc
index f87dcb0..c99f66f 100644
--- a/mojo/services/network/udp_socket_impl.cc
+++ b/mojo/services/network/udp_socket_impl.cc
@@ -37,7 +37,7 @@ UDPSocketImpl::PendingSendRequest::PendingSendRequest() {}
UDPSocketImpl::PendingSendRequest::~PendingSendRequest() {}
UDPSocketImpl::UDPSocketImpl(InterfaceRequest<UDPSocket> request,
- scoped_ptr<mojo::AppRefCount> app_refcount)
+ scoped_ptr<mojo::MessageLoopRef> app_refcount)
: binding_(this, std::move(request)),
socket_(net::DatagramSocket::DEFAULT_BIND,
net::RandIntCallback(),
diff --git a/mojo/services/network/udp_socket_impl.h b/mojo/services/network/udp_socket_impl.h
index 459ba9d..6ea5770 100644
--- a/mojo/services/network/udp_socket_impl.h
+++ b/mojo/services/network/udp_socket_impl.h
@@ -14,7 +14,7 @@
#include "base/memory/ref_counted.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/udp_socket.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "net/base/ip_endpoint.h"
#include "net/udp/udp_socket.h"
@@ -30,7 +30,7 @@ class UDPSocketImpl : public UDPSocket {
// The lifetime of a new UDPSocketImpl is bound to the connection associated
// with |request|.
UDPSocketImpl(InterfaceRequest<UDPSocket> request,
- scoped_ptr<mojo::AppRefCount> app_refcount);
+ scoped_ptr<mojo::MessageLoopRef> app_refcount);
~UDPSocketImpl() override;
// UDPSocket implementation.
@@ -123,7 +123,7 @@ class UDPSocketImpl : public UDPSocket {
// The maximum size of the |pending_send_requests_| queue.
size_t max_pending_send_requests_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
DISALLOW_COPY_AND_ASSIGN(UDPSocketImpl);
};
diff --git a/mojo/services/network/url_loader_factory_impl.cc b/mojo/services/network/url_loader_factory_impl.cc
index b14183c..2e19d5b 100644
--- a/mojo/services/network/url_loader_factory_impl.cc
+++ b/mojo/services/network/url_loader_factory_impl.cc
@@ -12,7 +12,7 @@ namespace mojo {
URLLoaderFactoryImpl::URLLoaderFactoryImpl(
NetworkContext* context,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<URLLoaderFactory> request)
: context_(context),
app_refcount_(std::move(app_refcount)),
diff --git a/mojo/services/network/url_loader_factory_impl.h b/mojo/services/network/url_loader_factory_impl.h
index 7b12556..0b59208 100644
--- a/mojo/services/network/url_loader_factory_impl.h
+++ b/mojo/services/network/url_loader_factory_impl.h
@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
namespace mojo {
class NetworkContext;
@@ -17,7 +17,7 @@ class NetworkContext;
class URLLoaderFactoryImpl : public URLLoaderFactory {
public:
URLLoaderFactoryImpl(NetworkContext* context,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<URLLoaderFactory> request);
~URLLoaderFactoryImpl() override;
@@ -26,7 +26,7 @@ class URLLoaderFactoryImpl : public URLLoaderFactory {
private:
NetworkContext* context_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
StrongBinding<URLLoaderFactory> binding_;
DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryImpl);
diff --git a/mojo/services/network/url_loader_impl.cc b/mojo/services/network/url_loader_impl.cc
index e8727ca..b6db54e 100644
--- a/mojo/services/network/url_loader_impl.cc
+++ b/mojo/services/network/url_loader_impl.cc
@@ -141,7 +141,7 @@ class UploadDataPipeElementReader : public net::UploadElementReader {
URLLoaderImpl::URLLoaderImpl(NetworkContext* context,
InterfaceRequest<URLLoader> request,
- scoped_ptr<mojo::AppRefCount> app_refcount)
+ scoped_ptr<mojo::MessageLoopRef> app_refcount)
: context_(context),
response_body_buffer_size_(0),
response_body_bytes_read_(0),
diff --git a/mojo/services/network/url_loader_impl.h b/mojo/services/network/url_loader_impl.h
index b8e6905..833eb86 100644
--- a/mojo/services/network/url_loader_impl.h
+++ b/mojo/services/network/url_loader_impl.h
@@ -12,7 +12,7 @@
#include "mojo/message_pump/handle_watcher.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/services/network/public/interfaces/url_loader.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
@@ -26,7 +26,7 @@ class URLLoaderImpl : public URLLoader,
public:
URLLoaderImpl(NetworkContext* context,
InterfaceRequest<URLLoader> request,
- scoped_ptr<mojo::AppRefCount> app_refcount);
+ scoped_ptr<mojo::MessageLoopRef> app_refcount);
~URLLoaderImpl() override;
// Called when the associated NetworkContext is going away.
@@ -70,7 +70,7 @@ class URLLoaderImpl : public URLLoader,
bool auto_follow_redirects_;
bool connected_;
Binding<URLLoader> binding_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_;
};
diff --git a/mojo/services/network/url_loader_impl_apptest.cc b/mojo/services/network/url_loader_impl_apptest.cc
index 90e7c96..fe7bd06 100644
--- a/mojo/services/network/url_loader_impl_apptest.cc
+++ b/mojo/services/network/url_loader_impl_apptest.cc
@@ -14,6 +14,7 @@
#include "mojo/services/network/network_context.h"
#include "mojo/services/network/url_loader_impl.h"
#include "mojo/shell/public/cpp/application_test_base.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request_job.h"
#include "net/url_request/url_request_job_factory_impl.h"
@@ -129,7 +130,7 @@ class UrlLoaderImplTest : public test::ApplicationTestBase {
MessagePipe pipe;
new URLLoaderImpl(network_context_.get(),
GetProxy(&url_loader_proxy_),
- make_scoped_ptr<mojo::AppRefCount>(nullptr));
+ make_scoped_ptr<mojo::MessageLoopRef>(nullptr));
EXPECT_TRUE(IsUrlLoaderValid());
}
diff --git a/mojo/services/network/web_socket_factory_impl.cc b/mojo/services/network/web_socket_factory_impl.cc
index ecd7272..6adde55 100644
--- a/mojo/services/network/web_socket_factory_impl.cc
+++ b/mojo/services/network/web_socket_factory_impl.cc
@@ -12,7 +12,7 @@ namespace mojo {
WebSocketFactoryImpl::WebSocketFactoryImpl(
NetworkContext* context,
- scoped_ptr<AppRefCount> app_refcount,
+ scoped_ptr<MessageLoopRef> app_refcount,
InterfaceRequest<WebSocketFactory> request)
: context_(context),
app_refcount_(std::move(app_refcount)),
diff --git a/mojo/services/network/web_socket_factory_impl.h b/mojo/services/network/web_socket_factory_impl.h
index 2763e7f4..ca254ca 100644
--- a/mojo/services/network/web_socket_factory_impl.h
+++ b/mojo/services/network/web_socket_factory_impl.h
@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
namespace mojo {
class NetworkContext;
@@ -17,7 +17,7 @@ class NetworkContext;
class WebSocketFactoryImpl : public WebSocketFactory {
public:
WebSocketFactoryImpl(NetworkContext* context,
- scoped_ptr<AppRefCount> app_refcount,
+ scoped_ptr<MessageLoopRef> app_refcount,
InterfaceRequest<WebSocketFactory> request);
~WebSocketFactoryImpl() override;
@@ -26,7 +26,7 @@ class WebSocketFactoryImpl : public WebSocketFactory {
private:
NetworkContext* context_;
- scoped_ptr<AppRefCount> app_refcount_;
+ scoped_ptr<MessageLoopRef> app_refcount_;
StrongBinding<WebSocketFactory> binding_;
DISALLOW_COPY_AND_ASSIGN(WebSocketFactoryImpl);
diff --git a/mojo/services/network/web_socket_impl.cc b/mojo/services/network/web_socket_impl.cc
index 459b531..2d89149 100644
--- a/mojo/services/network/web_socket_impl.cc
+++ b/mojo/services/network/web_socket_impl.cc
@@ -182,7 +182,7 @@ void WebSocketEventHandler::DidWriteToReceiveStream(
} // namespace mojo
WebSocketImpl::WebSocketImpl(NetworkContext* context,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<WebSocket> request)
: context_(context),
app_refcount_(std::move(app_refcount)),
diff --git a/mojo/services/network/web_socket_impl.h b/mojo/services/network/web_socket_impl.h
index 30b7cc2..06fd3ca 100644
--- a/mojo/services/network/web_socket_impl.h
+++ b/mojo/services/network/web_socket_impl.h
@@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/public/interfaces/web_socket.mojom.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/message_loop_ref.h"
namespace net {
class WebSocketChannel;
@@ -25,7 +25,7 @@ class WebSocketReadQueue;
class WebSocketImpl : public WebSocket {
public:
WebSocketImpl(NetworkContext* context,
- scoped_ptr<mojo::AppRefCount> app_refcount,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
InterfaceRequest<WebSocket> request);
~WebSocketImpl() override;
@@ -51,7 +51,7 @@ class WebSocketImpl : public WebSocket {
ScopedDataPipeConsumerHandle send_stream_;
scoped_ptr<WebSocketReadQueue> read_queue_;
NetworkContext* context_;
- scoped_ptr<mojo::AppRefCount> app_refcount_;
+ scoped_ptr<mojo::MessageLoopRef> app_refcount_;
StrongBinding<WebSocket> binding_;
};
diff --git a/mojo/services/package_manager/package_manager.cc b/mojo/services/package_manager/package_manager.cc
index ce6e1a69..54ec917 100644
--- a/mojo/services/package_manager/package_manager.cc
+++ b/mojo/services/package_manager/package_manager.cc
@@ -107,9 +107,6 @@ PackageManager::PackageManager(base::TaskRunner* blocking_pool,
}
PackageManager::~PackageManager() {}
-void PackageManager::Initialize(mojo::Shell* shell, const std::string& url,
- uint32_t id, uint32_t user_id) {}
-
bool PackageManager::AcceptConnection(mojo::Connection* connection) {
connection->AddInterface<mojom::Catalog>(this);
connection->AddInterface<mojom::Resolver>(this);
diff --git a/mojo/services/package_manager/package_manager.h b/mojo/services/package_manager/package_manager.h
index e587cc6..dc36d8e 100644
--- a/mojo/services/package_manager/package_manager.h
+++ b/mojo/services/package_manager/package_manager.h
@@ -14,7 +14,6 @@
#include "mojo/services/package_manager/public/interfaces/resolver.mojom.h"
#include "mojo/services/package_manager/public/interfaces/shell_resolver.mojom.h"
#include "mojo/shell/public/cpp/interface_factory.h"
-#include "mojo/shell/public/cpp/shell.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "url/gurl.h"
@@ -80,8 +79,6 @@ class PackageManager : public mojo::ShellClient,
using MojoURLAliasMap = std::map<GURL, std::pair<GURL, std::string>>;
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
- uint32_t id, uint32_t user_id) override;
bool AcceptConnection(mojo::Connection* connection) override;
// mojo::InterfaceFactory<mojom::Resolver>:
diff --git a/mojo/services/test_service/test_request_tracker_application.cc b/mojo/services/test_service/test_request_tracker_application.cc
index 73190b00..0b5d27a 100644
--- a/mojo/services/test_service/test_request_tracker_application.cc
+++ b/mojo/services/test_service/test_request_tracker_application.cc
@@ -15,15 +15,14 @@
namespace mojo {
namespace test {
-TestRequestTrackerApplication::TestRequestTrackerApplication()
- : shell_(nullptr) {}
+TestRequestTrackerApplication::TestRequestTrackerApplication() {}
TestRequestTrackerApplication::~TestRequestTrackerApplication() {}
-void TestRequestTrackerApplication::Initialize(Shell* shell,
+void TestRequestTrackerApplication::Initialize(Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id) {
- shell_ = shell;
+ connector_ = connector;
}
bool TestRequestTrackerApplication::AcceptConnection(Connection* connection) {
@@ -38,7 +37,7 @@ bool TestRequestTrackerApplication::AcceptConnection(Connection* connection) {
void TestRequestTrackerApplication::Create(
Connection* connection,
InterfaceRequest<TestTimeService> request) {
- new TestTimeServiceImpl(shell_, std::move(request));
+ new TestTimeServiceImpl(connector_, std::move(request));
}
void TestRequestTrackerApplication::Create(
diff --git a/mojo/services/test_service/test_request_tracker_application.h b/mojo/services/test_service/test_request_tracker_application.h
index 22206f9..a3dde4a 100644
--- a/mojo/services/test_service/test_request_tracker_application.h
+++ b/mojo/services/test_service/test_request_tracker_application.h
@@ -26,7 +26,7 @@ class TestRequestTrackerApplication
~TestRequestTrackerApplication() override;
// mojo::ShellClient methods:
- void Initialize(Shell* shell, const std::string& url,
+ void Initialize(Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(Connection* connection) override;
@@ -43,7 +43,7 @@ class TestRequestTrackerApplication
InterfaceRequest<TestTrackedRequestService> request) override;
private:
- Shell* shell_;
+ Connector* connector_;
TrackingContext context_;
MOJO_DISALLOW_COPY_AND_ASSIGN(TestRequestTrackerApplication);
};
diff --git a/mojo/services/test_service/test_service_application.cc b/mojo/services/test_service/test_service_application.cc
index a447c24..1274c3e 100644
--- a/mojo/services/test_service/test_service_application.cc
+++ b/mojo/services/test_service/test_service_application.cc
@@ -17,15 +17,16 @@ namespace mojo {
namespace test {
TestServiceApplication::TestServiceApplication()
- : ref_count_(0), shell_(nullptr) {
+ : ref_count_(0), connector_(nullptr) {
}
TestServiceApplication::~TestServiceApplication() {
}
-void TestServiceApplication::Initialize(Shell* shell, const std::string& url,
+void TestServiceApplication::Initialize(Connector* connector,
+ const std::string& url,
uint32_t id, uint32_t user_id) {
- shell_ = shell;
+ connector_ = connector;
}
bool TestServiceApplication::AcceptConnection(Connection* connection) {
@@ -36,13 +37,13 @@ bool TestServiceApplication::AcceptConnection(Connection* connection) {
void TestServiceApplication::Create(Connection* connection,
InterfaceRequest<TestService> request) {
- new TestServiceImpl(shell_, this, std::move(request));
+ new TestServiceImpl(connector_, this, std::move(request));
AddRef();
}
void TestServiceApplication::Create(Connection* connection,
InterfaceRequest<TestTimeService> request) {
- new TestTimeServiceImpl(shell_, std::move(request));
+ new TestTimeServiceImpl(connector_, std::move(request));
}
void TestServiceApplication::AddRef() {
diff --git a/mojo/services/test_service/test_service_application.h b/mojo/services/test_service/test_service_application.h
index 1c024c03..840954f 100644
--- a/mojo/services/test_service/test_service_application.h
+++ b/mojo/services/test_service/test_service_application.h
@@ -23,7 +23,7 @@ class TestServiceApplication : public ShellClient,
~TestServiceApplication() override;
// mojo::ShellClient implementation.
- void Initialize(Shell* shell, const std::string& url,
+ void Initialize(Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override;
bool AcceptConnection(Connection* connection) override;
@@ -40,7 +40,7 @@ class TestServiceApplication : public ShellClient,
private:
int ref_count_;
- Shell* shell_;
+ Connector* connector_;
MOJO_DISALLOW_COPY_AND_ASSIGN(TestServiceApplication);
};
diff --git a/mojo/services/test_service/test_service_impl.cc b/mojo/services/test_service/test_service_impl.cc
index 5582dec..f7c4bd1 100644
--- a/mojo/services/test_service/test_service_impl.cc
+++ b/mojo/services/test_service/test_service_impl.cc
@@ -14,16 +14,16 @@
#include "mojo/services/test_service/test_service_application.h"
#include "mojo/services/test_service/test_time_service_impl.h"
#include "mojo/services/test_service/tracked_service.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mojo {
namespace test {
-TestServiceImpl::TestServiceImpl(Shell* shell,
+TestServiceImpl::TestServiceImpl(Connector* connector,
TestServiceApplication* application,
InterfaceRequest<TestService> request)
: application_(application),
- shell_(shell),
+ connector_(connector),
binding_(this, std::move(request)) {
binding_.set_connection_error_handler(
[this]() { application_->ReleaseRef(); });
@@ -47,7 +47,7 @@ void SendTimeResponse(
void TestServiceImpl::ConnectToAppAndGetTime(
const mojo::String& app_url,
const mojo::Callback<void(int64_t)>& callback) {
- shell_->ConnectToInterface(app_url.get(), &time_service_);
+ connector_->ConnectToInterface(app_url.get(), &time_service_);
if (tracking_) {
tracking_->RecordNewRequest();
time_service_->StartTrackingRequests(mojo::Callback<void()>());
@@ -58,7 +58,7 @@ void TestServiceImpl::ConnectToAppAndGetTime(
void TestServiceImpl::StartTrackingRequests(
const mojo::Callback<void()>& callback) {
TestRequestTrackerPtr tracker;
- shell_->ConnectToInterface("mojo:test_request_tracker_app", &tracker);
+ connector_->ConnectToInterface("mojo:test_request_tracker_app", &tracker);
tracking_.reset(new TrackedService(std::move(tracker), Name_, callback));
}
diff --git a/mojo/services/test_service/test_service_impl.h b/mojo/services/test_service/test_service_impl.h
index f96da3c..60ba795 100644
--- a/mojo/services/test_service/test_service_impl.h
+++ b/mojo/services/test_service/test_service_impl.h
@@ -13,7 +13,7 @@
#include "mojo/services/test_service/test_service.mojom.h"
namespace mojo {
-class Shell;
+class Connector;
namespace test {
class TrackedService;
@@ -21,7 +21,7 @@ class TestServiceApplication;
class TestServiceImpl : public TestService {
public:
- TestServiceImpl(Shell* shell,
+ TestServiceImpl(Connector* connector,
TestServiceApplication* application,
InterfaceRequest<TestService> request);
~TestServiceImpl() override;
@@ -35,7 +35,7 @@ class TestServiceImpl : public TestService {
private:
TestServiceApplication* const application_;
- Shell* const shell_;
+ Connector* const connector_;
TestTimeServicePtr time_service_;
scoped_ptr<TrackedService> tracking_;
StrongBinding<TestService> binding_;
diff --git a/mojo/services/test_service/test_time_service_impl.cc b/mojo/services/test_service/test_time_service_impl.cc
index ee4028d..3074e59 100644
--- a/mojo/services/test_service/test_time_service_impl.cc
+++ b/mojo/services/test_service/test_time_service_impl.cc
@@ -11,15 +11,15 @@
#include "base/time/time.h"
#include "mojo/services/test_service/test_request_tracker.mojom.h"
#include "mojo/services/test_service/tracked_service.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
namespace mojo {
namespace test {
TestTimeServiceImpl::TestTimeServiceImpl(
- Shell* shell,
+ Connector* connector,
InterfaceRequest<TestTimeService> request)
- : shell_(shell), binding_(this, std::move(request)) {}
+ : connector_(connector), binding_(this, std::move(request)) {}
TestTimeServiceImpl::~TestTimeServiceImpl() {
}
@@ -27,7 +27,7 @@ TestTimeServiceImpl::~TestTimeServiceImpl() {
void TestTimeServiceImpl::StartTrackingRequests(
const mojo::Callback<void()>& callback) {
TestRequestTrackerPtr tracker;
- shell_->ConnectToInterface("mojo:test_request_tracker_app", &tracker);
+ connector_->ConnectToInterface("mojo:test_request_tracker_app", &tracker);
tracking_.reset(new TrackedService(std::move(tracker), Name_, callback));
}
diff --git a/mojo/services/test_service/test_time_service_impl.h b/mojo/services/test_service/test_time_service_impl.h
index 6b50982..d590a05 100644
--- a/mojo/services/test_service/test_time_service_impl.h
+++ b/mojo/services/test_service/test_time_service_impl.h
@@ -15,7 +15,7 @@
namespace mojo {
class Connection;
-class Shell;
+class Connector;
namespace test {
@@ -23,7 +23,7 @@ class TrackedService;
class TestTimeServiceImpl : public TestTimeService {
public:
- TestTimeServiceImpl(Shell* shell, InterfaceRequest<TestTimeService> request);
+ TestTimeServiceImpl(Connector* connector, TestTimeServiceRequest request);
~TestTimeServiceImpl() override;
// |TestTimeService| methods:
@@ -32,7 +32,7 @@ class TestTimeServiceImpl : public TestTimeService {
void StartTrackingRequests(const mojo::Callback<void()>& callback) override;
private:
- Shell* shell_;
+ Connector* connector_;
scoped_ptr<TrackedService> tracking_;
StrongBinding<TestTimeService> binding_;
MOJO_DISALLOW_COPY_AND_ASSIGN(TestTimeServiceImpl);
diff --git a/mojo/services/tracing/public/cpp/tracing_impl.cc b/mojo/services/tracing/public/cpp/tracing_impl.cc
index 2ac2749..e7a369c 100644
--- a/mojo/services/tracing/public/cpp/tracing_impl.cc
+++ b/mojo/services/tracing/public/cpp/tracing_impl.cc
@@ -10,7 +10,7 @@
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event_impl.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#ifdef NDEBUG
#include "base/command_line.h"
@@ -41,7 +41,7 @@ TracingImpl::TracingImpl() {
TracingImpl::~TracingImpl() {
}
-void TracingImpl::Initialize(Shell* shell, const std::string& url) {
+void TracingImpl::Initialize(Connector* connector, const std::string& url) {
{
base::AutoLock lock(g_singleton_lock.Get());
if (g_tracing_singleton_created)
@@ -53,7 +53,7 @@ void TracingImpl::Initialize(Shell* shell, const std::string& url) {
// up to something like CoreServices to name its own child threads.
base::PlatformThread::SetName(url);
- connection_ = shell->Connect("mojo:tracing");
+ connection_ = connector->Connect("mojo:tracing");
connection_->AddInterface(this);
#ifdef NDEBUG
diff --git a/mojo/services/tracing/public/cpp/tracing_impl.h b/mojo/services/tracing/public/cpp/tracing_impl.h
index 42d0a74..a4e82ab 100644
--- a/mojo/services/tracing/public/cpp/tracing_impl.h
+++ b/mojo/services/tracing/public/cpp/tracing_impl.h
@@ -13,7 +13,7 @@
namespace mojo {
class Connection;
-class Shell;
+class Connector;
// Connects to mojo:tracing during your Application's Initialize() call once
// per process.
@@ -32,7 +32,7 @@ class TracingImpl : public InterfaceFactory<tracing::TraceProvider> {
// This connects to the tracing service and registers ourselves to provide
// tracing data on demand.
- void Initialize(Shell* shell, const std::string& url);
+ void Initialize(Connector* connector, const std::string& url);
private:
// InterfaceFactory<tracing::TraceProvider> implementation.
diff --git a/mojo/services/tracing/tracing_app.cc b/mojo/services/tracing/tracing_app.cc
index 974ce0d..f7885eb 100644
--- a/mojo/services/tracing/tracing_app.cc
+++ b/mojo/services/tracing/tracing_app.cc
@@ -42,6 +42,11 @@ bool TracingApp::AcceptConnection(mojo::Connection* connection) {
return true;
}
+bool TracingApp::ShellConnectionLost() {
+ base::MessageLoop::current()->QuitWhenIdle();
+ return true;
+}
+
void TracingApp::Create(mojo::Connection* connection,
mojo::InterfaceRequest<TraceCollector> request) {
collector_binding_.Bind(std::move(request));
diff --git a/mojo/services/tracing/tracing_app.h b/mojo/services/tracing/tracing_app.h
index f409887..eb5934a 100644
--- a/mojo/services/tracing/tracing_app.h
+++ b/mojo/services/tracing/tracing_app.h
@@ -34,6 +34,7 @@ class TracingApp
private:
// mojo::ShellClient implementation.
bool AcceptConnection(mojo::Connection* connection) override;
+ bool ShellConnectionLost() override;
// mojo::InterfaceFactory<TraceCollector> implementation.
void Create(mojo::Connection* connection,
diff --git a/mojo/shell/background/tests/background_shell_unittest.cc b/mojo/shell/background/tests/background_shell_unittest.cc
index 19280ef..79be067 100644
--- a/mojo/shell/background/tests/background_shell_unittest.cc
+++ b/mojo/shell/background/tests/background_shell_unittest.cc
@@ -7,6 +7,7 @@
#include "base/run_loop.h"
#include "mojo/shell/background/tests/test.mojom.h"
#include "mojo/shell/background/tests/test_application_catalog_store.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -55,8 +56,8 @@ TEST(BackgroundShellTest, DISABLED_Basic) {
&shell_client, background_shell.CreateShellClientRequest(GURL(kTestUrl)));
shell_connection.WaitForInitialize();
mojom::TestServicePtr test_service;
- static_cast<Shell*>(&shell_connection)
- ->ConnectToInterface("mojo:background_shell_test_app", &test_service);
+ shell_connection.connector()->ConnectToInterface(
+ "mojo:background_shell_test_app", &test_service);
base::RunLoop run_loop;
bool got_result = false;
test_service->Test([&run_loop, &got_result]() {
diff --git a/mojo/shell/background/tests/test_service.cc b/mojo/shell/background/tests/test_service.cc
index 4d001af..8b68c59 100644
--- a/mojo/shell/background/tests/test_service.cc
+++ b/mojo/shell/background/tests/test_service.cc
@@ -21,10 +21,6 @@ class TestClient : public ShellClient,
private:
// ShellClient:
- void Initialize(Shell* shell,
- const std::string& url,
- uint32_t id,
- uint32_t user_id) override {}
bool AcceptConnection(Connection* connection) override {
connection->AddInterface(this);
return true;
diff --git a/mojo/shell/public/cpp/BUILD.gn b/mojo/shell/public/cpp/BUILD.gn
index 1ad6892..e4342c9 100644
--- a/mojo/shell/public/cpp/BUILD.gn
+++ b/mojo/shell/public/cpp/BUILD.gn
@@ -36,8 +36,10 @@ source_set("sources") {
"lib/connector_impl.h",
"lib/interface_factory_binder.h",
"lib/interface_registry.cc",
+ "lib/message_loop_ref.cc",
"lib/shell_client.cc",
"lib/shell_connection.cc",
+ "message_loop_ref.h",
"shell.h",
"shell_client.h",
"shell_connection.h",
diff --git a/mojo/shell/public/cpp/application_test_base.h b/mojo/shell/public/cpp/application_test_base.h
index f8ff6ad..bba5916 100644
--- a/mojo/shell/public/cpp/application_test_base.h
+++ b/mojo/shell/public/cpp/application_test_base.h
@@ -9,6 +9,7 @@
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/string.h"
#include "mojo/public/cpp/system/macros.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"
@@ -32,8 +33,8 @@ class TestHelper {
explicit TestHelper(ShellClient* client);
~TestHelper();
- Shell* shell() { return shell_connection_.get(); }
- std::string shell_url() { return url_; }
+ Connector* connector() { return shell_connection_->connector(); }
+ std::string test_url() { return url_; }
private:
// The application delegate used if GetShellClient is not overridden.
@@ -54,11 +55,11 @@ class ApplicationTestBase : public testing::Test {
~ApplicationTestBase() override;
protected:
- Shell* shell() {
- return test_helper_ ? test_helper_->shell() : nullptr;
+ Connector* connector() {
+ return test_helper_ ? test_helper_->connector() : nullptr;
}
- std::string shell_url() const {
- return test_helper_ ? test_helper_->shell_url() : std::string();
+ std::string test_url() const {
+ return test_helper_ ? test_helper_->test_url() : std::string();
}
// Get the ShellClient for the application to be tested.
diff --git a/mojo/shell/public/cpp/lib/message_loop_ref.cc b/mojo/shell/public/cpp/lib/message_loop_ref.cc
new file mode 100644
index 0000000..a285cda
--- /dev/null
+++ b/mojo/shell/public/cpp/lib/message_loop_ref.cc
@@ -0,0 +1,98 @@
+// Copyright 2016 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 "mojo/shell/public/cpp/message_loop_ref.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+
+namespace mojo {
+
+class MessageLoopRefImpl : public MessageLoopRef {
+ public:
+ MessageLoopRefImpl(
+ MessageLoopRefFactory* factory,
+ scoped_refptr<base::SingleThreadTaskRunner> app_task_runner)
+ : factory_(factory),
+ app_task_runner_(app_task_runner) {}
+ ~MessageLoopRefImpl() override {
+#ifndef NDEBUG
+ // Ensure that this object is used on only one thread at a time, or else
+ // there could be races where the object is being reset on one thread and
+ // cloned on another.
+ if (clone_task_runner_)
+ DCHECK(clone_task_runner_->BelongsToCurrentThread());
+#endif
+
+ if (app_task_runner_->BelongsToCurrentThread()) {
+ factory_->Release();
+ } else {
+ app_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&MessageLoopRefFactory::Release,
+ base::Unretained(factory_)));
+ }
+ }
+
+ private:
+ // MessageLoopRef:
+ scoped_ptr<MessageLoopRef> Clone() override {
+ if (app_task_runner_->BelongsToCurrentThread()) {
+ factory_->AddRef();
+ } else {
+ app_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&MessageLoopRefFactory::AddRef,
+ base::Unretained(factory_)));
+ }
+
+#ifndef NDEBUG
+ // Ensure that this object is used on only one thread at a time, or else
+ // there could be races where the object is being reset on one thread and
+ // cloned on another.
+ if (clone_task_runner_) {
+ DCHECK(clone_task_runner_->BelongsToCurrentThread());
+ } else {
+ clone_task_runner_ = base::MessageLoop::current()->task_runner();
+ }
+#endif
+
+ return make_scoped_ptr(new MessageLoopRefImpl(factory_, app_task_runner_));
+ }
+
+ MessageLoopRefFactory* factory_;
+ scoped_refptr<base::SingleThreadTaskRunner> app_task_runner_;
+
+#ifndef NDEBUG
+ scoped_refptr<base::SingleThreadTaskRunner> clone_task_runner_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(MessageLoopRefImpl);
+};
+
+MessageLoopRefFactory::MessageLoopRefFactory() {}
+MessageLoopRefFactory::~MessageLoopRefFactory() {}
+
+scoped_ptr<MessageLoopRef> MessageLoopRefFactory::CreateRef() {
+ AddRef();
+ return make_scoped_ptr(new MessageLoopRefImpl(
+ this, base::MessageLoop::current()->task_runner()));
+}
+
+void MessageLoopRefFactory::AddRef() {
+ ++ref_count_;
+}
+
+void MessageLoopRefFactory::Release() {
+ if (!--ref_count_) {
+ if (!quit_closure_.is_null())
+ quit_closure_.Run();
+ if (base::MessageLoop::current() &&
+ base::MessageLoop::current()->is_running()) {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
+ }
+}
+
+} // namespace mojo
diff --git a/mojo/shell/public/cpp/lib/shell_client.cc b/mojo/shell/public/cpp/lib/shell_client.cc
index 6570068..0d553f0 100644
--- a/mojo/shell/public/cpp/lib/shell_client.cc
+++ b/mojo/shell/public/cpp/lib/shell_client.cc
@@ -9,7 +9,7 @@ namespace mojo {
ShellClient::ShellClient() {}
ShellClient::~ShellClient() {}
-void ShellClient::Initialize(Shell* app, const std::string& url,
+void ShellClient::Initialize(Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) {
}
@@ -21,6 +21,4 @@ bool ShellClient::ShellConnectionLost() {
return true;
}
-void ShellClient::Quit() {}
-
} // namespace mojo
diff --git a/mojo/shell/public/cpp/lib/shell_connection.cc b/mojo/shell/public/cpp/lib/shell_connection.cc
index e14cc77..5977cc6 100644
--- a/mojo/shell/public/cpp/lib/shell_connection.cc
+++ b/mojo/shell/public/cpp/lib/shell_connection.cc
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <algorithm>
-#include <utility>
-
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
@@ -17,65 +14,6 @@
namespace mojo {
-class AppRefCountImpl : public AppRefCount {
- public:
- AppRefCountImpl(ShellConnection* connection,
- scoped_refptr<base::SingleThreadTaskRunner> app_task_runner)
- : connection_(connection),
- app_task_runner_(app_task_runner) {}
- ~AppRefCountImpl() override {
-#ifndef NDEBUG
- // Ensure that this object is used on only one thread at a time, or else
- // there could be races where the object is being reset on one thread and
- // cloned on another.
- if (clone_task_runner_)
- DCHECK(clone_task_runner_->BelongsToCurrentThread());
-#endif
-
- if (app_task_runner_->BelongsToCurrentThread()) {
- connection_->Release();
- } else {
- app_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ShellConnection::Release, base::Unretained(connection_)));
- }
- }
-
- private:
- // AppRefCount:
- scoped_ptr<AppRefCount> Clone() override {
- if (app_task_runner_->BelongsToCurrentThread()) {
- connection_->AddRef();
- } else {
- app_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ShellConnection::AddRef, base::Unretained(connection_)));
- }
-
-#ifndef NDEBUG
- // Ensure that this object is used on only one thread at a time, or else
- // there could be races where the object is being reset on one thread and
- // cloned on another.
- if (clone_task_runner_) {
- DCHECK(clone_task_runner_->BelongsToCurrentThread());
- } else {
- clone_task_runner_ = base::MessageLoop::current()->task_runner();
- }
-#endif
-
- return make_scoped_ptr(new AppRefCountImpl(connection_, app_task_runner_));
- }
-
- ShellConnection* connection_;
- scoped_refptr<base::SingleThreadTaskRunner> app_task_runner_;
-
-#ifndef NDEBUG
- scoped_refptr<base::SingleThreadTaskRunner> clone_task_runner_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(AppRefCountImpl);
-};
-
////////////////////////////////////////////////////////////////////////////////
// ShellConnection, public:
@@ -84,7 +22,6 @@ ShellConnection::ShellConnection(
InterfaceRequest<shell::mojom::ShellClient> request)
: client_(client),
binding_(this, std::move(request)),
- ref_count_(0),
weak_factory_(this) {}
ShellConnection::~ShellConnection() {}
@@ -95,36 +32,6 @@ void ShellConnection::WaitForInitialize() {
}
////////////////////////////////////////////////////////////////////////////////
-// ShellConnection, Shell implementation:
-
-scoped_ptr<Connection> ShellConnection::Connect(const std::string& url) {
- return connector_->Connect(url);
-}
-
-scoped_ptr<Connection> ShellConnection::Connect(
- Connector::ConnectParams* params) {
- return connector_->Connect(params);
-}
-
-scoped_ptr<Connector> ShellConnection::CloneConnector() const {
- return connector_->Clone();
-}
-
-scoped_ptr<AppRefCount> ShellConnection::CreateAppRefCount() {
- AddRef();
- return make_scoped_ptr(
- new AppRefCountImpl(this, base::MessageLoop::current()->task_runner()));
-}
-
-void ShellConnection::Quit() {
- client_->Quit();
- if (base::MessageLoop::current() &&
- base::MessageLoop::current()->is_running()) {
- base::MessageLoop::current()->QuitWhenIdle();
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
// ShellConnection, shell::mojom::ShellClient implementation:
void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector,
@@ -135,7 +42,7 @@ void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector,
std::move(connector),
base::Bind(&ShellConnection::OnConnectionError,
weak_factory_.GetWeakPtr())));
- client_->Initialize(this, url, id, user_id);
+ client_->Initialize(connector_.get(), url, id, user_id);
}
void ShellConnection::AcceptConnection(
@@ -162,27 +69,12 @@ void ShellConnection::AcceptConnection(
// ShellConnection, private:
void ShellConnection::OnConnectionError() {
- base::WeakPtr<ShellConnection> ptr(weak_factory_.GetWeakPtr());
-
// We give the client notice first, since it might want to do something on
// shell connection errors other than immediate termination of the run
// loop. The application might want to continue servicing connections other
// than the one to the shell.
- bool quit_now = client_->ShellConnectionLost();
- if (quit_now)
- Quit();
- if (!ptr)
- return;
- connector_.reset();
-}
-
-void ShellConnection::AddRef() {
- ++ref_count_;
-}
-
-void ShellConnection::Release() {
- if (!--ref_count_)
- Quit();
+ if (client_->ShellConnectionLost())
+ connector_.reset();
}
} // namespace mojo
diff --git a/mojo/shell/public/cpp/message_loop_ref.h b/mojo/shell/public/cpp/message_loop_ref.h
new file mode 100644
index 0000000..fffb738
--- /dev/null
+++ b/mojo/shell/public/cpp/message_loop_ref.h
@@ -0,0 +1,57 @@
+// Copyright 2016 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 MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_REFERENCE_H_
+#define MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_REFERENCE_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "mojo/public/cpp/system/core.h"
+
+namespace mojo {
+
+class MessageLoopRefImpl;
+
+// An interface implementation can keep this object as a member variable to
+// hold a reference to the ShellConnection, keeping it alive as long as the
+// bound implementation exists.
+// Since interface implementations can be bound on different threads than the
+// ShellConnection, this class is safe to use on any thread. However, each
+// instance should only be used on one thread at a time (otherwise there'll be
+// races between the AddRef resulting from cloning and destruction).
+class MessageLoopRef {
+ public:
+ virtual ~MessageLoopRef() {}
+
+ virtual scoped_ptr<MessageLoopRef> Clone() = 0;
+};
+
+class MessageLoopRefFactory {
+ public:
+ MessageLoopRefFactory();
+ ~MessageLoopRefFactory();
+
+ void set_quit_closure(const base::Closure& quit_closure) {
+ quit_closure_ = quit_closure;
+ }
+
+ scoped_ptr<MessageLoopRef> CreateRef();
+
+ private:
+ friend MessageLoopRefImpl;
+
+ // Called from MessageLoopRefImpl.
+ void AddRef();
+ void Release();
+
+ base::Closure quit_closure_;
+ int ref_count_ = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(MessageLoopRefFactory);
+};
+
+} // namespace mojo
+
+#endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_REFERENCE_H_
diff --git a/mojo/shell/public/cpp/shell.h b/mojo/shell/public/cpp/shell.h
index cade46a..772d23f 100644
--- a/mojo/shell/public/cpp/shell.h
+++ b/mojo/shell/public/cpp/shell.h
@@ -5,67 +5,11 @@
#ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_H_
#define MOJO_SHELL_PUBLIC_CPP_SHELL_H_
-#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/cpp/connector.h"
-#include "mojo/shell/public/interfaces/shell.mojom.h"
-#include "url/gurl.h"
namespace mojo {
-// An interface implementation can keep this object as a member variable to
-// hold a reference to the ShellConnection, keeping it alive as long as the
-// bound implementation exists.
-// Since interface implementations can be bound on different threads than the
-// ShellConnection, this class is safe to use on any thread. However, each
-// instance should only be used on one thread at a time (otherwise there'll be
-// races between the AddRef resulting from cloning and destruction).
-class AppRefCount {
- public:
- virtual ~AppRefCount() {}
-
- virtual scoped_ptr<AppRefCount> Clone() = 0;
-};
-
-// An interface that encapsulates the Mojo Shell's broker interface by which
-// connections between applications are established. Implemented by
-// ShellConnection, this is the primary interface exposed to clients.
-class Shell {
- public:
- // Requests a new connection to an application. Returns a pointer to the
- // connection if the connection is permitted by this application's delegate,
- // or nullptr otherwise. Caller takes ownership.
- virtual scoped_ptr<Connection> Connect(const std::string& url) = 0;
- virtual scoped_ptr<Connection> Connect(Connector::ConnectParams* params) = 0;
-
- // Connect to application identified by |request->url| and connect to the
- // service implementation of the interface identified by |Interface|.
- template <typename Interface>
- void ConnectToInterface(Connector::ConnectParams* params,
- InterfacePtr<Interface>* ptr) {
- scoped_ptr<Connection> connection = Connect(params);
- if (connection)
- connection->GetInterface(ptr);
- }
- template <typename Interface>
- void ConnectToInterface(const std::string& url,
- InterfacePtr<Interface>* ptr) {
- Connector::ConnectParams params(url);
- return ConnectToInterface(&params, ptr);
- }
-
- // Returns a clone of the ShellConnection's Connector that can be passed to
- // other threads.
- virtual scoped_ptr<Connector> CloneConnector() const = 0;
-
- // Quits the message loop run by the ApplicationRunner, which causes this
- // object to be destructed and the application to quit.
- virtual void Quit() = 0;
-
- // Create an object that can be used to refcount the lifetime of the
- // application. The returned object may be cloned, and when the refcount falls
- // to zero Quit() is called.
- virtual scoped_ptr<AppRefCount> CreateAppRefCount() = 0;
-};
+using Shell = Connector;
} // namespace mojo
diff --git a/mojo/shell/public/cpp/shell_client.h b/mojo/shell/public/cpp/shell_client.h
index b7a8e0e..0d6fde1 100644
--- a/mojo/shell/public/cpp/shell_client.h
+++ b/mojo/shell/public/cpp/shell_client.h
@@ -13,7 +13,7 @@
namespace mojo {
-class Shell;
+class Connector;
// An interface representing an instance "known to the Mojo Shell". The
// implementation receives lifecycle messages for the instance and gets the
@@ -31,7 +31,7 @@ class ShellClient {
// instance of the application.
// |user_id| identifies the user this instance is run as.
// Called exactly once before any other method.
- virtual void Initialize(Shell* shell,
+ virtual void Initialize(Connector* connector,
const std::string& url,
uint32_t id,
uint32_t user_id = 0);
@@ -44,20 +44,10 @@ class ShellClient {
// Called when ShellConnection's pipe to the Mojo Shell is closed.
//
- // Returning true from this method will cause the ShellConnection instance to
- // call this instance back via Quit(), and then run the termination closure
- // passed to it (which may do cleanup like, for example, quitting a run loop).
- // Returning false from this method will not do any of this. The client is
- // then responsible for calling Shell::QuitNow() when it is ready to close.
- // The client may do this if it wishes to continue servicing connections other
- // than the Shell.
+ // Returning true from this method will cause ...
// The default implementation returns true.
virtual bool ShellConnectionLost();
- // Called before ShellConnection::QuitNow(). After returning from this call
- // the delegate can no longer rely on the main run loop still running.
- virtual void Quit();
-
private:
MOJO_DISALLOW_COPY_AND_ASSIGN(ShellClient);
};
diff --git a/mojo/shell/public/cpp/shell_connection.h b/mojo/shell/public/cpp/shell_connection.h
index d79b788..123bd93 100644
--- a/mojo/shell/public/cpp/shell_connection.h
+++ b/mojo/shell/public/cpp/shell_connection.h
@@ -14,14 +14,12 @@
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/public/cpp/system/core.h"
-#include "mojo/shell/public/cpp/shell.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"
namespace mojo {
-class AppRefCountImpl;
class Connector;
// Encapsulates a connection to the Mojo Shell in two parts:
@@ -44,10 +42,7 @@ class Connector;
// Client Lib's mojo::ShellClient interface. See documentation in shell_client.h
// for details.
//
-// Though this class provides the canonical implementation of the Shell Client
-// lib's mojo::Shell interface, this interface should not be reached through
-// pointers to this type.
-class ShellConnection : public Shell, public shell::mojom::ShellClient {
+class ShellConnection : public shell::mojom::ShellClient {
public:
// Does not take ownership of |delegate|, which must remain valid for the
// lifetime of ShellConnection.
@@ -59,16 +54,9 @@ class ShellConnection : public Shell, public shell::mojom::ShellClient {
// shell.
void WaitForInitialize();
- private:
- friend AppRefCountImpl;
-
- // Shell:
- scoped_ptr<Connection> Connect(const std::string& url) override;
- scoped_ptr<Connection> Connect(Connector::ConnectParams* params) override;
- scoped_ptr<Connector> CloneConnector() const override;
- scoped_ptr<AppRefCount> CreateAppRefCount() override;
- void Quit() override;
+ Connector* connector() { return connector_.get(); }
+ private:
// shell::mojom::ShellClient:
void Initialize(shell::mojom::ConnectorPtr connector,
const mojo::String& url,
@@ -85,17 +73,12 @@ class ShellConnection : public Shell, public shell::mojom::ShellClient {
void OnConnectionError();
- // Called from AppRefCountImpl.
- void AddRef();
- void Release();
-
// We track the lifetime of incoming connection registries as it more
// convenient for the client.
ScopedVector<Connection> incoming_connections_;
mojo::ShellClient* client_;
Binding<shell::mojom::ShellClient> binding_;
scoped_ptr<Connector> connector_;
- int ref_count_;
base::WeakPtrFactory<ShellConnection> weak_factory_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ShellConnection);
diff --git a/mojo/shell/runner/child/native_apptest.cc b/mojo/shell/runner/child/native_apptest.cc
index 7368fbc..d0ab0b7 100644
--- a/mojo/shell/runner/child/native_apptest.cc
+++ b/mojo/shell/runner/child/native_apptest.cc
@@ -19,8 +19,8 @@ using NativeAppTest = mojo::test::ApplicationTestBase;
TEST_F(NativeAppTest, Connect) {
test::TestNativeServicePtr native_service;
- shell()->ConnectToInterface("exe:mojo_runner_child_apptest_native_target",
- &native_service);
+ connector()->ConnectToInterface("exe:mojo_runner_child_apptest_native_target",
+ &native_service);
bool result = false;
native_service->Invert(
diff --git a/mojo/shell/runner/child/native_apptest_target.cc b/mojo/shell/runner/child/native_apptest_target.cc
index 04ebdbb..565ba30 100644
--- a/mojo/shell/runner/child/native_apptest_target.cc
+++ b/mojo/shell/runner/child/native_apptest_target.cc
@@ -10,7 +10,6 @@
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/cpp/interface_factory.h"
-#include "mojo/shell/public/cpp/shell.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/runner/child/test_native_main.h"
#include "mojo/shell/runner/child/test_native_service.mojom.h"
@@ -28,8 +27,6 @@ class TargetApplicationDelegate
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
- uint32_t id, uint32_t user_id) override {}
bool AcceptConnection(mojo::Connection* connection) override {
connection->AddInterface<mojo::shell::test::TestNativeService>(this);
return true;
diff --git a/mojo/shell/tests/application_manager_apptest.cc b/mojo/shell/tests/application_manager_apptest.cc
index 82fa8bc..a848611 100644
--- a/mojo/shell/tests/application_manager_apptest.cc
+++ b/mojo/shell/tests/application_manager_apptest.cc
@@ -14,7 +14,7 @@
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/shell/public/cpp/application_test_base.h"
#include "mojo/shell/public/cpp/interface_factory.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/interfaces/application_manager.mojom.h"
#include "mojo/shell/tests/application_manager_apptests.mojom.h"
@@ -38,8 +38,6 @@ class ApplicationManagerAppTestDelegate
private:
// mojo::ShellClient:
- void Initialize(Shell* shell, const std::string& url, uint32_t id,
- uint32_t user_id) override {}
bool AcceptConnection(Connection* connection) override {
connection->AddInterface<CreateInstanceForHandleTest>(this);
return true;
@@ -88,7 +86,7 @@ class ApplicationManagerAppTest : public mojo::test::ApplicationTestBase,
void AddListenerAndWaitForApplications() {
mojom::ApplicationManagerPtr application_manager;
- shell()->ConnectToInterface("mojo:shell", &application_manager);
+ connector()->ConnectToInterface("mojo:shell", &application_manager);
application_manager->AddListener(binding_.CreateInterfacePtrAndBind());
binding_.WaitForIncomingMethodCall();
@@ -169,7 +167,7 @@ TEST_F(ApplicationManagerAppTest, CreateInstanceForHandle) {
// launches a process. #becauselinkerrors).
mojo::shell::test::mojom::DriverPtr driver;
scoped_ptr<Connection> connection =
- shell()->Connect("exe:application_manager_apptest_driver");
+ connector()->Connect("exe:application_manager_apptest_driver");
connection->GetInterface(&driver);
// 2. Wait for the target to connect to us. (via
diff --git a/mojo/shell/tests/application_manager_apptest_driver.cc b/mojo/shell/tests/application_manager_apptest_driver.cc
index 2a820fe..7342d72 100644
--- a/mojo/shell/tests/application_manager_apptest_driver.cc
+++ b/mojo/shell/tests/application_manager_apptest_driver.cc
@@ -23,8 +23,8 @@
#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/shell/public/cpp/connection.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/interface_factory.h"
-#include "mojo/shell/public/cpp/shell.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/interfaces/application_manager.mojom.h"
#include "mojo/shell/runner/child/test_native_main.h"
@@ -41,15 +41,13 @@ class TargetApplicationDelegate : public mojo::ShellClient,
public mojo::InterfaceFactory<Driver>,
public Driver {
public:
- TargetApplicationDelegate() : shell_(nullptr), weak_factory_(this) {}
+ TargetApplicationDelegate() : weak_factory_(this) {}
~TargetApplicationDelegate() override {}
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override {
- shell_ = shell;
-
base::FilePath target_path;
CHECK(base::PathService::Get(base::DIR_EXE, &target_path));
#if defined(OS_WIN)
@@ -98,7 +96,7 @@ class TargetApplicationDelegate : public mojo::ShellClient,
std::move(test_interfaces));
mojo::shell::mojom::ApplicationManagerPtr application_manager;
- shell_->ConnectToInterface("mojo:shell", &application_manager);
+ connector->ConnectToInterface("mojo:shell", &application_manager);
application_manager->CreateInstanceForHandle(
mojo::ScopedHandle(mojo::Handle(pipe.release().value())),
"exe:application_manager_apptest_target", std::move(filter),
@@ -131,10 +129,9 @@ class TargetApplicationDelegate : public mojo::ShellClient,
// Driver:
void QuitDriver() override {
target_.Terminate(0, false);
- shell_->Quit();
+ base::MessageLoop::current()->QuitWhenIdle();
}
- mojo::Shell* shell_;
base::Process target_;
mojo::BindingSet<Driver> bindings_;
base::WeakPtrFactory<TargetApplicationDelegate> weak_factory_;
diff --git a/mojo/shell/tests/application_manager_apptest_target.cc b/mojo/shell/tests/application_manager_apptest_target.cc
index 5284553..0c36d10 100644
--- a/mojo/shell/tests/application_manager_apptest_target.cc
+++ b/mojo/shell/tests/application_manager_apptest_target.cc
@@ -6,7 +6,7 @@
#include "base/command_line.h"
#include "base/macros.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/runner/child/test_native_main.h"
#include "mojo/shell/runner/init.h"
@@ -23,10 +23,10 @@ class TargetApplicationDelegate : public mojo::ShellClient {
private:
// mojo::ShellClient:
- void Initialize(mojo::Shell* shell, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override {
CreateInstanceForHandleTestPtr service;
- shell->ConnectToInterface("mojo:mojo_shell_apptests", &service);
+ connector->ConnectToInterface("mojo:mojo_shell_apptests", &service);
service->SetTargetID(id);
}
diff --git a/mojo/shell/tests/application_manager_unittest.cc b/mojo/shell/tests/application_manager_unittest.cc
index 51bcc15..bed3c74 100644
--- a/mojo/shell/tests/application_manager_unittest.cc
+++ b/mojo/shell/tests/application_manager_unittest.cc
@@ -16,6 +16,7 @@
#include "mojo/services/package_manager/package_manager.h"
#include "mojo/shell/application_loader.h"
#include "mojo/shell/connect_util.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/interface_factory.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
@@ -245,12 +246,12 @@ class TesterContext {
// Used to test that the requestor url will be correctly passed.
class TestAImpl : public TestA {
public:
- TestAImpl(Shell* shell,
+ TestAImpl(Connector* connector,
TesterContext* test_context,
InterfaceRequest<TestA> request,
InterfaceFactory<TestC>* factory)
: test_context_(test_context), binding_(this, std::move(request)) {
- connection_ = shell->Connect(kTestBURLString);
+ connection_ = connector->Connect(kTestBURLString);
connection_->AddInterface<TestC>(factory);
connection_->GetInterface(&b_);
}
@@ -368,7 +369,7 @@ class Tester : public ShellClient,
void Create(Connection* connection,
InterfaceRequest<TestA> request) override {
a_bindings_.push_back(
- new TestAImpl(app_.get(), context_, std::move(request), this));
+ new TestAImpl(app_->connector(), context_, std::move(request), this));
}
void Create(Connection* connection,
diff --git a/mojo/shell/tests/capability_filter_test.cc b/mojo/shell/tests/capability_filter_test.cc
index 3fac67c..1c3a1fa 100644
--- a/mojo/shell/tests/capability_filter_test.cc
+++ b/mojo/shell/tests/capability_filter_test.cc
@@ -14,6 +14,7 @@
#include "mojo/services/package_manager/package_manager.h"
#include "mojo/shell/application_loader.h"
#include "mojo/shell/public/cpp/connection.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/interface_factory.h"
#include "mojo/shell/public/cpp/shell_connection.h"
@@ -111,17 +112,16 @@ class ServiceApplication : public ShellClient,
public Safe,
public Unsafe {
public:
- ServiceApplication() : shell_(nullptr) {}
+ ServiceApplication() {}
~ServiceApplication() override {}
private:
// Overridden from ShellClient:
- void Initialize(Shell* shell, const std::string& url, uint32_t id,
+ void Initialize(Connector* connector, const std::string& url, uint32_t id,
uint32_t user_id) override {
- shell_ = shell;
// ServiceApplications have no capability filter and can thus connect
// directly to the validator application.
- shell_->ConnectToInterface("test:validator", &validator_);
+ connector->ConnectToInterface("test:validator", &validator_);
}
bool AcceptConnection(Connection* connection) override {
AddInterface<Safe>(connection);
@@ -149,7 +149,6 @@ class ServiceApplication : public ShellClient,
!connection->AddInterface<Interface>(this));
}
- Shell* shell_;
ValidatorPtr validator_;
BindingSet<Safe> safe_bindings_;
BindingSet<Unsafe> unsafe_bindings_;
@@ -160,24 +159,24 @@ class ServiceApplication : public ShellClient,
////////////////////////////////////////////////////////////////////////////////
// TestApplication:
-TestApplication::TestApplication() : shell_(nullptr) {}
+TestApplication::TestApplication() : connector_(nullptr) {}
TestApplication::~TestApplication() {}
-void TestApplication::Initialize(Shell* shell, const std::string& url,
+void TestApplication::Initialize(Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) {
- shell_ = shell;
+ connector_ = connector;
url_ = url;
}
bool TestApplication::AcceptConnection(Connection* connection) {
// TestApplications receive their Validator via the inbound connection.
connection->GetInterface(&validator_);
- connection1_ = shell_->Connect("test:service");
+ connection1_ = connector_->Connect("test:service");
connection1_->SetRemoteInterfaceProviderConnectionErrorHandler(
base::Bind(&TestApplication::ConnectionClosed,
base::Unretained(this), "test:service"));
- connection2_ = shell_->Connect("test:service2");
+ connection2_ = connector_->Connect("test:service2");
connection2_->SetRemoteInterfaceProviderConnectionErrorHandler(
base::Bind(&TestApplication::ConnectionClosed,
base::Unretained(this), "test:service2"));
diff --git a/mojo/shell/tests/capability_filter_test.h b/mojo/shell/tests/capability_filter_test.h
index 45a5fa8..43d7e47 100644
--- a/mojo/shell/tests/capability_filter_test.h
+++ b/mojo/shell/tests/capability_filter_test.h
@@ -29,13 +29,13 @@ class TestApplication : public ShellClient {
private:
// Overridden from ShellClient:
- void Initialize(Shell* shell, const std::string& url, uint32_t id,
+ void Initialize(Connector* connector, const std::string& url, uint32_t id,
uint32_t user_id) override;
bool AcceptConnection(Connection* connection) override;
void ConnectionClosed(const std::string& service_url);
- Shell* shell_;
+ Connector* connector_;
std::string url_;
ValidatorPtr validator_;
scoped_ptr<Connection> connection1_;
diff --git a/mojo/shell/tests/package_apptest.cc b/mojo/shell/tests/package_apptest.cc
index ecdb0d9..8b739ad 100644
--- a/mojo/shell/tests/package_apptest.cc
+++ b/mojo/shell/tests/package_apptest.cc
@@ -38,7 +38,7 @@ TEST_F(PackageApptest, Basic) {
// register aliases.
test::mojom::PackageTestServicePtr root_service;
scoped_ptr<Connection> connection =
- shell()->Connect("mojo:package_test_package");
+ connector()->Connect("mojo:package_test_package");
connection->GetInterface(&root_service);
base::RunLoop run_loop;
std::string root_name;
@@ -53,7 +53,8 @@ TEST_F(PackageApptest, Basic) {
// Now subsequent connects to applications provided by the root app will be
// resolved correctly.
test::mojom::PackageTestServicePtr service_a;
- scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_a");
+ scoped_ptr<Connection> connection =
+ connector()->Connect("mojo:package_test_a");
connection->GetInterface(&service_a);
base::RunLoop run_loop;
std::string a_name;
@@ -67,7 +68,8 @@ TEST_F(PackageApptest, Basic) {
{
test::mojom::PackageTestServicePtr service_b;
- scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_b");
+ scoped_ptr<Connection> connection =
+ connector()->Connect("mojo:package_test_b");
connection->GetInterface(&service_b);
base::RunLoop run_loop;
std::string b_name;
diff --git a/mojo/shell/tests/package_test_package.cc b/mojo/shell/tests/package_test_package.cc
index ee8ff5b..f25abd5 100644
--- a/mojo/shell/tests/package_test_package.cc
+++ b/mojo/shell/tests/package_test_package.cc
@@ -9,13 +9,13 @@
#include "base/bind.h"
#include "base/macros.h"
+#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/threading/simple_thread.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/shell/public/cpp/application_runner.h"
#include "mojo/shell/public/cpp/interface_factory.h"
-#include "mojo/shell/public/cpp/shell.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/interfaces/shell_client_factory.mojom.h"
#include "mojo/shell/tests/package_test.mojom.h"
@@ -39,8 +39,7 @@ class ProvidedShellClient
mojom::ShellClientRequest request)
: base::SimpleThread(name),
name_(name),
- request_(std::move(request)),
- shell_(nullptr) {
+ request_(std::move(request)) {
Start();
}
~ProvidedShellClient() override {
@@ -49,9 +48,8 @@ class ProvidedShellClient
private:
// mojo::ShellClient:
- void Initialize(Shell* shell, const std::string& url,
+ void Initialize(Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override {
- shell_ = shell;
bindings_.set_connection_error_handler(
base::Bind(&ProvidedShellClient::OnConnectionError,
base::Unretained(this)));
@@ -82,12 +80,11 @@ class ProvidedShellClient
void OnConnectionError() {
if (bindings_.empty())
- shell_->Quit();
+ base::MessageLoop::current()->QuitWhenIdle();
}
const std::string name_;
mojom::ShellClientRequest request_;
- Shell* shell_;
BindingSet<test::mojom::PackageTestService> bindings_;
DISALLOW_COPY_AND_ASSIGN(ProvidedShellClient);
@@ -100,14 +97,13 @@ class PackageTestShellClient
public mojom::ShellClientFactory,
public test::mojom::PackageTestService {
public:
- PackageTestShellClient() : shell_(nullptr) {}
+ PackageTestShellClient() {}
~PackageTestShellClient() override {}
private:
// mojo::ShellClient:
- void Initialize(Shell* shell, const std::string& url,
+ void Initialize(Connector* connector, const std::string& url,
uint32_t id, uint32_t user_id) override {
- shell_ = shell;
bindings_.set_connection_error_handler(
base::Bind(&PackageTestShellClient::OnConnectionError,
base::Unretained(this)));
@@ -117,6 +113,13 @@ class PackageTestShellClient
connection->AddInterface<test::mojom::PackageTestService>(this);
return true;
}
+ bool ShellConnectionLost() override {
+ if (base::MessageLoop::current() &&
+ base::MessageLoop::current()->is_running()) {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
+ return true;
+ }
// InterfaceFactory<mojom::ShellClientFactory>:
void Create(Connection* connection,
@@ -146,10 +149,9 @@ class PackageTestShellClient
void OnConnectionError() {
if (bindings_.empty())
- shell_->Quit();
+ base::MessageLoop::current()->QuitWhenIdle();
}
- Shell* shell_;
std::vector<scoped_ptr<ShellClient>> delegates_;
BindingSet<mojom::ShellClientFactory> shell_client_factory_bindings_;
BindingSet<test::mojom::PackageTestService> bindings_;
diff --git a/ui/views/mus/aura_init.cc b/ui/views/mus/aura_init.cc
index bc4d98e..2b08108 100644
--- a/ui/views/mus/aura_init.cc
+++ b/ui/views/mus/aura_init.cc
@@ -11,7 +11,7 @@
#include "base/path_service.h"
#include "build/build_config.h"
#include "components/resource_provider/public/cpp/resource_loader.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/aura/env.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/base/resource/resource_bundle.h"
@@ -50,12 +50,12 @@ class MusViewsDelegate : public ViewsDelegate {
} // namespace
-AuraInit::AuraInit(mojo::Shell* shell, const std::string& resource_file)
+AuraInit::AuraInit(mojo::Connector* connector, const std::string& resource_file)
: resource_file_(resource_file),
views_delegate_(new MusViewsDelegate) {
aura::Env::CreateInstance(false);
- InitializeResources(shell);
+ InitializeResources(connector);
ui::InitializeInputMethodForTesting();
}
@@ -72,11 +72,11 @@ AuraInit::~AuraInit() {
#endif
}
-void AuraInit::InitializeResources(mojo::Shell* shell) {
+void AuraInit::InitializeResources(mojo::Connector* connector) {
if (ui::ResourceBundle::HasSharedInstance())
return;
resource_provider::ResourceLoader resource_loader(
- shell, GetResourcePaths(resource_file_));
+ connector, GetResourcePaths(resource_file_));
CHECK(resource_loader.BlockUntilLoaded());
CHECK(resource_loader.loaded());
ui::RegisterPathProvider();
@@ -89,7 +89,7 @@ void AuraInit::InitializeResources(mojo::Shell* shell) {
// Initialize the skia font code to go ask fontconfig underneath.
#if defined(OS_LINUX) && !defined(OS_ANDROID)
- font_loader_ = skia::AdoptRef(new font_service::FontLoader(shell));
+ font_loader_ = skia::AdoptRef(new font_service::FontLoader(connector));
SkFontConfigInterface::SetGlobal(font_loader_.get());
#endif
diff --git a/ui/views/mus/aura_init.h b/ui/views/mus/aura_init.h
index b2cf750..521acac 100644
--- a/ui/views/mus/aura_init.h
+++ b/ui/views/mus/aura_init.h
@@ -18,7 +18,7 @@ class FontLoader;
}
namespace mojo {
-class Shell;
+class Connector;
}
namespace views {
@@ -28,11 +28,11 @@ class ViewsDelegate;
// |resource_file| is the path to the apk file containing the resources.
class VIEWS_MUS_EXPORT AuraInit {
public:
- AuraInit(mojo::Shell* shell, const std::string& resource_file);
+ AuraInit(mojo::Connector* connector, const std::string& resource_file);
~AuraInit();
private:
- void InitializeResources(mojo::Shell* shell);
+ void InitializeResources(mojo::Connector* connector);
#if defined(OS_LINUX) && !defined(OS_ANDROID)
skia::RefPtr<font_service::FontLoader> font_loader_;
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc
index d485155..2ecb52d 100644
--- a/ui/views/mus/native_widget_mus.cc
+++ b/ui/views/mus/native_widget_mus.cc
@@ -176,7 +176,7 @@ int ResizeBehaviorFromDelegate(WidgetDelegate* delegate) {
// NativeWidgetMus, public:
NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate,
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::Window* window,
mus::mojom::SurfaceType surface_type)
: window_(window),
@@ -200,10 +200,10 @@ NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate,
// SoftwareOutputDeviceMus.
if (!default_context_factory) {
context_factory_.reset(
- new SurfaceContextFactory(shell, window_, surface_type_));
+ new SurfaceContextFactory(connector, window_, surface_type_));
aura::Env::GetInstance()->set_context_factory(context_factory_.get());
}
- window_tree_host_.reset(new WindowTreeHostMus(shell, this, window_));
+ window_tree_host_.reset(new WindowTreeHostMus(connector, this, window_));
aura::Env::GetInstance()->set_context_factory(default_context_factory);
}
diff --git a/ui/views/mus/native_widget_mus.h b/ui/views/mus/native_widget_mus.h
index 57cb55c..9e697a8 100644
--- a/ui/views/mus/native_widget_mus.h
+++ b/ui/views/mus/native_widget_mus.h
@@ -30,7 +30,7 @@ class Window;
}
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -59,7 +59,7 @@ class VIEWS_MUS_EXPORT NativeWidgetMus : public internal::NativeWidgetPrivate,
public aura::WindowTreeHostObserver {
public:
NativeWidgetMus(internal::NativeWidgetDelegate* delegate,
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::Window* window,
mus::mojom::SurfaceType surface_type);
~NativeWidgetMus() override;
diff --git a/ui/views/mus/platform_test_helper_mus.cc b/ui/views/mus/platform_test_helper_mus.cc
index 918c550..ba6869c 100644
--- a/ui/views/mus/platform_test_helper_mus.cc
+++ b/ui/views/mus/platform_test_helper_mus.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "mojo/shell/background/background_shell.h"
#include "mojo/shell/background/tests/test_application_catalog_store.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "ui/views/mus/window_manager_connection.h"
@@ -52,9 +53,9 @@ class PlatformTestHelperMus : public PlatformTestHelper {
shell_connection_->WaitForInitialize();
// ui/views/mus requires a WindowManager running, for now use the desktop
// one.
- mojo::Shell* shell = shell_connection_.get();
- shell->Connect("mojo:desktop_wm");
- WindowManagerConnection::Create(shell_connection_.get());
+ mojo::Connector* connector = shell_connection_->connector();
+ connector->Connect("mojo:desktop_wm");
+ WindowManagerConnection::Create(connector);
}
~PlatformTestHelperMus() override {
diff --git a/ui/views/mus/platform_window_mus.cc b/ui/views/mus/platform_window_mus.cc
index 07e3c6e..3961390 100644
--- a/ui/views/mus/platform_window_mus.cc
+++ b/ui/views/mus/platform_window_mus.cc
@@ -22,7 +22,7 @@ static uint32_t accelerated_widget_count = 1;
} // namespace
PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::Window* mus_window)
: delegate_(delegate),
mus_window_(mus_window),
@@ -48,7 +48,7 @@ PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
accelerated_widget, mus_window_->viewport_metrics().device_pixel_ratio);
bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(mus_window_));
- bitmap_uploader_->Init(shell);
+ bitmap_uploader_->Init(connector);
prop_.reset(new ui::ViewProp(
accelerated_widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget,
bitmap_uploader_.get()));
diff --git a/ui/views/mus/platform_window_mus.h b/ui/views/mus/platform_window_mus.h
index 5cc440b..2d95a21 100644
--- a/ui/views/mus/platform_window_mus.h
+++ b/ui/views/mus/platform_window_mus.h
@@ -21,7 +21,7 @@ class BitmapUploader;
}
namespace mojo {
-class Shell;
+class Connector;
}
namespace ui {
@@ -36,7 +36,7 @@ class VIEWS_MUS_EXPORT PlatformWindowMus
public NON_EXPORTED_BASE(mus::InputEventHandler) {
public:
PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::Window* mus_window);
~PlatformWindowMus() override;
diff --git a/ui/views/mus/screen_mus.cc b/ui/views/mus/screen_mus.cc
index 5b22354..7c763e7 100644
--- a/ui/views/mus/screen_mus.cc
+++ b/ui/views/mus/screen_mus.cc
@@ -7,7 +7,7 @@
// #include "components/mus/public/interfaces/window_manager_constants.mojom.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/gfx/display_finder.h"
#include "ui/gfx/display_observer.h"
#include "ui/views/mus/screen_mus_delegate.h"
@@ -75,10 +75,10 @@ ScreenMus::ScreenMus(ScreenMusDelegate* delegate)
ScreenMus::~ScreenMus() {}
-void ScreenMus::Init(mojo::Shell* shell) {
+void ScreenMus::Init(mojo::Connector* connector) {
gfx::Screen::SetScreenInstance(this);
- shell->ConnectToInterface("mojo:mus", &display_manager_);
+ connector->ConnectToInterface("mojo:mus", &display_manager_);
display_manager_->AddObserver(
display_manager_observer_binding_.CreateInterfacePtrAndBind());
diff --git a/ui/views/mus/screen_mus.h b/ui/views/mus/screen_mus.h
index 0e9a352..04e4b5e 100644
--- a/ui/views/mus/screen_mus.h
+++ b/ui/views/mus/screen_mus.h
@@ -15,7 +15,7 @@
#include "ui/views/mus/mus_export.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace views {
@@ -30,7 +30,7 @@ class VIEWS_MUS_EXPORT ScreenMus
explicit ScreenMus(ScreenMusDelegate* delegate);
~ScreenMus() override;
- void Init(mojo::Shell* shell);
+ void Init(mojo::Connector* connector);
private:
int FindDisplayIndexById(int64_t id) const;
diff --git a/ui/views/mus/surface_binding.cc b/ui/views/mus/surface_binding.cc
index c9e897a..e33e324 100644
--- a/ui/views/mus/surface_binding.cc
+++ b/ui/views/mus/surface_binding.cc
@@ -26,7 +26,7 @@
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/views/mus/window_tree_host_mus.h"
namespace views {
@@ -41,7 +41,7 @@ namespace views {
class SurfaceBinding::PerConnectionState
: public base::RefCounted<PerConnectionState> {
public:
- static PerConnectionState* Get(mojo::Shell* shell,
+ static PerConnectionState* Get(mojo::Connector* connector,
mus::WindowTreeConnection* connection);
scoped_ptr<cc::OutputSurface> CreateOutputSurface(
@@ -54,7 +54,8 @@ class SurfaceBinding::PerConnectionState
friend class base::RefCounted<PerConnectionState>;
- PerConnectionState(mojo::Shell* shell, mus::WindowTreeConnection* connection);
+ PerConnectionState(mojo::Connector* connector,
+ mus::WindowTreeConnection* connection);
~PerConnectionState();
void Init();
@@ -62,7 +63,7 @@ class SurfaceBinding::PerConnectionState
static base::LazyInstance<
base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky window_states;
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
mus::WindowTreeConnection* connection_;
// Set of state needed to create an OutputSurface.
@@ -78,7 +79,7 @@ base::LazyInstance<base::ThreadLocalPointer<
// static
SurfaceBinding::PerConnectionState* SurfaceBinding::PerConnectionState::Get(
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::WindowTreeConnection* connection) {
ConnectionToStateMap* window_map = window_states.Pointer()->Get();
if (!window_map) {
@@ -86,7 +87,7 @@ SurfaceBinding::PerConnectionState* SurfaceBinding::PerConnectionState::Get(
window_states.Pointer()->Set(window_map);
}
if (!(*window_map)[connection]) {
- (*window_map)[connection] = new PerConnectionState(shell, connection);
+ (*window_map)[connection] = new PerConnectionState(connector, connection);
(*window_map)[connection]->Init();
}
return (*window_map)[connection];
@@ -108,9 +109,9 @@ SurfaceBinding::PerConnectionState::CreateOutputSurface(
}
SurfaceBinding::PerConnectionState::PerConnectionState(
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::WindowTreeConnection* connection)
- : shell_(shell), connection_(connection) {}
+ : connector_(connector), connection_(connection) {}
SurfaceBinding::PerConnectionState::~PerConnectionState() {
ConnectionToStateMap* window_map = window_states.Pointer()->Get();
@@ -124,17 +125,17 @@ SurfaceBinding::PerConnectionState::~PerConnectionState() {
}
void SurfaceBinding::PerConnectionState::Init() {
- shell_->ConnectToInterface("mojo:mus", &gpu_);
+ connector_->ConnectToInterface("mojo:mus", &gpu_);
}
// SurfaceBinding --------------------------------------------------------------
-SurfaceBinding::SurfaceBinding(mojo::Shell* shell,
+SurfaceBinding::SurfaceBinding(mojo::Connector* connector,
mus::Window* window,
mus::mojom::SurfaceType surface_type)
: window_(window),
surface_type_(surface_type),
- state_(PerConnectionState::Get(shell, window->connection())) {}
+ state_(PerConnectionState::Get(connector, window->connection())) {}
SurfaceBinding::~SurfaceBinding() {}
diff --git a/ui/views/mus/surface_binding.h b/ui/views/mus/surface_binding.h
index 0b468b5..2c6c5b6 100644
--- a/ui/views/mus/surface_binding.h
+++ b/ui/views/mus/surface_binding.h
@@ -16,7 +16,7 @@ class OutputSurface;
}
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -32,7 +32,7 @@ namespace views {
// connection.
class VIEWS_MUS_EXPORT SurfaceBinding {
public:
- SurfaceBinding(mojo::Shell* shell,
+ SurfaceBinding(mojo::Connector* connector,
mus::Window* window,
mus::mojom::SurfaceType surface_type);
~SurfaceBinding();
diff --git a/ui/views/mus/surface_context_factory.cc b/ui/views/mus/surface_context_factory.cc
index 0d5bfee..840a16b 100644
--- a/ui/views/mus/surface_context_factory.cc
+++ b/ui/views/mus/surface_context_factory.cc
@@ -27,10 +27,10 @@ class FakeReflector : public ui::Reflector {
} // namespace
SurfaceContextFactory::SurfaceContextFactory(
- mojo::Shell* shell,
+ mojo::Connector* connector,
mus::Window* window,
mus::mojom::SurfaceType surface_type)
- : surface_binding_(shell, window, surface_type),
+ : surface_binding_(connector, window, surface_type),
next_surface_id_namespace_(1u) {}
SurfaceContextFactory::~SurfaceContextFactory() {}
diff --git a/ui/views/mus/surface_context_factory.h b/ui/views/mus/surface_context_factory.h
index 72c85fd..6399d5a 100644
--- a/ui/views/mus/surface_context_factory.h
+++ b/ui/views/mus/surface_context_factory.h
@@ -16,7 +16,7 @@
#include "ui/views/mus/surface_binding.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -27,7 +27,7 @@ namespace views {
class VIEWS_MUS_EXPORT SurfaceContextFactory : public ui::ContextFactory {
public:
- SurfaceContextFactory(mojo::Shell* shell,
+ SurfaceContextFactory(mojo::Connector* connector,
mus::Window* window,
mus::mojom::SurfaceType surface_type);
~SurfaceContextFactory() override;
diff --git a/ui/views/mus/window_manager_connection.cc b/ui/views/mus/window_manager_connection.cc
index 10d373b..a7841fd 100644
--- a/ui/views/mus/window_manager_connection.cc
+++ b/ui/views/mus/window_manager_connection.cc
@@ -13,7 +13,7 @@
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/network/network_type_converters.h"
#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "ui/views/mus/native_widget_mus.h"
#include "ui/views/mus/screen_mus.h"
#include "ui/views/views_delegate.h"
@@ -31,9 +31,9 @@ base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr =
} // namespace
// static
-void WindowManagerConnection::Create(mojo::Shell* shell) {
+void WindowManagerConnection::Create(mojo::Connector* connector) {
DCHECK(!lazy_tls_ptr.Pointer()->Get());
- lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(shell));
+ lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(connector));
}
// static
@@ -60,17 +60,17 @@ NativeWidget* WindowManagerConnection::CreateNativeWidgetMus(
internal::NativeWidgetDelegate* delegate) {
std::map<std::string, std::vector<uint8_t>> properties = props;
NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties);
- return new NativeWidgetMus(delegate, shell_, NewWindow(properties),
+ return new NativeWidgetMus(delegate, connector_, NewWindow(properties),
mus::mojom::SurfaceType::DEFAULT);
}
-WindowManagerConnection::WindowManagerConnection(mojo::Shell* shell)
- : shell_(shell), window_tree_connection_(nullptr) {
+WindowManagerConnection::WindowManagerConnection(mojo::Connector* connector)
+ : connector_(connector), window_tree_connection_(nullptr) {
window_tree_connection_.reset(
- mus::WindowTreeConnection::Create(this, shell_));
+ mus::WindowTreeConnection::Create(this, connector_));
screen_.reset(new ScreenMus(this));
- screen_->Init(shell);
+ screen_->Init(connector);
ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind(
&WindowManagerConnection::CreateNativeWidgetMus,
diff --git a/ui/views/mus/window_manager_connection.h b/ui/views/mus/window_manager_connection.h
index 0095728..896f9e7 100644
--- a/ui/views/mus/window_manager_connection.h
+++ b/ui/views/mus/window_manager_connection.h
@@ -15,7 +15,7 @@
#include "ui/views/widget/widget.h"
namespace mojo {
-class Shell;
+class Connector;
}
namespace views {
@@ -37,13 +37,13 @@ class VIEWS_MUS_EXPORT WindowManagerConnection
: public NON_EXPORTED_BASE(mus::WindowTreeDelegate),
public ScreenMusDelegate {
public:
- static void Create(mojo::Shell* shell);
+ static void Create(mojo::Connector* connector);
static WindowManagerConnection* Get();
// Destroys the singleton instance.
static void Reset();
- mojo::Shell* shell() { return shell_; }
+ mojo::Connector* connector() { return connector_; }
mus::Window* NewWindow(const std::map<std::string,
std::vector<uint8_t>>& properties);
@@ -54,7 +54,7 @@ class VIEWS_MUS_EXPORT WindowManagerConnection
internal::NativeWidgetDelegate* delegate);
private:
- explicit WindowManagerConnection(mojo::Shell* shell);
+ explicit WindowManagerConnection(mojo::Connector* connector);
~WindowManagerConnection() override;
// mus::WindowTreeDelegate:
@@ -65,7 +65,7 @@ class VIEWS_MUS_EXPORT WindowManagerConnection
void OnWindowManagerFrameValuesChanged() override;
- mojo::Shell* shell_;
+ mojo::Connector* connector_;
scoped_ptr<ScreenMus> screen_;
scoped_ptr<mus::WindowTreeConnection> window_tree_connection_;
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/views/mus/window_tree_host_mus.cc
index 6326e85..507adc5 100644
--- a/ui/views/mus/window_tree_host_mus.cc
+++ b/ui/views/mus/window_tree_host_mus.cc
@@ -16,13 +16,13 @@ namespace views {
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHostMus, public:
-WindowTreeHostMus::WindowTreeHostMus(mojo::Shell* shell,
+WindowTreeHostMus::WindowTreeHostMus(mojo::Connector* connector,
NativeWidgetMus* native_widget,
mus::Window* window)
: native_widget_(native_widget),
show_state_(ui::PLATFORM_WINDOW_STATE_UNKNOWN) {
SetPlatformWindow(
- make_scoped_ptr(new PlatformWindowMus(this, shell, window)));
+ make_scoped_ptr(new PlatformWindowMus(this, connector, window)));
// The location of events is already transformed, and there is no way to
// correctly determine the reverse transform. So, don't attempt to transform
// event locations, else the root location is wrong.
diff --git a/ui/views/mus/window_tree_host_mus.h b/ui/views/mus/window_tree_host_mus.h
index a97475a..4044e8e 100644
--- a/ui/views/mus/window_tree_host_mus.h
+++ b/ui/views/mus/window_tree_host_mus.h
@@ -12,7 +12,7 @@
class SkBitmap;
namespace mojo {
-class Shell;
+class Connector;
}
namespace mus {
@@ -27,7 +27,7 @@ class PlatformWindowMus;
class VIEWS_MUS_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform {
public:
- WindowTreeHostMus(mojo::Shell* shell,
+ WindowTreeHostMus(mojo::Connector* connector,
NativeWidgetMus* native_widget_,
mus::Window* window);
~WindowTreeHostMus() override;