OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/public/cpp/bindings/error_handler.h" | 5 #include "mojo/public/cpp/bindings/error_handler.h" |
6 #include "mojo/public/cpp/environment/environment.h" | 6 #include "mojo/public/cpp/environment/environment.h" |
7 #include "mojo/public/cpp/utility/run_loop.h" | 7 #include "mojo/public/cpp/utility/run_loop.h" |
8 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h" |
9 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" | 9 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 MathCalculatorImpl() | 35 MathCalculatorImpl() |
36 : total_(0.0), | 36 : total_(0.0), |
37 got_connection_(false) { | 37 got_connection_(false) { |
38 } | 38 } |
39 | 39 |
40 virtual void OnConnectionEstablished() MOJO_OVERRIDE { | 40 virtual void OnConnectionEstablished() MOJO_OVERRIDE { |
41 got_connection_ = true; | 41 got_connection_ = true; |
42 } | 42 } |
43 | 43 |
44 virtual void OnConnectionError() MOJO_OVERRIDE { | |
45 delete this; | |
46 } | |
47 | |
48 virtual void Clear() MOJO_OVERRIDE { | 44 virtual void Clear() MOJO_OVERRIDE { |
49 client()->Output(total_); | 45 client()->Output(total_); |
50 } | 46 } |
51 | 47 |
52 virtual void Add(double value) MOJO_OVERRIDE { | 48 virtual void Add(double value) MOJO_OVERRIDE { |
53 total_ += value; | 49 total_ += value; |
54 client()->Output(total_); | 50 client()->Output(total_); |
55 } | 51 } |
56 | 52 |
57 virtual void Multiply(double value) MOJO_OVERRIDE { | 53 virtual void Multiply(double value) MOJO_OVERRIDE { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 public: | 153 public: |
158 virtual ~ReentrantServiceImpl() {} | 154 virtual ~ReentrantServiceImpl() {} |
159 | 155 |
160 ReentrantServiceImpl() | 156 ReentrantServiceImpl() |
161 : got_connection_(false), call_depth_(0), max_call_depth_(0) {} | 157 : got_connection_(false), call_depth_(0), max_call_depth_(0) {} |
162 | 158 |
163 virtual void OnConnectionEstablished() MOJO_OVERRIDE { | 159 virtual void OnConnectionEstablished() MOJO_OVERRIDE { |
164 got_connection_ = true; | 160 got_connection_ = true; |
165 } | 161 } |
166 | 162 |
167 virtual void OnConnectionError() MOJO_OVERRIDE { | |
168 delete this; | |
169 } | |
170 | |
171 bool got_connection() const { | 163 bool got_connection() const { |
172 return got_connection_; | 164 return got_connection_; |
173 } | 165 } |
174 | 166 |
175 int max_call_depth() { return max_call_depth_; } | 167 int max_call_depth() { return max_call_depth_; } |
176 | 168 |
177 virtual void Frobinate(sample::FooPtr foo, | 169 virtual void Frobinate(sample::FooPtr foo, |
178 sample::Service::BazOptions baz, | 170 sample::Service::BazOptions baz, |
179 sample::PortPtr port) MOJO_OVERRIDE { | 171 sample::PortPtr port) MOJO_OVERRIDE { |
180 max_call_depth_ = std::max(++call_depth_, max_call_depth_); | 172 max_call_depth_ = std::max(++call_depth_, max_call_depth_); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 sample::PortPtr()); | 386 sample::PortPtr()); |
395 | 387 |
396 PumpMessages(); | 388 PumpMessages(); |
397 | 389 |
398 EXPECT_EQ(2, impl->max_call_depth()); | 390 EXPECT_EQ(2, impl->max_call_depth()); |
399 } | 391 } |
400 | 392 |
401 } // namespace | 393 } // namespace |
402 } // namespace test | 394 } // namespace test |
403 } // namespace mojo | 395 } // namespace mojo |
OLD | NEW |