OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/message_pump/message_pump_mojo.h" | 9 #include "mojo/message_pump/message_pump_mojo.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class PingServiceImpl : public test::PingService { | 26 class PingServiceImpl : public test::PingService { |
27 public: | 27 public: |
28 explicit PingServiceImpl() {} | 28 explicit PingServiceImpl() {} |
29 ~PingServiceImpl() override {} | 29 ~PingServiceImpl() override {} |
30 | 30 |
31 // |PingService| methods: | 31 // |PingService| methods: |
32 void Ping(const Callback<void()>& callback) override; | 32 void Ping(const Callback<void()>& callback) override; |
33 | 33 |
34 private: | 34 private: |
35 MOJO_DISALLOW_COPY_AND_ASSIGN(PingServiceImpl); | 35 DISALLOW_COPY_AND_ASSIGN(PingServiceImpl); |
36 }; | 36 }; |
37 | 37 |
38 void PingServiceImpl::Ping(const Callback<void()>& callback) { | 38 void PingServiceImpl::Ping(const Callback<void()>& callback) { |
39 callback.Run(); | 39 callback.Run(); |
40 } | 40 } |
41 | 41 |
42 class PingPongTest { | 42 class PingPongTest { |
43 public: | 43 public: |
44 explicit PingPongTest(test::PingServicePtr service); | 44 explicit PingPongTest(test::PingServicePtr service); |
45 | 45 |
46 void Run(unsigned int iterations); | 46 void Run(unsigned int iterations); |
47 | 47 |
48 private: | 48 private: |
49 void OnPingDone(); | 49 void OnPingDone(); |
50 | 50 |
51 test::PingServicePtr service_; | 51 test::PingServicePtr service_; |
52 unsigned int iterations_to_run_; | 52 unsigned int iterations_to_run_; |
53 unsigned int current_iterations_; | 53 unsigned int current_iterations_; |
54 | 54 |
55 MOJO_DISALLOW_COPY_AND_ASSIGN(PingPongTest); | 55 DISALLOW_COPY_AND_ASSIGN(PingPongTest); |
56 }; | 56 }; |
57 | 57 |
58 PingPongTest::PingPongTest(test::PingServicePtr service) | 58 PingPongTest::PingPongTest(test::PingServicePtr service) |
59 : service_(std::move(service)) {} | 59 : service_(std::move(service)) {} |
60 | 60 |
61 void PingPongTest::Run(unsigned int iterations) { | 61 void PingPongTest::Run(unsigned int iterations) { |
62 iterations_to_run_ = iterations; | 62 iterations_to_run_ = iterations; |
63 current_iterations_ = 0; | 63 current_iterations_ = 0; |
64 | 64 |
65 service_->Ping([this]() { OnPingDone(); }); | 65 service_->Ping([this]() { OnPingDone(); }); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 "InProcessPingPong", "1000_Inactive", | 124 "InProcessPingPong", "1000_Inactive", |
125 kIterations / MojoTicksToSeconds(end_time - start_time), | 125 kIterations / MojoTicksToSeconds(end_time - start_time), |
126 "pings/second"); | 126 "pings/second"); |
127 | 127 |
128 delete[] inactive_services; | 128 delete[] inactive_services; |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 } // namespace | 132 } // namespace |
133 } // namespace mojo | 133 } // namespace mojo |
OLD | NEW |