forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an implementation of ApplicationManager interface, which allows registration of instances launched by other process launchers. R=sky@chromium.org BUG=none Review URL: https://codereview.chromium.org/1435933003 Cr-Commit-Position: refs/heads/master@{#359385}
- Loading branch information
ben
authored and
Commit bot
committed
Nov 12, 2015
1 parent
f911237
commit 86c0f7e
Showing
8 changed files
with
192 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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. | ||
|
||
module mojo.shell.mojom; | ||
|
||
interface ApplicationManager { | ||
// Instructs the ApplicationManager to create an instance for an existing | ||
// process at the other end of |channel|, and perform applicable | ||
// initialization. This assumes the target process will bind the other end of | ||
// channel to an implementation of ChildController and bind an Application | ||
// request there. | ||
CreateInstanceForHandle(handle channel); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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/shell_application_delegate.h" | ||
|
||
#include "mojo/application/public/cpp/application_connection.h" | ||
|
||
namespace mojo { | ||
namespace shell { | ||
|
||
ShellApplicationDelegate::ShellApplicationDelegate( | ||
mojo::shell::ApplicationManager* manager) | ||
: manager_(manager) {} | ||
ShellApplicationDelegate::~ShellApplicationDelegate() {} | ||
|
||
void ShellApplicationDelegate::Initialize(ApplicationImpl* app) {} | ||
bool ShellApplicationDelegate::ConfigureIncomingConnection( | ||
ApplicationConnection* connection) { | ||
connection->AddService<mojom::ApplicationManager>(this); | ||
return true; | ||
} | ||
|
||
void ShellApplicationDelegate::Create( | ||
ApplicationConnection* connection, | ||
InterfaceRequest<mojom::ApplicationManager> request) { | ||
bindings_.AddBinding(this, request.Pass()); | ||
} | ||
|
||
void ShellApplicationDelegate::CreateInstanceForHandle(ScopedHandle channel) { | ||
// TODO(beng): create the instance. | ||
} | ||
|
||
} // namespace shell | ||
} // namespace mojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef MOJO_SHELL_SHELL_APPLICATION_DELEGATE_H_ | ||
#define MOJO_SHELL_SHELL_APPLICATION_DELEGATE_H_ | ||
|
||
#include "mojo/application/public/cpp/application_delegate.h" | ||
|
||
#include "base/macros.h" | ||
#include "mojo/application/public/cpp/interface_factory.h" | ||
#include "mojo/common/weak_binding_set.h" | ||
#include "mojo/shell/application_manager.mojom.h" | ||
|
||
namespace mojo { | ||
namespace shell { | ||
class ApplicationManager; | ||
|
||
class ShellApplicationDelegate | ||
: public ApplicationDelegate, | ||
public InterfaceFactory<mojom::ApplicationManager>, | ||
public mojom::ApplicationManager { | ||
public: | ||
explicit ShellApplicationDelegate(mojo::shell::ApplicationManager* manager); | ||
~ShellApplicationDelegate() override; | ||
|
||
private: | ||
// Overridden from ApplicationDelegate: | ||
void Initialize(ApplicationImpl* app) override; | ||
bool ConfigureIncomingConnection(ApplicationConnection* connection) override; | ||
|
||
// Overridden from InterfaceFactory<mojom::ApplicationManager>: | ||
void Create( | ||
ApplicationConnection* connection, | ||
InterfaceRequest<mojom::ApplicationManager> request) override; | ||
|
||
// Overridden from mojom::ApplicationManager: | ||
void CreateInstanceForHandle(ScopedHandle channel) override; | ||
|
||
mojo::shell::ApplicationManager* manager_; | ||
|
||
WeakBindingSet<mojom::ApplicationManager> bindings_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ShellApplicationDelegate); | ||
}; | ||
|
||
} // namespace shell | ||
} // namespace mojo | ||
|
||
#endif // MOJO_SHELL_SHELL_APPLICATION_DELEGATE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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/shell_application_loader.h" | ||
|
||
#include "mojo/application/public/cpp/application_impl.h" | ||
#include "mojo/shell/shell_application_delegate.h" | ||
|
||
namespace mojo { | ||
namespace shell { | ||
|
||
ShellApplicationLoader::ShellApplicationLoader(ApplicationManager* manager) | ||
: manager_(manager) {} | ||
ShellApplicationLoader::~ShellApplicationLoader() {} | ||
|
||
void ShellApplicationLoader::Load( | ||
const GURL& url, | ||
InterfaceRequest<Application> application_request) { | ||
DCHECK(application_request.is_pending()); | ||
app_.reset(new ApplicationImpl(new ShellApplicationDelegate(manager_), | ||
application_request.Pass())); | ||
} | ||
|
||
} // namespace shell | ||
} // namespace mojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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_SHELL_APPLICATION_LOADER_H_ | ||
#define MOJO_SHELL_SHELL_APPLICATION_LOADER_H_ | ||
|
||
#include "base/macros.h" | ||
#include "mojo/shell/application_loader.h" | ||
|
||
namespace mojo { | ||
class ApplicationImpl; | ||
namespace shell { | ||
|
||
class ShellApplicationLoader : public ApplicationLoader { | ||
public: | ||
explicit ShellApplicationLoader(ApplicationManager* manager); | ||
~ShellApplicationLoader() override; | ||
|
||
private: | ||
// Overridden from ApplicationLoader: | ||
void Load( | ||
const GURL& url, | ||
InterfaceRequest<Application> application_request) override; | ||
|
||
scoped_ptr<ApplicationImpl> app_; | ||
|
||
ApplicationManager* manager_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ShellApplicationLoader); | ||
}; | ||
|
||
} // namespace shell | ||
} // namespace mojo | ||
|
||
#endif // MOJO_SHELL_SHELL_APPLICATION_LOADER_H_ |