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

Unified Diff: mojo/services/test_service/test_service_application.cc

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 9 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/services/test_service/test_service_application.cc
diff --git a/mojo/services/test_service/test_service_application.cc b/mojo/services/test_service/test_service_application.cc
new file mode 100644
index 0000000000000000000000000000000000000000..70a2824e993602f680016864da4a8387fc22f143
--- /dev/null
+++ b/mojo/services/test_service/test_service_application.cc
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/services/test_service/test_service_application.h"
+
+#include <assert.h>
+
+#include "mojo/public/c/system/main.h"
+#include "mojo/public/cpp/application/application_connection.h"
+#include "mojo/public/cpp/application/application_runner.h"
+#include "mojo/public/cpp/utility/run_loop.h"
+#include "mojo/services/test_service/test_service_impl.h"
+#include "mojo/services/test_service/test_time_service_impl.h"
+
+namespace mojo {
+namespace test {
+
+TestServiceApplication::TestServiceApplication()
+ : ref_count_(0), app_impl_(nullptr) {
+}
+
+TestServiceApplication::~TestServiceApplication() {
+}
+
+void TestServiceApplication::Initialize(ApplicationImpl* app) {
+ app_impl_ = app;
+}
+
+bool TestServiceApplication::ConfigureIncomingConnection(
+ ApplicationConnection* connection) {
+ connection->AddService<TestService>(this);
+ connection->AddService<TestTimeService>(this);
+ return true;
+}
+
+void TestServiceApplication::Create(ApplicationConnection* connection,
+ InterfaceRequest<TestService> request) {
+ new TestServiceImpl(app_impl_, this, request.Pass());
+ AddRef();
+}
+
+void TestServiceApplication::Create(ApplicationConnection* connection,
+ InterfaceRequest<TestTimeService> request) {
+ new TestTimeServiceImpl(app_impl_, request.Pass());
+}
+
+void TestServiceApplication::AddRef() {
+ assert(ref_count_ >= 0);
+ ref_count_++;
+}
+
+void TestServiceApplication::ReleaseRef() {
+ assert(ref_count_ > 0);
+ ref_count_--;
+ if (ref_count_ <= 0)
+ RunLoop::current()->Quit();
+}
+
+} // namespace test
+} // namespace mojo
+
+MojoResult MojoMain(MojoHandle shell_handle) {
+ mojo::ApplicationRunner runner(new mojo::test::TestServiceApplication);
+ return runner.Run(shell_handle);
+}
« no previous file with comments | « mojo/services/test_service/test_service_application.h ('k') | mojo/services/test_service/test_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698