| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 | 51 |
| 52 class PingPongTest { | 52 class PingPongTest { |
| 53 public: | 53 public: |
| 54 explicit PingPongTest(test::EchoServicePtr service); | 54 explicit PingPongTest(test::EchoServicePtr service); |
| 55 | 55 |
| 56 void RunTest(int iterations, int batch_size, int message_size); | 56 void RunTest(int iterations, int batch_size, int message_size); |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 void DoPing(); | 59 void DoPing(); |
| 60 void OnPingDone(const mojo::String& reply); | 60 void OnPingDone(mojo::String reply); |
| 61 | 61 |
| 62 test::EchoServicePtr service_; | 62 test::EchoServicePtr service_; |
| 63 const base::Callback<void(const mojo::String&)> ping_done_callback_; | 63 const base::Callback<void(mojo::String)> ping_done_callback_; |
| 64 | 64 |
| 65 int iterations_; | 65 int iterations_; |
| 66 int batch_size_; | 66 int batch_size_; |
| 67 std::string message_; | 67 std::string message_; |
| 68 | 68 |
| 69 int current_iterations_; | 69 int current_iterations_; |
| 70 int calls_outstanding_; | 70 int calls_outstanding_; |
| 71 | 71 |
| 72 base::Closure quit_closure_; | 72 base::Closure quit_closure_; |
| 73 }; | 73 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 quit_closure_.Run(); | 99 quit_closure_.Run(); |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 | 102 |
| 103 calls_outstanding_ = batch_size_; | 103 calls_outstanding_ = batch_size_; |
| 104 for (int i = 0; i < batch_size_; i++) { | 104 for (int i = 0; i < batch_size_; i++) { |
| 105 service_->Echo(message_, ping_done_callback_); | 105 service_->Echo(message_, ping_done_callback_); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 void PingPongTest::OnPingDone(const mojo::String& reply) { | 109 void PingPongTest::OnPingDone(mojo::String reply) { |
| 110 DCHECK_GT(calls_outstanding_, 0); | 110 DCHECK_GT(calls_outstanding_, 0); |
| 111 calls_outstanding_--; | 111 calls_outstanding_--; |
| 112 | 112 |
| 113 if (!calls_outstanding_) | 113 if (!calls_outstanding_) |
| 114 DoPing(); | 114 DoPing(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 class MojoE2EPerftest : public edk::test::MojoTestBase { | 117 class MojoE2EPerftest : public edk::test::MojoTestBase { |
| 118 public: | 118 public: |
| 119 void RunTestOnTaskRunner(base::TaskRunner* runner, | 119 void RunTestOnTaskRunner(base::TaskRunner* runner, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 MojoHandle client_mp, service_mp; | 197 MojoHandle client_mp, service_mp; |
| 198 CreateMessagePipe(&client_mp, &service_mp); | 198 CreateMessagePipe(&client_mp, &service_mp); |
| 199 WriteMessageWithHandles(mp, "hello", &service_mp, 1); | 199 WriteMessageWithHandles(mp, "hello", &service_mp, 1); |
| 200 RunTestOnTaskRunner(edk::test::GetIoTaskRunner(), client_mp, | 200 RunTestOnTaskRunner(edk::test::GetIoTaskRunner(), client_mp, |
| 201 "MultiProcessEchoIoThread"); | 201 "MultiProcessEchoIoThread"); |
| 202 END_CHILD() | 202 END_CHILD() |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| 206 } // namespace mojo | 206 } // namespace mojo |
| OLD | NEW |