| OLD | NEW | 
|---|
| 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 #include <utility> | 
| 12 | 13 | 
| 13 #include "base/callback.h" | 14 #include "base/callback.h" | 
| 14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" | 
| 15 #include "base/logging.h" | 16 #include "base/logging.h" | 
| 16 #include "base/macros.h" | 17 #include "base/macros.h" | 
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" | 
| 18 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" | 
| 19 #include "base/optional.h" | 20 #include "base/optional.h" | 
| 20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" | 
| 21 #include "base/threading/thread_checker.h" | 22 #include "base/threading/thread_checker.h" | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 44   InterfaceEndpointClient(ScopedInterfaceEndpointHandle handle, | 45   InterfaceEndpointClient(ScopedInterfaceEndpointHandle handle, | 
| 45                           MessageReceiverWithResponderStatus* receiver, | 46                           MessageReceiverWithResponderStatus* receiver, | 
| 46                           std::unique_ptr<MessageReceiver> payload_validator, | 47                           std::unique_ptr<MessageReceiver> payload_validator, | 
| 47                           bool expect_sync_requests, | 48                           bool expect_sync_requests, | 
| 48                           scoped_refptr<base::SingleThreadTaskRunner> runner, | 49                           scoped_refptr<base::SingleThreadTaskRunner> runner, | 
| 49                           uint32_t interface_version); | 50                           uint32_t interface_version); | 
| 50   ~InterfaceEndpointClient() override; | 51   ~InterfaceEndpointClient() override; | 
| 51 | 52 | 
| 52   // Sets the error handler to receive notifications when an error is | 53   // Sets the error handler to receive notifications when an error is | 
| 53   // encountered. | 54   // encountered. | 
| 54   void set_connection_error_handler(const base::Closure& error_handler) { | 55   void set_connection_error_handler(base::OnceClosure error_handler) { | 
| 55     DCHECK(thread_checker_.CalledOnValidThread()); | 56     DCHECK(thread_checker_.CalledOnValidThread()); | 
| 56     error_handler_ = error_handler; | 57     error_handler_ = std::move(error_handler); | 
| 57     error_with_reason_handler_.Reset(); | 58     error_with_reason_handler_.Reset(); | 
| 58   } | 59   } | 
| 59 | 60 | 
| 60   void set_connection_error_with_reason_handler( | 61   void set_connection_error_with_reason_handler( | 
| 61       const ConnectionErrorWithReasonCallback& error_handler) { | 62       ConnectionErrorWithReasonCallback error_handler) { | 
| 62     DCHECK(thread_checker_.CalledOnValidThread()); | 63     DCHECK(thread_checker_.CalledOnValidThread()); | 
| 63     error_with_reason_handler_ = error_handler; | 64     error_with_reason_handler_ = std::move(error_handler); | 
| 64     error_handler_.Reset(); | 65     error_handler_.Reset(); | 
| 65   } | 66   } | 
| 66 | 67 | 
| 67   // Returns true if an error was encountered. | 68   // Returns true if an error was encountered. | 
| 68   bool encountered_error() const { | 69   bool encountered_error() const { | 
| 69     DCHECK(thread_checker_.CalledOnValidThread()); | 70     DCHECK(thread_checker_.CalledOnValidThread()); | 
| 70     return encountered_error_; | 71     return encountered_error_; | 
| 71   } | 72   } | 
| 72 | 73 | 
| 73   // Returns true if this endpoint has any pending callbacks. | 74   // Returns true if this endpoint has any pending callbacks. | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 165 | 166 | 
| 166   MessageReceiverWithResponderStatus* const incoming_receiver_ = nullptr; | 167   MessageReceiverWithResponderStatus* const incoming_receiver_ = nullptr; | 
| 167   HandleIncomingMessageThunk thunk_; | 168   HandleIncomingMessageThunk thunk_; | 
| 168   FilterChain filters_; | 169   FilterChain filters_; | 
| 169 | 170 | 
| 170   AsyncResponderMap async_responders_; | 171   AsyncResponderMap async_responders_; | 
| 171   SyncResponseMap sync_responses_; | 172   SyncResponseMap sync_responses_; | 
| 172 | 173 | 
| 173   uint64_t next_request_id_ = 1; | 174   uint64_t next_request_id_ = 1; | 
| 174 | 175 | 
| 175   base::Closure error_handler_; | 176   base::OnceClosure error_handler_; | 
| 176   ConnectionErrorWithReasonCallback error_with_reason_handler_; | 177   ConnectionErrorWithReasonCallback error_with_reason_handler_; | 
| 177   bool encountered_error_ = false; | 178   bool encountered_error_ = false; | 
| 178 | 179 | 
| 179   scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 180   scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 
| 180 | 181 | 
| 181   internal::ControlMessageProxy control_message_proxy_; | 182   internal::ControlMessageProxy control_message_proxy_; | 
| 182   internal::ControlMessageHandler control_message_handler_; | 183   internal::ControlMessageHandler control_message_handler_; | 
| 183 | 184 | 
| 184   base::ThreadChecker thread_checker_; | 185   base::ThreadChecker thread_checker_; | 
| 185 | 186 | 
| 186   base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_; | 187   base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_; | 
| 187 | 188 | 
| 188   DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient); | 189   DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient); | 
| 189 }; | 190 }; | 
| 190 | 191 | 
| 191 }  // namespace mojo | 192 }  // namespace mojo | 
| 192 | 193 | 
| 193 #endif  // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ | 194 #endif  // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ | 
| OLD | NEW | 
|---|