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

Unified Diff: examples/indirect_service/integer_service.cc

Issue 733563002: Mojo Example that demos the difference between providing and requesting an interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Manage IntegerServicePtr and DemoTask lifetimes. Fixed RunLoop::RemoveFirstInvalidHandle() Created 6 years, 1 month 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: examples/indirect_service/integer_service.cc
diff --git a/examples/echo/echo_service.cc b/examples/indirect_service/integer_service.cc
similarity index 57%
copy from examples/echo/echo_service.cc
copy to examples/indirect_service/integer_service.cc
index c96f106a688b0d91a9f8f85c3b349ca39c48ffa6..f590438cec6a9c420aee9ac354f53faf55fc7bd1 100644
--- a/examples/echo/echo_service.cc
+++ b/examples/indirect_service/integer_service.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "examples/echo/echo_service.mojom.h"
+#include "examples/indirect_service/indirect_service_demo.mojom.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
@@ -12,30 +12,36 @@
namespace mojo {
namespace examples {
-class EchoServiceImpl : public InterfaceImpl<EchoService> {
+class IntegerServiceImpl : public InterfaceImpl<IntegerService> {
public:
- virtual void EchoString(const String& value,
- const Callback<void(String)>& callback) override {
- callback.Run(value);
+ IntegerServiceImpl() : value_(0) {}
+ virtual ~IntegerServiceImpl() {}
yzshen1 2014/11/20 22:01:44 nit: use "override" instead of "virtual" whenever
hansmuller 2014/11/20 22:35:38 Sorry, I thought I had cleaned all of these up.
+
+ virtual void Increment(const Callback<void(int32_t)>& callback) override {
+ callback.Run(value_++);
}
+
+ private:
+ int32_t value_;
};
-class EchoServiceDelegate : public ApplicationDelegate {
+class IntegerServiceAppDelegate : public ApplicationDelegate {
public:
virtual bool ConfigureIncomingConnection(
ApplicationConnection* connection) override {
- connection->AddService(&echo_service_factory_);
+ connection->AddService(&integer_service_factory_);
return true;
}
private:
- InterfaceFactoryImpl<EchoServiceImpl> echo_service_factory_;
+ InterfaceFactoryImpl<IntegerServiceImpl> integer_service_factory_;
};
} // namespace examples
} // namespace mojo
MojoResult MojoMain(MojoHandle shell_handle) {
- mojo::ApplicationRunner runner(new mojo::examples::EchoServiceDelegate);
+ mojo::ApplicationRunner runner(new mojo::examples::IntegerServiceAppDelegate);
return runner.Run(shell_handle);
}
+

Powered by Google App Engine
This is Rietveld 408576698