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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // N = |kTaskCount * kTaskIterationCount| times. Each DemoTask's results | 87 // N = |kTaskCount * kTaskIterationCount| times. Each DemoTask's results |
88 // are displayed in array of length N. Digits appear in positions that | 88 // are displayed in array of length N. Digits appear in positions that |
89 // correspond to the results obtained by the DemoTask thread. The results | 89 // correspond to the results obtained by the DemoTask thread. The results |
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->ConnectToServiceDeprecated("mojo:indirect_integer_service", |
98 &indirect_integer_service_); | 98 &indirect_integer_service_); |
99 app->ConnectToService("mojo:integer_service", &indirect_service_delegate); | 99 app->ConnectToServiceDeprecated("mojo:integer_service", |
| 100 &indirect_service_delegate); |
100 indirect_integer_service_->Set( | 101 indirect_integer_service_->Set( |
101 indirect_service_delegate.PassInterfaceHandle()); | 102 indirect_service_delegate.PassInterfaceHandle()); |
102 | 103 |
103 for (unsigned i = 0; i < kTaskCount; i++) { | 104 for (unsigned i = 0; i < kTaskCount; i++) { |
104 IntegerServicePtr integer_service; | 105 IntegerServicePtr integer_service; |
105 indirect_integer_service_->Get(GetProxy(&integer_service)); | 106 indirect_integer_service_->Get(GetProxy(&integer_service)); |
106 DemoTaskFinishedCallback finished_callback = base::Bind( | 107 DemoTaskFinishedCallback finished_callback = base::Bind( |
107 &IndirectServiceDemoAppDelegate::FinishDemoTask, | 108 &IndirectServiceDemoAppDelegate::FinishDemoTask, |
108 base::Unretained(this), | 109 base::Unretained(this), |
109 base::Unretained(base::MessageLoop::current())); | 110 base::Unretained(base::MessageLoop::current())); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 150 |
150 | 151 |
151 } // namespace examples | 152 } // namespace examples |
152 } // namespace mojo | 153 } // namespace mojo |
153 | 154 |
154 MojoResult MojoMain(MojoHandle application_request) { | 155 MojoResult MojoMain(MojoHandle application_request) { |
155 mojo::ApplicationRunnerChromium runner( | 156 mojo::ApplicationRunnerChromium runner( |
156 new mojo::examples::IndirectServiceDemoAppDelegate); | 157 new mojo::examples::IndirectServiceDemoAppDelegate); |
157 return runner.Run(application_request); | 158 return runner.Run(application_request); |
158 } | 159 } |
OLD | NEW |