Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: mojo/public/cpp/application/lib/application_impl.cc

Issue 868463008: Remove Client relationship between mojo.Shell/mojo.Application (Closed) Base URL: git@github.com:domokit/mojo.git@app_impl_init
Patch Set: fix android Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/application/lib/application_impl.cc
diff --git a/mojo/public/cpp/application/lib/application_impl.cc b/mojo/public/cpp/application/lib/application_impl.cc
index 89a9ab04bb475960d1c48842cba24c2e2ee63656..4d1f8dcf3442827c84090373b6a7e2f06c1048fd 100644
--- a/mojo/public/cpp/application/lib/application_impl.cc
+++ b/mojo/public/cpp/application/lib/application_impl.cc
@@ -24,13 +24,12 @@ class ApplicationImpl::ShellPtrWatcher : public ErrorHandler {
MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher);
};
-ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, ShellPtr shell)
+ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
+ InterfaceRequest<Application> request)
: initialized_(false),
delegate_(delegate),
- shell_(shell.Pass()),
- shell_watch_(new ShellPtrWatcher(this)) {
- shell_.set_client(this);
- shell_.set_error_handler(shell_watch_);
+ binding_(this, request.Pass()),
+ shell_watch_(nullptr) {
}
bool ApplicationImpl::HasArg(const std::string& arg) const {
@@ -57,7 +56,7 @@ ApplicationImpl::~ApplicationImpl() {
ApplicationConnection* ApplicationImpl::ConnectToApplication(
const String& application_url) {
- MOJO_CHECK(initialized_);
+ MOJO_CHECK(shell_);
ServiceProviderPtr local_services;
InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services);
ServiceProviderPtr remote_services;
@@ -73,20 +72,26 @@ ApplicationConnection* ApplicationImpl::ConnectToApplication(
return registry;
}
-ShellPtr ApplicationImpl::UnbindShell() {
- MOJO_CHECK(shell_);
- ShellPtr unbound_shell;
- unbound_shell.Bind(shell_.PassMessagePipe());
- return unbound_shell.Pass();
-}
-
-void ApplicationImpl::Initialize(Array<String> args) {
- MOJO_CHECK(!initialized_);
- initialized_ = true;
+void ApplicationImpl::Initialize(ShellPtr shell, Array<String> args) {
+ shell_ = shell.Pass();
+ shell_watch_ = new ShellPtrWatcher(this);
+ shell_.set_error_handler(shell_watch_);
args_ = args.To<std::vector<std::string>>();
delegate_->Initialize(this);
}
+void ApplicationImpl::WaitForInitialize() {
+ if (!shell_)
+ binding_.WaitForIncomingMethodCall();
+}
+
+void ApplicationImpl::UnbindConnections(
+ InterfaceRequest<Application>* application_request,
+ ShellPtr* shell) {
+ *application_request = binding_.Unbind();
+ shell->Bind(shell_.PassMessagePipe());
+}
+
void ApplicationImpl::AcceptConnection(
const String& requestor_url,
InterfaceRequest<ServiceProvider> services,

Powered by Google App Engine
This is Rietveld 408576698