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

Unified Diff: examples/wm_flow/embedded/embedded.cc

Issue 898013004: Remove uses of InterfaceImpl in wm_flow example (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « examples/wm_flow/app/app.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/wm_flow/embedded/embedded.cc
diff --git a/examples/wm_flow/embedded/embedded.cc b/examples/wm_flow/embedded/embedded.cc
index ed9cbb5c8c13a422d8840ac7abe4bc7c2b0fb632..fe79eeee3051f0fbd9c712ce67a5f4a5d57e6558 100644
--- a/examples/wm_flow/embedded/embedded.cc
+++ b/examples/wm_flow/embedded/embedded.cc
@@ -13,8 +13,8 @@
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/interface_factory_impl.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/view_manager/public/cpp/view.h"
#include "mojo/services/view_manager/public/cpp/view_manager.h"
#include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
@@ -25,47 +25,50 @@ namespace examples {
namespace {
-class EmbeddeeImpl : public mojo::InterfaceImpl<Embeddee> {
+class EmbeddeeImpl : public Embeddee {
public:
- EmbeddeeImpl() {}
- virtual ~EmbeddeeImpl() {}
+ explicit EmbeddeeImpl(mojo::InterfaceRequest<Embeddee> request)
+ : binding_(this, request.Pass()) {}
+ ~EmbeddeeImpl() override {}
private:
// Overridden from Embeddee:
- virtual void HelloBack(const mojo::Callback<void()>& callback) override {
+ void HelloBack(const mojo::Callback<void()>& callback) override {
callback.Run();
}
+ mojo::StrongBinding<Embeddee> binding_;
DISALLOW_COPY_AND_ASSIGN(EmbeddeeImpl);
};
} // namespace
class WMFlowEmbedded : public mojo::ApplicationDelegate,
- public mojo::ViewManagerDelegate {
+ public mojo::ViewManagerDelegate,
+ public mojo::InterfaceFactory<Embeddee> {
public:
WMFlowEmbedded() : shell_(nullptr) {
- embeddee_provider_impl_.AddService(&embeddee_factory_);
+ embeddee_provider_impl_.AddService(this);
}
virtual ~WMFlowEmbedded() {}
private:
// Overridden from Application:
- virtual void Initialize(mojo::ApplicationImpl* app) override {
+ void Initialize(mojo::ApplicationImpl* app) override {
shell_ = app->shell();
view_manager_client_factory_.reset(
new mojo::ViewManagerClientFactory(app->shell(), this));
}
- virtual bool ConfigureIncomingConnection(
+ bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override {
connection->AddService(view_manager_client_factory_.get());
return true;
}
// Overridden from mojo::ViewManagerDelegate:
- virtual void OnEmbed(mojo::View* root,
- mojo::InterfaceRequest<mojo::ServiceProvider> services,
- mojo::ServiceProviderPtr exposed_services) override {
+ void OnEmbed(mojo::View* root,
+ mojo::InterfaceRequest<mojo::ServiceProvider> services,
+ mojo::ServiceProviderPtr exposed_services) override {
bitmap_uploader_.reset(new mojo::BitmapUploader(root));
bitmap_uploader_->Init(shell_);
// BitmapUploader does not track view size changes, we would
@@ -82,8 +85,13 @@ class WMFlowEmbedded : public mojo::ApplicationDelegate,
embedder_->HelloWorld(base::Bind(&WMFlowEmbedded::HelloWorldAck,
base::Unretained(this)));
}
- virtual void OnViewManagerDisconnected(
- mojo::ViewManager* view_manager) override {}
+ void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override {}
+
+ // Overridden from mojo::InterfaceFactory<Embeddee>:
+ void Create(mojo::ApplicationConnection* app,
+ mojo::InterfaceRequest<Embeddee> request) override {
+ new EmbeddeeImpl(request.Pass());
+ }
void HelloWorldAck() {
printf("HelloWorld() ack'ed\n");
@@ -93,7 +101,6 @@ class WMFlowEmbedded : public mojo::ApplicationDelegate,
scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
EmbedderPtr embedder_;
mojo::ServiceProviderImpl embeddee_provider_impl_;
- mojo::InterfaceFactoryImpl<EmbeddeeImpl> embeddee_factory_;
scoped_ptr<mojo::BitmapUploader> bitmap_uploader_;
DISALLOW_COPY_AND_ASSIGN(WMFlowEmbedded);
« no previous file with comments | « examples/wm_flow/app/app.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698