summaryrefslogtreecommitdiffstats
path: root/mojo/shell
diff options
context:
space:
mode:
authorben <ben@chromium.org>2016-02-26 08:45:58 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-26 16:48:05 +0000
commitbf36a789d350f459f26321c7cddf2640f2ffd38c (patch)
tree353ef9686d72d96c85b248280844961b276534e0 /mojo/shell
parentc04a33bce2761ef30c51a833781effc7162e68cd (diff)
downloadchromium_src-bf36a789d350f459f26321c7cddf2640f2ffd38c.zip
chromium_src-bf36a789d350f459f26321c7cddf2640f2ffd38c.tar.gz
chromium_src-bf36a789d350f459f26321c7cddf2640f2ffd38c.tar.bz2
Fold ApplicationInstance into ApplicationManager
TBR=sky@chromium.org BUG= Review URL: https://codereview.chromium.org/1727233006 Cr-Commit-Position: refs/heads/master@{#377902}
Diffstat (limited to 'mojo/shell')
-rw-r--r--mojo/shell/BUILD.gn2
-rw-r--r--mojo/shell/application_instance.cc119
-rw-r--r--mojo/shell/application_instance.h90
-rw-r--r--mojo/shell/application_manager.cc231
-rw-r--r--mojo/shell/application_manager.h50
-rw-r--r--mojo/shell/connect_params.cc4
-rw-r--r--mojo/shell/connect_params.h2
7 files changed, 201 insertions, 297 deletions
diff --git a/mojo/shell/BUILD.gn b/mojo/shell/BUILD.gn
index 2fbf078..ad94d19 100644
--- a/mojo/shell/BUILD.gn
+++ b/mojo/shell/BUILD.gn
@@ -19,8 +19,6 @@ group("all") {
source_set("shell") {
output_name = "mojo_shell"
sources = [
- "application_instance.cc",
- "application_instance.h",
"application_loader.h",
"application_manager.cc",
"application_manager.h",
diff --git a/mojo/shell/application_instance.cc b/mojo/shell/application_instance.cc
deleted file mode 100644
index e1930b1..0000000
--- a/mojo/shell/application_instance.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/shell/application_instance.h"
-
-#include <stdint.h>
-
-#include <utility>
-
-#include "base/atomic_sequence_num.h"
-#include "base/bind.h"
-#include "base/stl_util.h"
-#include "mojo/common/common_type_converters.h"
-#include "mojo/common/url_type_converters.h"
-#include "mojo/shell/application_manager.h"
-#include "mojo/shell/capability_filter.h"
-
-namespace mojo {
-namespace shell {
-
-ApplicationInstance::ApplicationInstance(
- mojom::ShellClientPtr shell_client,
- ApplicationManager* manager,
- const Identity& identity)
- : manager_(manager),
- id_(GenerateUniqueID()),
- identity_(identity),
- allow_any_application_(identity.filter().size() == 1 &&
- identity.filter().count("*") == 1),
- shell_client_(std::move(shell_client)),
- pid_receiver_binding_(this),
- native_runner_(nullptr),
- pid_(base::kNullProcessId) {
- DCHECK_NE(kInvalidApplicationID, id_);
-}
-
-ApplicationInstance::~ApplicationInstance() {}
-
-void ApplicationInstance::InitializeApplication() {
- shell_client_->Initialize(connectors_.CreateInterfacePtrAndBind(this),
- identity_.url().spec(), id_, identity_.user_id());
- connectors_.set_connection_error_handler(
- base::Bind(&ApplicationManager::OnApplicationInstanceError,
- base::Unretained(manager_), base::Unretained(this)));
-}
-
-void ApplicationInstance::ConnectToClient(scoped_ptr<ConnectParams> params) {
- params->connect_callback().Run(id_);
- AllowedInterfaces interfaces;
- interfaces.insert("*");
- if (!params->source().is_null())
- interfaces = GetAllowedInterfaces(params->source().filter(), identity_);
-
- ApplicationInstance* source =
- manager_->GetApplicationInstance(params->source());
- uint32_t source_id = source ? source->id() : kInvalidApplicationID;
- shell_client_->AcceptConnection(
- params->source().url().spec(), params->source().user_id(), source_id,
- params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(),
- Array<String>::From(interfaces), params->target().url().spec());
-}
-
-void ApplicationInstance::SetNativeRunner(NativeRunner* native_runner) {
- native_runner_ = native_runner;
-}
-
-void ApplicationInstance::BindPIDReceiver(
- InterfaceRequest<mojom::PIDReceiver> pid_receiver) {
- pid_receiver_binding_.Bind(std::move(pid_receiver));
-}
-
-// Connector implementation:
-void ApplicationInstance::Connect(
- const String& app_url,
- uint32_t user_id,
- shell::mojom::InterfaceProviderRequest remote_interfaces,
- shell::mojom::InterfaceProviderPtr local_interfaces,
- const ConnectCallback& callback) {
- GURL url = app_url.To<GURL>();
- if (!url.is_valid()) {
- LOG(ERROR) << "Error: invalid URL: " << app_url;
- callback.Run(kInvalidApplicationID);
- return;
- }
- if (allow_any_application_ ||
- identity_.filter().find(url.spec()) != identity_.filter().end()) {
- scoped_ptr<ConnectParams> params(new ConnectParams);
- params->set_source(identity_);
- params->set_target(Identity(url, std::string(), user_id));
- params->set_remote_interfaces(std::move(remote_interfaces));
- params->set_local_interfaces(std::move(local_interfaces));
- params->set_connect_callback(callback);
- manager_->Connect(std::move(params));
- } else {
- LOG(WARNING) << "CapabilityFilter prevented connection from: " <<
- identity_.url() << " to: " << url.spec();
- callback.Run(kInvalidApplicationID);
- }
-}
-
-void ApplicationInstance::Clone(mojom::ConnectorRequest request) {
- connectors_.AddBinding(this, std::move(request));
-}
-
-void ApplicationInstance::SetPID(uint32_t pid) {
- // This will call us back to update pid_.
- manager_->ApplicationPIDAvailable(id_, pid);
-}
-
-uint32_t ApplicationInstance::GenerateUniqueID() const {
- static uint32_t id = kInvalidApplicationID;
- ++id;
- CHECK_NE(kInvalidApplicationID, id);
- return id;
-}
-
-} // namespace shell
-} // namespace mojo
diff --git a/mojo/shell/application_instance.h b/mojo/shell/application_instance.h
deleted file mode 100644
index 3126af0..0000000
--- a/mojo/shell/application_instance.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_SHELL_APPLICATION_INSTANCE_H_
-#define MOJO_SHELL_APPLICATION_INSTANCE_H_
-
-#include <stdint.h>
-
-#include <set>
-
-#include "base/callback.h"
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/process/process_handle.h"
-#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/bindings/binding_set.h"
-#include "mojo/shell/connect_params.h"
-#include "mojo/shell/identity.h"
-#include "mojo/shell/public/interfaces/application_manager.mojom.h"
-#include "mojo/shell/public/interfaces/shell.mojom.h"
-#include "mojo/shell/public/interfaces/shell_client.mojom.h"
-#include "url/gurl.h"
-
-namespace mojo {
-namespace shell {
-
-class ApplicationManager;
-class NativeRunner;
-
-// Encapsulates a connection to an instance of an application, tracked by the
-// shell's ApplicationManager.
-class ApplicationInstance : public mojom::Connector,
- public mojom::PIDReceiver {
- public:
- ApplicationInstance(
- mojom::ShellClientPtr shell_client,
- ApplicationManager* manager,
- const Identity& identity);
- ~ApplicationInstance() override;
-
- void InitializeApplication();
-
- void ConnectToClient(scoped_ptr<ConnectParams> params);
-
- // Required before GetProcessId can be called.
- void SetNativeRunner(NativeRunner* native_runner);
-
- void BindPIDReceiver(InterfaceRequest<mojom::PIDReceiver> pid_receiver);
-
- mojom::ShellClient* shell_client() { return shell_client_.get(); }
- const Identity& identity() const { return identity_; }
- uint32_t id() const { return id_; }
- base::ProcessId pid() const { return pid_; }
- void set_pid(base::ProcessId pid) { pid_ = pid; }
-
- private:
- // Connector implementation:
- void Connect(const String& app_url,
- uint32_t user_id,
- shell::mojom::InterfaceProviderRequest remote_interfaces,
- shell::mojom::InterfaceProviderPtr local_interfaces,
- const ConnectCallback& callback) override;
- void Clone(mojom::ConnectorRequest request) override;
-
- // PIDReceiver implementation:
- void SetPID(uint32_t pid) override;
-
- uint32_t GenerateUniqueID() const;
-
- ApplicationManager* const manager_;
- // An id that identifies this instance. Distinct from pid, as a single process
- // may vend multiple application instances, and this object may exist before a
- // process is launched.
- const uint32_t id_;
- const Identity identity_;
- const bool allow_any_application_;
- mojom::ShellClientPtr shell_client_;
- Binding<mojom::PIDReceiver> pid_receiver_binding_;
- BindingSet<mojom::Connector> connectors_;
- NativeRunner* native_runner_;
- base::ProcessId pid_;
-
- DISALLOW_COPY_AND_ASSIGN(ApplicationInstance);
-};
-
-} // namespace shell
-} // namespace mojo
-
-#endif // MOJO_SHELL_APPLICATION_INSTANCE_H_
diff --git a/mojo/shell/application_manager.cc b/mojo/shell/application_manager.cc
index 3267d5c..7ec5cdf 100644
--- a/mojo/shell/application_manager.cc
+++ b/mojo/shell/application_manager.cc
@@ -13,22 +13,145 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/process/process.h"
+#include "base/process/process_handle.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/trace_event/trace_event.h"
#include "mojo/common/url_type_converters.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/services/package_manager/loader.h"
-#include "mojo/shell/application_instance.h"
#include "mojo/shell/connect_util.h"
#include "mojo/shell/public/cpp/connect.h"
#include "mojo/shell/public/cpp/shell_connection.h"
-#include "mojo/shell/switches.h"
+#include "mojo/shell/public/interfaces/application_manager.mojom.h"
+#include "mojo/shell/public/interfaces/shell.mojom.h"
+#include "mojo/shell/public/interfaces/shell_client.mojom.h"
#include "mojo/util/filename_util.h"
namespace mojo {
namespace shell {
+// Encapsulates a connection to an instance of an application, tracked by the
+// shell's ApplicationManager.
+class ApplicationManager::Instance : public mojom::Connector,
+ public mojom::PIDReceiver {
+ public:
+ Instance(mojom::ShellClientPtr shell_client,
+ ApplicationManager* manager,
+ const Identity& identity)
+ : manager_(manager),
+ id_(GenerateUniqueID()),
+ identity_(identity),
+ allow_any_application_(identity.filter().size() == 1 &&
+ identity.filter().count("*") == 1),
+ shell_client_(std::move(shell_client)),
+ pid_receiver_binding_(this) {
+ DCHECK_NE(kInvalidApplicationID, id_);
+ }
+
+ ~Instance() override {}
+
+ void Initialize() {
+ shell_client_->Initialize(connectors_.CreateInterfacePtrAndBind(this),
+ identity_.url().spec(), id_, identity_.user_id());
+ connectors_.set_connection_error_handler(
+ base::Bind(&ApplicationManager::OnInstanceError,
+ base::Unretained(manager_), base::Unretained(this)));
+ }
+
+ void ConnectToClient(scoped_ptr<ConnectParams> params) {
+ params->connect_callback().Run(id_);
+ AllowedInterfaces interfaces;
+ interfaces.insert("*");
+ if (!params->source().is_null())
+ interfaces = GetAllowedInterfaces(params->source().filter(), identity_);
+
+ Instance* source = manager_->GetExistingInstance(params->source());
+ uint32_t source_id = source ? source->id() : kInvalidApplicationID;
+ shell_client_->AcceptConnection(
+ params->source().url().spec(), params->source().user_id(), source_id,
+ params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(),
+ Array<String>::From(interfaces), params->target().url().spec());
+ }
+
+ // Required before GetProcessId can be called.
+ void SetNativeRunner(NativeRunner* native_runner) {
+ native_runner_ = native_runner;
+ }
+
+ void BindPIDReceiver(mojom::PIDReceiverRequest pid_receiver) {
+ pid_receiver_binding_.Bind(std::move(pid_receiver));
+ }
+
+ mojom::ShellClient* shell_client() { return shell_client_.get(); }
+ const Identity& identity() const { return identity_; }
+ uint32_t id() const { return id_; }
+ base::ProcessId pid() const { return pid_; }
+ void set_pid(base::ProcessId pid) { pid_ = pid; }
+
+ private:
+ // Connector implementation:
+ void Connect(const String& app_url,
+ uint32_t user_id,
+ shell::mojom::InterfaceProviderRequest remote_interfaces,
+ shell::mojom::InterfaceProviderPtr local_interfaces,
+ const ConnectCallback& callback) override {
+ GURL url = app_url.To<GURL>();
+ if (!url.is_valid()) {
+ LOG(ERROR) << "Error: invalid URL: " << app_url;
+ callback.Run(kInvalidApplicationID);
+ return;
+ }
+ if (allow_any_application_ ||
+ identity_.filter().find(url.spec()) != identity_.filter().end()) {
+ scoped_ptr<ConnectParams> params(new ConnectParams);
+ params->set_source(identity_);
+ params->set_target(Identity(url, std::string(), user_id));
+ params->set_remote_interfaces(std::move(remote_interfaces));
+ params->set_local_interfaces(std::move(local_interfaces));
+ params->set_connect_callback(callback);
+ manager_->Connect(std::move(params));
+ }
+ else {
+ LOG(WARNING) << "CapabilityFilter prevented connection from: " <<
+ identity_.url() << " to: " << url.spec();
+ callback.Run(kInvalidApplicationID);
+ }
+ }
+ void Clone(mojom::ConnectorRequest request) override {
+ connectors_.AddBinding(this, std::move(request));
+ }
+
+ // PIDReceiver implementation:
+ void SetPID(uint32_t pid) override {
+ // This will call us back to update pid_.
+ manager_->ApplicationPIDAvailable(id_, pid);
+ }
+
+ uint32_t GenerateUniqueID() const {
+ static uint32_t id = kInvalidApplicationID;
+ ++id;
+ CHECK_NE(kInvalidApplicationID, id);
+ return id;
+ }
+
+ ApplicationManager* const manager_;
+ // An id that identifies this instance. Distinct from pid, as a single process
+ // may vend multiple application instances, and this object may exist before a
+ // process is launched.
+ const uint32_t id_;
+ const Identity identity_;
+ const bool allow_any_application_;
+ mojom::ShellClientPtr shell_client_;
+ Binding<mojom::PIDReceiver> pid_receiver_binding_;
+ BindingSet<mojom::Connector> connectors_;
+ NativeRunner* native_runner_ = nullptr;
+ base::ProcessId pid_ = base::kNullProcessId;
+
+ DISALLOW_COPY_AND_ASSIGN(Instance);
+};
+
// static
ApplicationManager::TestAPI::TestAPI(ApplicationManager* manager)
: manager_(manager) {
@@ -80,7 +203,7 @@ void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) {
DCHECK(params->target().url().is_valid());
if (params->target().user_id() == mojom::Connector::kUserInherit) {
- ApplicationInstance* source = GetApplicationInstance(params->source());
+ Instance* source = GetExistingInstance(params->source());
Identity target = params->target();
// TODO(beng): we should CHECK source.
target.set_user_id(source ? source->identity().user_id()
@@ -105,7 +228,7 @@ mojom::ShellClientRequest ApplicationManager::InitInstanceForEmbedder(
mojo::shell::Identity target(url, std::string(), mojom::Connector::kUserRoot);
target.SetFilter(GetPermissiveCapabilityFilter());
- DCHECK(!GetApplicationInstance(target));
+ DCHECK(!GetExistingInstance(target));
mojom::ShellClientRequest request;
embedder_instance_ = CreateInstance(target, &request);
@@ -122,48 +245,6 @@ void ApplicationManager::SetLoaderForURL(scoped_ptr<ApplicationLoader> loader,
url_to_loader_[url] = loader.release();
}
-void ApplicationManager::TerminateShellConnections() {
- STLDeleteValues(&identity_to_instance_);
-}
-
-void ApplicationManager::OnApplicationInstanceError(
- ApplicationInstance* instance) {
- const Identity identity = instance->identity();
- // Remove the shell.
- auto it = identity_to_instance_.find(identity);
- DCHECK(it != identity_to_instance_.end());
- int id = instance->id();
- delete it->second;
- identity_to_instance_.erase(it);
- listeners_.ForAllPtrs(
- [this, id](mojom::ApplicationManagerListener* listener) {
- listener->ApplicationInstanceDestroyed(id);
- });
- if (!instance_quit_callback_.is_null())
- instance_quit_callback_.Run(identity);
-}
-
-ApplicationInstance* ApplicationManager::GetApplicationInstance(
- const Identity& identity) const {
- const auto& it = identity_to_instance_.find(identity);
- return it != identity_to_instance_.end() ? it->second : nullptr;
-}
-
-void ApplicationManager::ApplicationPIDAvailable(
- uint32_t id,
- base::ProcessId pid) {
- for (auto& instance : identity_to_instance_) {
- if (instance.second->id() == id) {
- instance.second->set_pid(pid);
- break;
- }
- }
- listeners_.ForAllPtrs(
- [this, id, pid](mojom::ApplicationManagerListener* listener) {
- listener->ApplicationPIDAvailable(id, pid);
- });
-}
-
////////////////////////////////////////////////////////////////////////////////
// ApplicationManager, ShellClient implementation:
@@ -198,7 +279,7 @@ void ApplicationManager::CreateInstanceForHandle(
mojom::Connector::kUserInherit);
target_id.SetFilter(filter->filter.To<CapabilityFilter>());
mojom::ShellClientRequest request;
- ApplicationInstance* instance = CreateInstance(target_id, &request);
+ Instance* instance = CreateInstance(target_id, &request);
instance->BindPIDReceiver(std::move(pid_receiver));
scoped_ptr<NativeRunner> runner =
native_runner_factory_->Create(base::FilePath());
@@ -236,26 +317,66 @@ void ApplicationManager::InitPackageManager(
ConnectToInterface(this, CreateShellIdentity(), url, &shell_resolver_);
}
+void ApplicationManager::TerminateShellConnections() {
+ STLDeleteValues(&identity_to_instance_);
+}
+
+void ApplicationManager::OnInstanceError(Instance* instance) {
+ const Identity identity = instance->identity();
+ // Remove the shell.
+ auto it = identity_to_instance_.find(identity);
+ DCHECK(it != identity_to_instance_.end());
+ int id = instance->id();
+ delete it->second;
+ identity_to_instance_.erase(it);
+ listeners_.ForAllPtrs(
+ [this, id](mojom::ApplicationManagerListener* listener) {
+ listener->ApplicationInstanceDestroyed(id);
+ });
+ if (!instance_quit_callback_.is_null())
+ instance_quit_callback_.Run(identity);
+}
+
+ApplicationManager::Instance* ApplicationManager::GetExistingInstance(
+ const Identity& identity) const {
+ const auto& it = identity_to_instance_.find(identity);
+ return it != identity_to_instance_.end() ? it->second : nullptr;
+}
+
+void ApplicationManager::ApplicationPIDAvailable(
+ uint32_t id,
+ base::ProcessId pid) {
+ for (auto& instance : identity_to_instance_) {
+ if (instance.second->id() == id) {
+ instance.second->set_pid(pid);
+ break;
+ }
+ }
+ listeners_.ForAllPtrs(
+ [this, id, pid](mojom::ApplicationManagerListener* listener) {
+ listener->ApplicationPIDAvailable(id, pid);
+ });
+}
+
bool ApplicationManager::ConnectToExistingInstance(
scoped_ptr<ConnectParams>* params) {
- ApplicationInstance* instance = GetApplicationInstance((*params)->target());
+ Instance* instance = GetExistingInstance((*params)->target());
if (!instance) {
Identity root_identity = (*params)->target();
root_identity.set_user_id(mojom::Connector::kUserRoot);
- instance = GetApplicationInstance(root_identity);
+ instance = GetExistingInstance(root_identity);
if (!instance) return false;
}
instance->ConnectToClient(std::move(*params));
return true;
}
-ApplicationInstance* ApplicationManager::CreateInstance(
+ApplicationManager::Instance* ApplicationManager::CreateInstance(
const Identity& target_id,
mojom::ShellClientRequest* request) {
mojom::ShellClientPtr shell_client;
*request = GetProxy(&shell_client);
- ApplicationInstance* instance =
- new ApplicationInstance(std::move(shell_client), this, target_id);
+ Instance* instance = new Instance(std::move(shell_client), this, target_id);
DCHECK(identity_to_instance_.find(target_id) ==
identity_to_instance_.end());
identity_to_instance_[target_id] = instance;
@@ -265,7 +386,7 @@ ApplicationInstance* ApplicationManager::CreateInstance(
[this, &application_info](mojom::ApplicationManagerListener* listener) {
listener->ApplicationInstanceCreated(application_info.Clone());
});
- instance->InitializeApplication();
+ instance->Initialize();
return instance;
}
@@ -328,7 +449,7 @@ void ApplicationManager::OnGotResolvedURL(
target.SetFilter(filter);
mojom::ShellClientRequest request;
- ApplicationInstance* instance = CreateInstance(target, &request);
+ Instance* instance = CreateInstance(target, &request);
instance->ConnectToClient(std::move(params));
if (LoadWithLoader(target, &request))
@@ -384,7 +505,7 @@ void ApplicationManager::CleanupRunner(NativeRunner* runner) {
}
mojom::ApplicationInfoPtr ApplicationManager::CreateApplicationInfoForInstance(
- ApplicationInstance* instance) const {
+ Instance* instance) const {
mojom::ApplicationInfoPtr info(mojom::ApplicationInfo::New());
info->id = instance->id();
info->url = instance->identity().url().spec();
diff --git a/mojo/shell/application_manager.h b/mojo/shell/application_manager.h
index 92ed969..98c19f8 100644
--- a/mojo/shell/application_manager.h
+++ b/mojo/shell/application_manager.h
@@ -38,8 +38,6 @@ namespace mojo {
class ShellConnection;
namespace shell {
-class ApplicationInstance;
-
class ApplicationManager : public ShellClient,
public InterfaceFactory<mojom::ApplicationManager>,
public mojom::ApplicationManager {
@@ -50,7 +48,7 @@ class ApplicationManager : public ShellClient,
explicit TestAPI(ApplicationManager* manager);
~TestAPI();
- // Returns true if there is a ApplicationInstance for this URL.
+ // Returns true if there is a Instance for this URL.
bool HasRunningInstanceForURL(const GURL& url) const;
private:
ApplicationManager* manager_;
@@ -83,10 +81,10 @@ class ApplicationManager : public ShellClient,
// instance of the target application is running, one will be loaded.
void Connect(scoped_ptr<ConnectParams> params);
- // Creates a new ApplicationInstance identified as |url|. This is intended for
- // use by the ApplicationManager's embedder to register itself with the shell.
- // The URL is never resolved and there must not be an existing instance
- // associated with it. This must only be called once.
+ // Creates a new Instance identified as |url|. This is intended for use by the
+ // ApplicationManager's embedder to register itself with the shell. The URL is
+ // never resolved and there must not be an existing instance associated with
+ // it. This must only be called once.
mojom::ShellClientRequest InitInstanceForEmbedder(const GURL& url);
// Sets the default Loader to be used if not overridden by SetLoaderForURL().
@@ -97,20 +95,10 @@ class ApplicationManager : public ShellClient,
// Sets a Loader to be used for a specific url.
void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url);
- // Destroys all Shell-ends of connections established with Applications.
- // Applications connected by this ApplicationManager will observe pipe errors
- // and have a chance to shutdown.
- void TerminateShellConnections();
-
- // Removes a ApplicationInstance when it encounters an error.
- void OnApplicationInstanceError(ApplicationInstance* instance);
-
- ApplicationInstance* GetApplicationInstance(const Identity& identity) const;
-
- void ApplicationPIDAvailable(uint32_t id, base::ProcessId pid);
-
private:
- using IdentityToInstanceMap = std::map<Identity, ApplicationInstance*>;
+ class Instance;
+
+ using IdentityToInstanceMap = std::map<Identity, Instance*>;
using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
using IdentityToShellClientFactoryMap =
std::map<Identity, mojom::ShellClientFactoryPtr>;
@@ -133,13 +121,25 @@ class ApplicationManager : public ShellClient,
bool register_mojo_url_schemes,
scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog);
+ // Destroys all Shell-ends of connections established with Applications.
+ // Applications connected by this ApplicationManager will observe pipe errors
+ // and have a chance to shutdown.
+ void TerminateShellConnections();
+
+ // Removes a Instance when it encounters an error.
+ void OnInstanceError(Instance* instance);
+
+ Instance* GetExistingInstance(const Identity& identity) const;
+
+ void ApplicationPIDAvailable(uint32_t id, base::ProcessId pid);
+
// Attempt to complete the connection requested by |params| by connecting to
// an existing instance. If there is an existing instance, |params| is taken,
// and this function returns true.
bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params);
- ApplicationInstance* CreateInstance(const Identity& target_id,
- mojom::ShellClientRequest* request);
+ Instance* CreateInstance(const Identity& target_id,
+ mojom::ShellClientRequest* request);
void CreateShellClient(const Identity& source,
const Identity& shell_client_factory,
@@ -177,7 +177,7 @@ class ApplicationManager : public ShellClient,
void CleanupRunner(NativeRunner* runner);
mojom::ApplicationInfoPtr CreateApplicationInfoForInstance(
- ApplicationInstance* instance) const;
+ Instance* instance) const;
package_manager::mojom::ShellResolverPtr shell_resolver_;
@@ -192,8 +192,8 @@ class ApplicationManager : public ShellClient,
// Counter used to assign ids to content handlers.
uint32_t shell_client_factory_id_counter_;
- // The ApplicationInstance created by the shell embedder, if any.
- ApplicationInstance* embedder_instance_ = nullptr;
+ // The Instance created by the shell embedder, if any.
+ Instance* embedder_instance_ = nullptr;
InterfacePtrSet<mojom::ApplicationManagerListener> listeners_;
diff --git a/mojo/shell/connect_params.cc b/mojo/shell/connect_params.cc
index cdcbdb0..447c0d5 100644
--- a/mojo/shell/connect_params.cc
+++ b/mojo/shell/connect_params.cc
@@ -4,10 +4,6 @@
#include "mojo/shell/connect_params.h"
-#include <utility>
-
-#include "mojo/shell/application_instance.h"
-
namespace mojo {
namespace shell {
diff --git a/mojo/shell/connect_params.h b/mojo/shell/connect_params.h
index 8ff0fbb..70acfdf 100644
--- a/mojo/shell/connect_params.h
+++ b/mojo/shell/connect_params.h
@@ -19,8 +19,6 @@
namespace mojo {
namespace shell {
-class ApplicationInstance;
-
// This class represents a request for the application manager to connect to an
// application.
class ConnectParams {