| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <ostream> | 6 #include <ostream> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "mojo/public/cpp/bindings/allocation_scope.h" | 9 #include "mojo/public/cpp/bindings/allocation_scope.h" |
| 10 #include "mojo/public/cpp/environment/environment.h" | 10 #include "mojo/public/cpp/environment/environment.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 if (i % 2 == 1) | 260 if (i % 2 == 1) |
| 261 std::cout << " "; | 261 std::cout << " "; |
| 262 if (i % 8 == 7) | 262 if (i % 8 == 7) |
| 263 std::cout << " "; | 263 std::cout << " "; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 class ServiceImpl : public Service { | 267 class ServiceImpl : public Service { |
| 268 public: | 268 public: |
| 269 ServiceImpl() : client_(NULL) { | |
| 270 } | |
| 271 | |
| 272 virtual void SetClient(ServiceClient* client) MOJO_OVERRIDE { | |
| 273 client_ = client; | |
| 274 } | |
| 275 | |
| 276 virtual void Frobinate(const Foo& foo, BazOptions baz, PortPtr port) | 269 virtual void Frobinate(const Foo& foo, BazOptions baz, PortPtr port) |
| 277 MOJO_OVERRIDE { | 270 MOJO_OVERRIDE { |
| 278 // Users code goes here to handle the incoming Frobinate message. | 271 // Users code goes here to handle the incoming Frobinate message. |
| 279 | 272 |
| 280 // We mainly check that we're given the expected arguments. | 273 // We mainly check that we're given the expected arguments. |
| 281 CheckFoo(foo); | 274 CheckFoo(foo); |
| 282 EXPECT_EQ(BAZ_EXTRA, baz); | 275 EXPECT_EQ(BAZ_EXTRA, baz); |
| 283 | 276 |
| 284 if (g_dump_message_as_text) { | 277 if (g_dump_message_as_text) { |
| 285 // Also dump the Foo structure and all of its members. | 278 // Also dump the Foo structure and all of its members. |
| 286 std::cout << "Frobinate:" << std::endl; | 279 std::cout << "Frobinate:" << std::endl; |
| 287 int depth = 1; | 280 int depth = 1; |
| 288 Print(depth, "foo", foo); | 281 Print(depth, "foo", foo); |
| 289 Print(depth, "baz", baz); | 282 Print(depth, "baz", baz); |
| 290 Print(depth, "port", port.get()); | 283 Print(depth, "port", port.get()); |
| 291 } | 284 } |
| 292 } | 285 } |
| 293 | |
| 294 private: | |
| 295 ServiceClient* client_; | |
| 296 }; | 286 }; |
| 297 | 287 |
| 298 class ServiceProxyImpl : public ServiceProxy { | 288 class ServiceProxyImpl : public ServiceProxy { |
| 299 public: | 289 public: |
| 300 explicit ServiceProxyImpl(mojo::MessageReceiver* receiver) | 290 explicit ServiceProxyImpl(mojo::MessageReceiver* receiver) |
| 301 : ServiceProxy(receiver) { | 291 : ServiceProxy(receiver) { |
| 302 } | 292 } |
| 303 | |
| 304 virtual void SetClient(ServiceClient* client) MOJO_OVERRIDE { | |
| 305 assert(false); | |
| 306 } | |
| 307 }; | 293 }; |
| 308 | 294 |
| 309 class SimpleMessageReceiver : public mojo::MessageReceiver { | 295 class SimpleMessageReceiver : public mojo::MessageReceiver { |
| 310 public: | 296 public: |
| 311 virtual bool Accept(mojo::Message* message) MOJO_OVERRIDE { | 297 virtual bool Accept(mojo::Message* message) MOJO_OVERRIDE { |
| 312 // Imagine some IPC happened here. | 298 // Imagine some IPC happened here. |
| 313 | 299 |
| 314 if (g_dump_message_as_hex) { | 300 if (g_dump_message_as_hex) { |
| 315 DumpHex(reinterpret_cast<const uint8_t*>(message->data()), | 301 DumpHex(reinterpret_cast<const uint8_t*>(message->data()), |
| 316 message->data_num_bytes()); | 302 message->data_num_bytes()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 EXPECT_DOUBLE_EQ(1E10, full.a17()); | 371 EXPECT_DOUBLE_EQ(1E10, full.a17()); |
| 386 EXPECT_DOUBLE_EQ(-1.2E+20, full.a18()); | 372 EXPECT_DOUBLE_EQ(-1.2E+20, full.a18()); |
| 387 EXPECT_DOUBLE_EQ(1.23E-20, full.a19()); | 373 EXPECT_DOUBLE_EQ(1.23E-20, full.a19()); |
| 388 EXPECT_TRUE(full.a20().is_null()); | 374 EXPECT_TRUE(full.a20().is_null()); |
| 389 EXPECT_TRUE(full.a21().is_null()); | 375 EXPECT_TRUE(full.a21().is_null()); |
| 390 EXPECT_TRUE(full.a22().is_null()); | 376 EXPECT_TRUE(full.a22().is_null()); |
| 391 } | 377 } |
| 392 | 378 |
| 393 } // namespace | 379 } // namespace |
| 394 } // namespace sample | 380 } // namespace sample |
| OLD | NEW |