From 3a7cbe0bed9f9b81ab1da4ed0e4dba764345977e Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 6 Feb 2016 20:35:30 -0800 Subject: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. Also eliminates use of mojo::shell::mojom::Shell in favor of this base interface. This means most code doesn't have to use ApplicationImpl - only the places that instantiate them. TBR=rockot@chromium.org BUG= Review URL: https://codereview.chromium.org/1674903003 Cr-Commit-Position: refs/heads/master@{#374049} --- mojo/shell/standalone/android/android_handler.cc | 6 ++++-- mojo/shell/standalone/android/android_handler.h | 2 +- mojo/shell/standalone/context.cc | 3 --- mojo/shell/standalone/shell_apptest.cc | 15 +++++++-------- mojo/shell/standalone/test/pingable_app.cc | 6 ++++-- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'mojo/shell/standalone') diff --git a/mojo/shell/standalone/android/android_handler.cc b/mojo/shell/standalone/android/android_handler.cc index f3de55f..175923b 100644 --- a/mojo/shell/standalone/android/android_handler.cc +++ b/mojo/shell/standalone/android/android_handler.cc @@ -16,7 +16,7 @@ #include "jni/AndroidHandler_jni.h" #include "mojo/common/data_pipe_utils.h" #include "mojo/public/c/system/main.h" -#include "mojo/shell/public/cpp/application_impl.h" +#include "mojo/shell/public/cpp/shell.h" #include "mojo/shell/runner/host/native_application_support.h" #include "mojo/shell/standalone/android/run_android_application_function.h" #include "mojo/util/filename_util.h" @@ -166,7 +166,9 @@ void AndroidHandler::RunApplication( reinterpret_cast(run_android_application_fn)); } -void AndroidHandler::Initialize(ApplicationImpl* app) {} +void AndroidHandler::Initialize(Shell* shell, + const std::string& url, + uint32_t id) {} bool AndroidHandler::AcceptConnection(ApplicationConnection* connection) { connection->AddService(&content_handler_factory_); diff --git a/mojo/shell/standalone/android/android_handler.h b/mojo/shell/standalone/android/android_handler.h index 1169699..e58d3bf 100644 --- a/mojo/shell/standalone/android/android_handler.h +++ b/mojo/shell/standalone/android/android_handler.h @@ -27,7 +27,7 @@ class AndroidHandler : public ApplicationDelegate, private: // ApplicationDelegate: - void Initialize(ApplicationImpl* app) override; + void Initialize(Shell* shell, const std::string& url, uint32_t id) override; bool AcceptConnection(ApplicationConnection* connection) override; // ContentHandlerFactory::Delegate: diff --git a/mojo/shell/standalone/context.cc b/mojo/shell/standalone/context.cc index f2f84d0..41a003f 100644 --- a/mojo/shell/standalone/context.cc +++ b/mojo/shell/standalone/context.cc @@ -36,9 +36,6 @@ #include "mojo/shell/application_loader.h" #include "mojo/shell/connect_to_application_params.h" #include "mojo/shell/package_manager/package_manager_impl.h" -#include "mojo/shell/public/cpp/application_connection.h" -#include "mojo/shell/public/cpp/application_delegate.h" -#include "mojo/shell/public/cpp/application_impl.h" #include "mojo/shell/query_util.h" #include "mojo/shell/runner/host/in_process_native_runner.h" #include "mojo/shell/runner/host/out_of_process_native_runner.h" diff --git a/mojo/shell/standalone/shell_apptest.cc b/mojo/shell/standalone/shell_apptest.cc index a8a5c5b..2ded998 100644 --- a/mojo/shell/standalone/shell_apptest.cc +++ b/mojo/shell/standalone/shell_apptest.cc @@ -18,8 +18,8 @@ #include "mojo/services/http_server/public/interfaces/http_server.mojom.h" #include "mojo/services/http_server/public/interfaces/http_server_factory.mojom.h" #include "mojo/services/network/public/interfaces/net_address.mojom.h" -#include "mojo/shell/public/cpp/application_impl.h" #include "mojo/shell/public/cpp/application_test_base.h" +#include "mojo/shell/public/cpp/shell.h" #include "mojo/shell/standalone/kPingable.h" #include "mojo/shell/standalone/test/pingable.mojom.h" @@ -77,8 +77,7 @@ class ShellHTTPAppTest : public test::ApplicationTestBase { void SetUp() override { ApplicationTestBase::SetUp(); - application_impl()->ConnectToService("mojo:http_server", - &http_server_factory_); + shell()->ConnectToService("mojo:http_server", &http_server_factory_); NetAddressPtr local_address(NetAddress::New()); local_address->family = NET_ADDRESS_FAMILY_IPV4; @@ -118,7 +117,7 @@ class ShellHTTPAppTest : public test::ApplicationTestBase { // Test that we can load apps over http. TEST_F(ShellHTTPAppTest, Http) { InterfacePtr pingable; - application_impl()->ConnectToService(GetURL("app"), &pingable); + shell()->ConnectToService(GetURL("app"), &pingable); pingable->Ping("hello", [this](const String& app_url, const String& connection_url, const String& message) { @@ -134,7 +133,7 @@ TEST_F(ShellHTTPAppTest, Http) { // TODO(aa): Test that apps receive the correct URL parameters. TEST_F(ShellHTTPAppTest, Redirect) { InterfacePtr pingable; - application_impl()->ConnectToService(GetURL("redirect"), &pingable); + shell()->ConnectToService(GetURL("redirect"), &pingable); pingable->Ping("hello", [this](const String& app_url, const String& connection_url, const String& message) { @@ -156,8 +155,8 @@ TEST_F(ShellHTTPAppTest, Redirect) { TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) { InterfacePtr pingable1; InterfacePtr pingable2; - application_impl()->ConnectToService(GetURL("app?foo"), &pingable1); - application_impl()->ConnectToService(GetURL("app?bar"), &pingable2); + shell()->ConnectToService(GetURL("app?foo"), &pingable1); + shell()->ConnectToService(GetURL("app?bar"), &pingable2); int num_responses = 0; auto callback = [this, &num_responses](const String& app_url, @@ -183,7 +182,7 @@ TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) { // mojo: URLs can have querystrings too TEST_F(ShellAppTest, MojoURLQueryHandling) { InterfacePtr pingable; - application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); + shell()->ConnectToService("mojo:pingable_app?foo", &pingable); auto callback = [this](const String& app_url, const String& connection_url, const String& message) { EXPECT_TRUE(base::EndsWith(app_url, "/pingable_app.mojo", diff --git a/mojo/shell/standalone/test/pingable_app.cc b/mojo/shell/standalone/test/pingable_app.cc index bd92bd5..31613b8 100644 --- a/mojo/shell/standalone/test/pingable_app.cc +++ b/mojo/shell/standalone/test/pingable_app.cc @@ -7,9 +7,9 @@ #include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/shell/public/cpp/application_delegate.h" -#include "mojo/shell/public/cpp/application_impl.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/standalone/test/pingable.mojom.h" namespace mojo { @@ -44,7 +44,9 @@ class PingableApp : public mojo::ApplicationDelegate, private: // ApplicationDelegate: - void Initialize(ApplicationImpl* impl) override { app_url_ = impl->url(); } + void Initialize(Shell* shell, const std::string& url, uint32_t id) override { + app_url_ = url; + } bool AcceptConnection(mojo::ApplicationConnection* connection) override { connection->AddService(this); -- cgit v1.1