Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: mojo/public/cpp/bindings/tests/bindings_perftest.cc

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bind.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "mojo/public/cpp/bindings/binding.h" 11 #include "mojo/public/cpp/bindings/binding.h"
11 #include "mojo/public/cpp/test_support/test_support.h" 12 #include "mojo/public/cpp/test_support/test_support.h"
12 #include "mojo/public/cpp/test_support/test_utils.h" 13 #include "mojo/public/cpp/test_support/test_utils.h"
13 #include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h" 14 #include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace { 18 namespace {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 59
59 PingPongTest::PingPongTest(test::PingServicePtr service) 60 PingPongTest::PingPongTest(test::PingServicePtr service)
60 : service_(std::move(service)) {} 61 : service_(std::move(service)) {}
61 62
62 void PingPongTest::Run(unsigned int iterations) { 63 void PingPongTest::Run(unsigned int iterations) {
63 iterations_to_run_ = iterations; 64 iterations_to_run_ = iterations;
64 current_iterations_ = 0; 65 current_iterations_ = 0;
65 66
66 base::RunLoop run_loop; 67 base::RunLoop run_loop;
67 quit_closure_ = run_loop.QuitClosure(); 68 quit_closure_ = run_loop.QuitClosure();
68 service_->Ping([this]() { OnPingDone(); }); 69 service_->Ping(base::Bind(&PingPongTest::OnPingDone, base::Unretained(this)));
69 run_loop.Run(); 70 run_loop.Run();
70 } 71 }
71 72
72 void PingPongTest::OnPingDone() { 73 void PingPongTest::OnPingDone() {
73 current_iterations_++; 74 current_iterations_++;
74 if (current_iterations_ >= iterations_to_run_) { 75 if (current_iterations_ >= iterations_to_run_) {
75 quit_closure_.Run(); 76 quit_closure_.Run();
76 return; 77 return;
77 } 78 }
78 79
79 service_->Ping([this]() { OnPingDone(); }); 80 service_->Ping(base::Bind(&PingPongTest::OnPingDone, base::Unretained(this)));
80 } 81 }
81 82
82 struct BoundPingService { 83 struct BoundPingService {
83 BoundPingService() : binding(&impl) { 84 BoundPingService() : binding(&impl) {
84 binding.Bind(GetProxy(&service)); 85 binding.Bind(GetProxy(&service));
85 } 86 }
86 87
87 PingServiceImpl impl; 88 PingServiceImpl impl;
88 test::PingServicePtr service; 89 test::PingServicePtr service;
89 Binding<test::PingService> binding; 90 Binding<test::PingService> binding;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 "InProcessPingPong", "1000_Inactive", 128 "InProcessPingPong", "1000_Inactive",
128 kIterations / MojoTicksToSeconds(end_time - start_time), 129 kIterations / MojoTicksToSeconds(end_time - start_time),
129 "pings/second"); 130 "pings/second");
130 131
131 delete[] inactive_services; 132 delete[] inactive_services;
132 } 133 }
133 } 134 }
134 135
135 } // namespace 136 } // namespace
136 } // namespace mojo 137 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/binding_unittest.cc ('k') | mojo/public/cpp/bindings/tests/callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698