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

Side by Side Diff: mojo/public/cpp/bindings/interface_endpoint_client.h

Issue 2633053002: Remove the MessageLoop::DestructionObserver from mojo bindings. (Closed)
Patch Set: rebase Created 3 years, 10 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/message_loop/message_loop.h"
20 #include "base/optional.h" 19 #include "base/optional.h"
21 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
22 #include "base/threading/thread_checker.h" 21 #include "base/threading/thread_checker.h"
23 #include "mojo/public/cpp/bindings/bindings_export.h" 22 #include "mojo/public/cpp/bindings/bindings_export.h"
24 #include "mojo/public/cpp/bindings/connection_error_callback.h" 23 #include "mojo/public/cpp/bindings/connection_error_callback.h"
25 #include "mojo/public/cpp/bindings/disconnect_reason.h" 24 #include "mojo/public/cpp/bindings/disconnect_reason.h"
26 #include "mojo/public/cpp/bindings/filter_chain.h" 25 #include "mojo/public/cpp/bindings/filter_chain.h"
27 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" 26 #include "mojo/public/cpp/bindings/lib/control_message_handler.h"
28 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" 27 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
29 #include "mojo/public/cpp/bindings/message.h" 28 #include "mojo/public/cpp/bindings/message.h"
30 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 29 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
31 30
32 namespace mojo { 31 namespace mojo {
33 32
34 class AssociatedGroup; 33 class AssociatedGroup;
35 class AssociatedGroupController; 34 class AssociatedGroupController;
36 class InterfaceEndpointController; 35 class InterfaceEndpointController;
37 36
38 // InterfaceEndpointClient handles message sending and receiving of an interface 37 // InterfaceEndpointClient handles message sending and receiving of an interface
39 // endpoint, either the implementation side or the client side. 38 // endpoint, either the implementation side or the client side.
40 // It should only be accessed and destructed on the creating thread. 39 // It should only be accessed and destructed on the creating thread.
41 class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient 40 class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
42 : NON_EXPORTED_BASE(public MessageReceiverWithResponder), 41 : NON_EXPORTED_BASE(public MessageReceiverWithResponder) {
43 public base::MessageLoop::DestructionObserver {
44 public: 42 public:
45 // |receiver| is okay to be null. If it is not null, it must outlive this 43 // |receiver| is okay to be null. If it is not null, it must outlive this
46 // object. 44 // object.
47 InterfaceEndpointClient(ScopedInterfaceEndpointHandle handle, 45 InterfaceEndpointClient(ScopedInterfaceEndpointHandle handle,
48 MessageReceiverWithResponderStatus* receiver, 46 MessageReceiverWithResponderStatus* receiver,
49 std::unique_ptr<MessageReceiver> payload_validator, 47 std::unique_ptr<MessageReceiver> payload_validator,
50 bool expect_sync_requests, 48 bool expect_sync_requests,
51 scoped_refptr<base::SingleThreadTaskRunner> runner, 49 scoped_refptr<base::SingleThreadTaskRunner> runner,
52 uint32_t interface_version); 50 uint32_t interface_version);
53 ~InterfaceEndpointClient() override; 51 ~InterfaceEndpointClient() override;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // MessageReceiver implementation: 144 // MessageReceiver implementation:
147 bool Accept(Message* message) override; 145 bool Accept(Message* message) override;
148 146
149 private: 147 private:
150 InterfaceEndpointClient* const owner_; 148 InterfaceEndpointClient* const owner_;
151 149
152 DISALLOW_COPY_AND_ASSIGN(HandleIncomingMessageThunk); 150 DISALLOW_COPY_AND_ASSIGN(HandleIncomingMessageThunk);
153 }; 151 };
154 152
155 bool HandleValidatedMessage(Message* message); 153 bool HandleValidatedMessage(Message* message);
156 void StopObservingIfNecessary();
157
158 // base::MessageLoop::DestructionObserver:
159 void WillDestroyCurrentMessageLoop() override;
160 154
161 ScopedInterfaceEndpointHandle handle_; 155 ScopedInterfaceEndpointHandle handle_;
162 std::unique_ptr<AssociatedGroup> associated_group_; 156 std::unique_ptr<AssociatedGroup> associated_group_;
163 InterfaceEndpointController* controller_; 157 InterfaceEndpointController* controller_;
164 158
165 MessageReceiverWithResponderStatus* const incoming_receiver_; 159 MessageReceiverWithResponderStatus* const incoming_receiver_;
166 HandleIncomingMessageThunk thunk_; 160 HandleIncomingMessageThunk thunk_;
167 FilterChain filters_; 161 FilterChain filters_;
168 162
169 AsyncResponderMap async_responders_; 163 AsyncResponderMap async_responders_;
170 SyncResponseMap sync_responses_; 164 SyncResponseMap sync_responses_;
171 165
172 uint64_t next_request_id_; 166 uint64_t next_request_id_;
173 167
174 base::Closure error_handler_; 168 base::Closure error_handler_;
175 ConnectionErrorWithReasonCallback error_with_reason_handler_; 169 ConnectionErrorWithReasonCallback error_with_reason_handler_;
176 bool encountered_error_; 170 bool encountered_error_;
177 171
178 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 172 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
179 173
180 internal::ControlMessageProxy control_message_proxy_; 174 internal::ControlMessageProxy control_message_proxy_;
181 internal::ControlMessageHandler control_message_handler_; 175 internal::ControlMessageHandler control_message_handler_;
182 176
183 bool observing_message_loop_destruction_ = true;
184
185 base::ThreadChecker thread_checker_; 177 base::ThreadChecker thread_checker_;
186 178
187 base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_; 179 base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_;
188 180
189 DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient); 181 DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient);
190 }; 182 };
191 183
192 } // namespace mojo 184 } // namespace mojo
193 185
194 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ 186 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_
OLDNEW
« no previous file with comments | « mojo/android/system/watcher_impl.cc ('k') | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698