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

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

Issue 2515873003: Mojo C++ Bindings: Introduce mojo::SupportsStrongBinding
Patch Set: . Created 4 years, 1 month 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 <stdint.h> 6 #include <stdint.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 void set_connection_error_handler(const base::Closure& handler) { 57 void set_connection_error_handler(const base::Closure& handler) {
58 binding_.set_connection_error_handler(handler); 58 binding_.set_connection_error_handler(handler);
59 } 59 }
60 60
61 private: 61 private:
62 AssociatedBinding<IntegerSender> binding_; 62 AssociatedBinding<IntegerSender> binding_;
63 base::Callback<void(int32_t)> notify_send_method_called_; 63 base::Callback<void(int32_t)> notify_send_method_called_;
64 }; 64 };
65 65
66 class IntegerSenderConnectionImpl : public IntegerSenderConnection { 66 class IntegerSenderConnectionImpl
67 : public SupportsStrongBinding<IntegerSenderConnection> {
67 public: 68 public:
68 explicit IntegerSenderConnectionImpl( 69 explicit IntegerSenderConnectionImpl(
69 InterfaceRequest<IntegerSenderConnection> request) 70 InterfaceRequest<IntegerSenderConnection> request)
70 : binding_(this, std::move(request)) {} 71 : binding_(this, std::move(request)) {}
71 72
72 ~IntegerSenderConnectionImpl() override {} 73 ~IntegerSenderConnectionImpl() override {}
73 74
74 void GetSender(AssociatedInterfaceRequest<IntegerSender> sender) override { 75 void GetSender(AssociatedInterfaceRequest<IntegerSender> sender) override {
75 IntegerSenderImpl* sender_impl = new IntegerSenderImpl(std::move(sender)); 76 IntegerSenderImpl* sender_impl = new IntegerSenderImpl(std::move(sender));
76 sender_impl->set_connection_error_handler( 77 sender_impl->set_connection_error_handler(
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 thread_safe_sender); 1047 thread_safe_sender);
1047 other_thread.message_loop()->task_runner()->PostTask(FROM_HERE, run_method); 1048 other_thread.message_loop()->task_runner()->PostTask(FROM_HERE, run_method);
1048 1049
1049 // Block until the method callback is called on the background thread. 1050 // Block until the method callback is called on the background thread.
1050 run_loop.Run(); 1051 run_loop.Run();
1051 } 1052 }
1052 1053
1053 } // namespace 1054 } // namespace
1054 } // namespace test 1055 } // namespace test
1055 } // namespace mojo 1056 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698