| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <cstdlib> | 5 #include <cstdlib> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "examples/indirect_service/indirect_service_demo.mojom.h" | 11 #include "examples/indirect_service/indirect_service_demo.mojom.h" |
| 12 #include "mojo/environment/scoped_chromium_init.h" |
| 12 #include "mojo/message_pump/message_pump_mojo.h" | 13 #include "mojo/message_pump/message_pump_mojo.h" |
| 13 #include "mojo/public/c/system/main.h" | 14 #include "mojo/public/c/system/main.h" |
| 14 #include "mojo/public/cpp/application/application_impl_base.h" | 15 #include "mojo/public/cpp/application/application_impl_base.h" |
| 15 #include "mojo/public/cpp/application/connect.h" | 16 #include "mojo/public/cpp/application/connect.h" |
| 16 #include "mojo/public/cpp/application/run_application.h" | 17 #include "mojo/public/cpp/application/run_application.h" |
| 17 | 18 |
| 18 namespace mojo { | 19 namespace mojo { |
| 19 namespace examples { | 20 namespace examples { |
| 20 | 21 |
| 21 class DemoTask; | 22 class DemoTask; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 133 } |
| 133 | 134 |
| 134 void DoFinishDemoTask(DemoTask* task, const std::vector<int32_t>& results) { | 135 void DoFinishDemoTask(DemoTask* task, const std::vector<int32_t>& results) { |
| 135 std::string display(kTaskCount * kTaskIterationCount, ' '); | 136 std::string display(kTaskCount * kTaskIterationCount, ' '); |
| 136 for (unsigned i = 0; i < results.size(); i++) | 137 for (unsigned i = 0; i < results.size(); i++) |
| 137 display[results[i]] = '0' + (results[i] % 10); | 138 display[results[i]] = '0' + (results[i] % 10); |
| 138 printf("DemoTask Thread [%s]\n", display.c_str()); | 139 printf("DemoTask Thread [%s]\n", display.c_str()); |
| 139 tasks_.erase(std::remove(tasks_.begin(), tasks_.end(), task), tasks_.end()); | 140 tasks_.erase(std::remove(tasks_.begin(), tasks_.end(), task), tasks_.end()); |
| 140 delete task; // Stop the DemoTask's thread etc. | 141 delete task; // Stop the DemoTask's thread etc. |
| 141 if (tasks_.empty()) | 142 if (tasks_.empty()) |
| 142 TerminateMainApplication(MOJO_RESULT_OK); | 143 TerminateApplication(MOJO_RESULT_OK); |
| 143 } | 144 } |
| 144 | 145 |
| 145 IndirectIntegerServicePtr indirect_integer_service_; | 146 IndirectIntegerServicePtr indirect_integer_service_; |
| 146 std::vector<DemoTask*> tasks_; | 147 std::vector<DemoTask*> tasks_; |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 } // namespace examples | 150 } // namespace examples |
| 150 } // namespace mojo | 151 } // namespace mojo |
| 151 | 152 |
| 152 MojoResult MojoMain(MojoHandle application_request) { | 153 MojoResult MojoMain(MojoHandle application_request) { |
| 154 mojo::ScopedChromiumInit init; |
| 153 mojo::examples::IndirectServiceDemoApp indirect_service_demo_app; | 155 mojo::examples::IndirectServiceDemoApp indirect_service_demo_app; |
| 154 return mojo::RunMainApplication(application_request, | 156 return mojo::RunApplication(application_request, &indirect_service_demo_app); |
| 155 &indirect_service_demo_app); | |
| 156 } | 157 } |
| OLD | NEW |