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

Unified Diff: mojo/examples/png_viewer/png_viewer.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: specify ownership in the Bind call Created 6 years, 5 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/examples/png_viewer/png_viewer.cc
diff --git a/mojo/examples/png_viewer/png_viewer.cc b/mojo/examples/png_viewer/png_viewer.cc
index a6f87417bad4f50a075919dd017923d6c46363a3..9262b908aed7abf94646dc40edb2a78fb4bfa388 100644
--- a/mojo/examples/png_viewer/png_viewer.cc
+++ b/mojo/examples/png_viewer/png_viewer.cc
@@ -9,6 +9,7 @@
#include "mojo/examples/media_viewer/media_viewer.mojom.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/context_interface_provider.h"
#include "mojo/services/public/cpp/view_manager/node.h"
#include "mojo/services/public/cpp/view_manager/types.h"
#include "mojo/services/public/cpp/view_manager/view.h"
@@ -30,8 +31,7 @@ class PNGViewer;
class ZoomableMediaImpl : public InterfaceImpl<ZoomableMedia> {
public:
- ZoomableMediaImpl(ApplicationConnection* connection,
- PNGViewer* viewer) : viewer_(viewer) {}
+ explicit ZoomableMediaImpl(PNGViewer* viewer) : viewer_(viewer) {}
virtual ~ZoomableMediaImpl() {}
private:
@@ -47,8 +47,7 @@ class ZoomableMediaImpl : public InterfaceImpl<ZoomableMedia> {
class NavigatorImpl : public InterfaceImpl<navigation::Navigator> {
public:
- NavigatorImpl(ApplicationConnection* connection,
- PNGViewer* viewer) : viewer_(viewer) {}
+ explicit NavigatorImpl(PNGViewer* viewer) : viewer_(viewer) {}
virtual ~NavigatorImpl() {}
private:
@@ -110,10 +109,17 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> {
DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
};
-class PNGViewer : public ApplicationDelegate,
- public view_manager::ViewManagerDelegate {
+class PNGViewer
+ : public ApplicationDelegate,
+ public view_manager::ViewManagerDelegate,
+ public ContextInterfaceProvider<NavigatorImpl, PNGViewer>,
+ public ContextInterfaceProvider<ZoomableMediaImpl, PNGViewer> {
public:
- PNGViewer() : content_view_(NULL), zoom_percentage_(kDefaultZoomPercentage) {}
+ PNGViewer()
+ : ContextInterfaceProvider<NavigatorImpl, PNGViewer>(this),
+ ContextInterfaceProvider<ZoomableMediaImpl, PNGViewer>(this),
+ content_view_(NULL),
+ zoom_percentage_(kDefaultZoomPercentage) {}
virtual ~PNGViewer() {}
void UpdateView(view_manager::Id node_id, const SkBitmap& bitmap) {
@@ -152,8 +158,8 @@ class PNGViewer : public ApplicationDelegate,
// Overridden from ApplicationDelegate:
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
MOJO_OVERRIDE {
- connection->AddService<NavigatorImpl>(this);
- connection->AddService<ZoomableMediaImpl>(this);
+ connection->AddServiceProvider<navigation::Navigator>(this);
+ connection->AddServiceProvider<ZoomableMedia>(this);
view_manager::ViewManager::ConfigureIncomingConnection(connection, this);
return true;
}
« no previous file with comments | « no previous file | mojo/examples/surfaces_app/child_app.cc » ('j') | mojo/public/cpp/application/context_interface_provider.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698