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

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

Issue 2280483002: Add FlushForTesting to InterfacePtr and Binding. (Closed)
Patch Set: Created 4 years, 3 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/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "mojo/public/cpp/bindings/filter_chain.h" 20 #include "mojo/public/cpp/bindings/filter_chain.h"
21 #include "mojo/public/cpp/bindings/lib/control_message_handler.h"
22 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
21 #include "mojo/public/cpp/bindings/message.h" 23 #include "mojo/public/cpp/bindings/message.h"
22 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 24 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
23 25
24 namespace mojo { 26 namespace mojo {
25 27
26 class AssociatedGroup; 28 class AssociatedGroup;
27 class AssociatedGroupController; 29 class AssociatedGroupController;
28 class InterfaceEndpointController; 30 class InterfaceEndpointController;
29 31
30 // InterfaceEndpointClient handles message sending and receiving of an interface 32 // InterfaceEndpointClient handles message sending and receiving of an interface
31 // endpoint, either the implementation side or the client side. 33 // endpoint, either the implementation side or the client side.
32 // It should only be accessed and destructed on the creating thread. 34 // It should only be accessed and destructed on the creating thread.
33 class InterfaceEndpointClient : public MessageReceiverWithResponder { 35 class InterfaceEndpointClient : public MessageReceiverWithResponder {
34 public: 36 public:
35 // |receiver| is okay to be null. If it is not null, it must outlive this 37 // |receiver| is okay to be null. If it is not null, it must outlive this
36 // object. 38 // object.
37 InterfaceEndpointClient(ScopedInterfaceEndpointHandle handle, 39 InterfaceEndpointClient(ScopedInterfaceEndpointHandle handle,
38 MessageReceiverWithResponderStatus* receiver, 40 MessageReceiverWithResponderStatus* receiver,
39 std::unique_ptr<MessageReceiver> payload_validator, 41 std::unique_ptr<MessageReceiver> payload_validator,
40 bool expect_sync_requests, 42 bool expect_sync_requests,
41 scoped_refptr<base::SingleThreadTaskRunner> runner); 43 scoped_refptr<base::SingleThreadTaskRunner> runner,
44 uint32_t interface_version);
42 ~InterfaceEndpointClient() override; 45 ~InterfaceEndpointClient() override;
43 46
44 // Sets the error handler to receive notifications when an error is 47 // Sets the error handler to receive notifications when an error is
45 // encountered. 48 // encountered.
46 void set_connection_error_handler(const base::Closure& error_handler) { 49 void set_connection_error_handler(const base::Closure& error_handler) {
47 DCHECK(thread_checker_.CalledOnValidThread()); 50 DCHECK(thread_checker_.CalledOnValidThread());
48 error_handler_ = error_handler; 51 error_handler_ = error_handler;
49 } 52 }
50 53
51 // Returns true if an error was encountered. 54 // Returns true if an error was encountered.
(...skipping 30 matching lines...) Expand all
82 bool AcceptWithResponder(Message* message, 85 bool AcceptWithResponder(Message* message,
83 MessageReceiver* responder) override; 86 MessageReceiver* responder) override;
84 87
85 // The following methods are called by the router. They must be called 88 // The following methods are called by the router. They must be called
86 // outside of the router's lock. 89 // outside of the router's lock.
87 90
88 // NOTE: |message| must have passed message header validation. 91 // NOTE: |message| must have passed message header validation.
89 bool HandleIncomingMessage(Message* message); 92 bool HandleIncomingMessage(Message* message);
90 void NotifyError(); 93 void NotifyError();
91 94
95 internal::ControlMessageProxy* control_message_proxy() {
96 return &control_message_proxy_;
97 }
98
92 private: 99 private:
93 // Maps from the id of a response to the MessageReceiver that handles the 100 // Maps from the id of a response to the MessageReceiver that handles the
94 // response. 101 // response.
95 using AsyncResponderMap = 102 using AsyncResponderMap =
96 std::map<uint64_t, std::unique_ptr<MessageReceiver>>; 103 std::map<uint64_t, std::unique_ptr<MessageReceiver>>;
97 104
98 struct SyncResponseInfo { 105 struct SyncResponseInfo {
99 public: 106 public:
100 explicit SyncResponseInfo(bool* in_response_received); 107 explicit SyncResponseInfo(bool* in_response_received);
101 ~SyncResponseInfo(); 108 ~SyncResponseInfo();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 AsyncResponderMap async_responders_; 147 AsyncResponderMap async_responders_;
141 SyncResponseMap sync_responses_; 148 SyncResponseMap sync_responses_;
142 149
143 uint64_t next_request_id_; 150 uint64_t next_request_id_;
144 151
145 base::Closure error_handler_; 152 base::Closure error_handler_;
146 bool encountered_error_; 153 bool encountered_error_;
147 154
148 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 155 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
149 156
157 internal::ControlMessageProxy control_message_proxy_;
158 internal::ControlMessageHandler control_message_handler_;
159
150 base::ThreadChecker thread_checker_; 160 base::ThreadChecker thread_checker_;
151 161
152 base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_; 162 base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_;
153 163
154 DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient); 164 DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient);
155 }; 165 };
156 166
157 } // namespace mojo 167 } // namespace mojo
158 168
159 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ 169 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698