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" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // show that the DemoTask threads are accessing the Integer in parallel. | 90 // show that the DemoTask threads are accessing the Integer in parallel. |
91 // The fact that only one digit appears in each column shows that things | 91 // The fact that only one digit appears in each column shows that things |
92 // are working correctly. | 92 // are working correctly. |
93 class IndirectServiceDemoAppDelegate : public ApplicationDelegate { | 93 class IndirectServiceDemoAppDelegate : public ApplicationDelegate { |
94 public: | 94 public: |
95 void Initialize(ApplicationImpl* app) override { | 95 void Initialize(ApplicationImpl* app) override { |
96 IntegerServicePtr indirect_service_delegate; | 96 IntegerServicePtr indirect_service_delegate; |
97 app->ConnectToService("mojo:indirect_integer_service", | 97 app->ConnectToService("mojo:indirect_integer_service", |
98 &indirect_integer_service_); | 98 &indirect_integer_service_); |
99 app->ConnectToService("mojo:integer_service", &indirect_service_delegate); | 99 app->ConnectToService("mojo:integer_service", &indirect_service_delegate); |
100 indirect_integer_service_->Set(indirect_service_delegate.Pass()); | 100 indirect_integer_service_->Set( |
| 101 indirect_service_delegate.PassInterfaceHandle()); |
101 | 102 |
102 for (unsigned i = 0; i < kTaskCount; i++) { | 103 for (unsigned i = 0; i < kTaskCount; i++) { |
103 IntegerServicePtr integer_service; | 104 IntegerServicePtr integer_service; |
104 indirect_integer_service_->Get(GetProxy(&integer_service)); | 105 indirect_integer_service_->Get(GetProxy(&integer_service)); |
105 DemoTaskFinishedCallback finished_callback = base::Bind( | 106 DemoTaskFinishedCallback finished_callback = base::Bind( |
106 &IndirectServiceDemoAppDelegate::FinishDemoTask, | 107 &IndirectServiceDemoAppDelegate::FinishDemoTask, |
107 base::Unretained(this), | 108 base::Unretained(this), |
108 base::Unretained(base::MessageLoop::current())); | 109 base::Unretained(base::MessageLoop::current())); |
109 // We're passing the integer_service_ proxy to another thread, so | 110 // We're passing the integer_service_ proxy to another thread, so |
110 // use its MessagePipe. | 111 // use its MessagePipe. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 149 |
149 | 150 |
150 } // namespace examples | 151 } // namespace examples |
151 } // namespace mojo | 152 } // namespace mojo |
152 | 153 |
153 MojoResult MojoMain(MojoHandle application_request) { | 154 MojoResult MojoMain(MojoHandle application_request) { |
154 mojo::ApplicationRunnerChromium runner( | 155 mojo::ApplicationRunnerChromium runner( |
155 new mojo::examples::IndirectServiceDemoAppDelegate); | 156 new mojo::examples::IndirectServiceDemoAppDelegate); |
156 return runner.Run(application_request); | 157 return runner.Run(application_request); |
157 } | 158 } |
OLD | NEW |