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

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: fix network_service_loader 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
« no previous file with comments | « mojo/examples/nesting_app/nesting_app.cc ('k') | mojo/examples/surfaces_app/child_app.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c9488e78d2cc849fe8876801906aedb31fb1b5ef..e1a5aed801ba01a5f19a95ad92a30f186988ed39 100644
--- a/mojo/examples/png_viewer/png_viewer.cc
+++ b/mojo/examples/png_viewer/png_viewer.cc
@@ -9,11 +9,13 @@
#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/interface_factory_with_context.h"
#include "mojo/services/public/cpp/view_manager/node.h"
#include "mojo/services/public/cpp/view_manager/node_observer.h"
#include "mojo/services/public/cpp/view_manager/types.h"
#include "mojo/services/public/cpp/view_manager/view.h"
#include "mojo/services/public/cpp/view_manager/view_manager.h"
+#include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
#include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
#include "skia/ext/platform_canvas.h"
@@ -31,8 +33,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:
@@ -48,8 +49,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:
@@ -111,14 +111,20 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> {
DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
};
-class PNGViewer : public ApplicationDelegate,
- public view_manager::ViewManagerDelegate,
- public view_manager::NodeObserver {
+class PNGViewer
+ : public ApplicationDelegate,
+ public view_manager::ViewManagerDelegate,
+ public view_manager::NodeObserver,
+ public InterfaceFactoryWithContext<NavigatorImpl, PNGViewer>,
+ public InterfaceFactoryWithContext<ZoomableMediaImpl, PNGViewer> {
public:
PNGViewer()
- : content_view_(NULL),
+ : InterfaceFactoryWithContext<NavigatorImpl, PNGViewer>(this),
+ InterfaceFactoryWithContext<ZoomableMediaImpl, PNGViewer>(this),
+ content_view_(NULL),
root_(NULL),
- zoom_percentage_(kDefaultZoomPercentage) {}
+ zoom_percentage_(kDefaultZoomPercentage),
+ view_manager_client_factory_(this) {}
virtual ~PNGViewer() {
if (root_)
root_->RemoveObserver(this);
@@ -160,9 +166,9 @@ class PNGViewer : public ApplicationDelegate,
// Overridden from ApplicationDelegate:
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
MOJO_OVERRIDE {
- connection->AddService<NavigatorImpl>(this);
- connection->AddService<ZoomableMediaImpl>(this);
- view_manager::ViewManager::ConfigureIncomingConnection(connection, this);
+ connection->AddService<navigation::Navigator>(this);
+ connection->AddService<ZoomableMedia>(this);
+ connection->AddService(&view_manager_client_factory_);
return true;
}
@@ -216,6 +222,7 @@ class PNGViewer : public ApplicationDelegate,
view_manager::Node* root_;
SkBitmap bitmap_;
uint16_t zoom_percentage_;
+ view_manager::ViewManagerClientFactory view_manager_client_factory_;
DISALLOW_COPY_AND_ASSIGN(PNGViewer);
};
« no previous file with comments | « mojo/examples/nesting_app/nesting_app.cc ('k') | mojo/examples/surfaces_app/child_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698