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 <stdint.h> | 5 #include <stdint.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 "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 base::Closure closure_; | 53 base::Closure closure_; |
54 }; | 54 }; |
55 int ImportedInterfaceImpl::do_something_count_ = 0; | 55 int ImportedInterfaceImpl::do_something_count_ = 0; |
56 | 56 |
57 class SampleNamedObjectImpl : public sample::NamedObject { | 57 class SampleNamedObjectImpl : public sample::NamedObject { |
58 public: | 58 public: |
59 explicit SampleNamedObjectImpl(InterfaceRequest<sample::NamedObject> request) | 59 explicit SampleNamedObjectImpl(InterfaceRequest<sample::NamedObject> request) |
60 : binding_(this, std::move(request)) {} | 60 : binding_(this, std::move(request)) {} |
61 void SetName(const mojo::String& name) override { name_ = name; } | 61 void SetName(const mojo::String& name) override { name_ = name; } |
62 | 62 |
63 void GetName(const GetNameCallback& callback) override { | 63 void GetName(const mojo::Callback<void(mojo::String)>& callback) override { |
64 callback.Run(name_); | 64 callback.Run(name_); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 std::string name_; | 68 std::string name_; |
69 StrongBinding<sample::NamedObject> binding_; | 69 StrongBinding<sample::NamedObject> binding_; |
70 }; | 70 }; |
71 | 71 |
72 class SampleFactoryImpl : public sample::Factory { | 72 class SampleFactoryImpl : public sample::Factory { |
73 public: | 73 public: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 InterfaceRequest<sample::NamedObject> object_request) override { | 134 InterfaceRequest<sample::NamedObject> object_request) override { |
135 EXPECT_TRUE(object_request.is_pending()); | 135 EXPECT_TRUE(object_request.is_pending()); |
136 new SampleNamedObjectImpl(std::move(object_request)); | 136 new SampleNamedObjectImpl(std::move(object_request)); |
137 } | 137 } |
138 | 138 |
139 // These aren't called or implemented, but exist here to test that the | 139 // These aren't called or implemented, but exist here to test that the |
140 // methods are generated with the correct argument types for imported | 140 // methods are generated with the correct argument types for imported |
141 // interfaces. | 141 // interfaces. |
142 void RequestImportedInterface( | 142 void RequestImportedInterface( |
143 InterfaceRequest<imported::ImportedInterface> imported, | 143 InterfaceRequest<imported::ImportedInterface> imported, |
144 const RequestImportedInterfaceCallback& callback) override {} | 144 const mojo::Callback<void(InterfaceRequest<imported::ImportedInterface>)>& |
| 145 callback) override {} |
145 void TakeImportedInterface( | 146 void TakeImportedInterface( |
146 imported::ImportedInterfacePtr imported, | 147 imported::ImportedInterfacePtr imported, |
147 const TakeImportedInterfaceCallback& callback) override {} | 148 const mojo::Callback<void(imported::ImportedInterfacePtr)>& callback) |
| 149 override {} |
148 | 150 |
149 private: | 151 private: |
150 ScopedMessagePipeHandle pipe1_; | 152 ScopedMessagePipeHandle pipe1_; |
151 Binding<sample::Factory> binding_; | 153 Binding<sample::Factory> binding_; |
152 }; | 154 }; |
153 | 155 |
154 class HandlePassingTest : public testing::Test { | 156 class HandlePassingTest : public testing::Test { |
155 public: | 157 public: |
156 HandlePassingTest() {} | 158 HandlePassingTest() {} |
157 | 159 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 run_loop.Run(); | 362 run_loop.Run(); |
361 run_loop2.Run(); | 363 run_loop2.Run(); |
362 | 364 |
363 EXPECT_EQ(std::string("object1"), name1); | 365 EXPECT_EQ(std::string("object1"), name1); |
364 EXPECT_EQ(std::string("object2"), name2); | 366 EXPECT_EQ(std::string("object2"), name2); |
365 } | 367 } |
366 | 368 |
367 } // namespace | 369 } // namespace |
368 } // namespace test | 370 } // namespace test |
369 } // namespace mojo | 371 } // namespace mojo |
OLD | NEW |