| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 IPC_IPC_CHANNEL_PROXY_H_ | 5 #ifndef IPC_IPC_CHANNEL_PROXY_H_ |
| 6 #define IPC_IPC_CHANNEL_PROXY_H_ | 6 #define IPC_IPC_CHANNEL_PROXY_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 <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/sequence_checker.h" |
| 17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 18 #include "base/threading/non_thread_safe.h" | |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "ipc/ipc_channel.h" | 20 #include "ipc/ipc_channel.h" |
| 21 #include "ipc/ipc_channel_handle.h" | 21 #include "ipc/ipc_channel_handle.h" |
| 22 #include "ipc/ipc_listener.h" | 22 #include "ipc/ipc_listener.h" |
| 23 #include "ipc/ipc_sender.h" | 23 #include "ipc/ipc_sender.h" |
| 24 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 24 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 25 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 25 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
| 26 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" | 26 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
| 27 #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" | 27 #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" |
| 28 | 28 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // instance where the IPC::Channel will be created and operated. | 65 // instance where the IPC::Channel will be created and operated. |
| 66 // | 66 // |
| 67 // Thread-safe send | 67 // Thread-safe send |
| 68 // | 68 // |
| 69 // If a particular |Channel| implementation has a thread-safe |Send()| operation | 69 // If a particular |Channel| implementation has a thread-safe |Send()| operation |
| 70 // then ChannelProxy skips the inter-thread hop and calls |Send()| directly. In | 70 // then ChannelProxy skips the inter-thread hop and calls |Send()| directly. In |
| 71 // this case the |channel_| variable is touched by multiple threads so | 71 // this case the |channel_| variable is touched by multiple threads so |
| 72 // |channel_lifetime_lock_| is used to protect it. The locking overhead is only | 72 // |channel_lifetime_lock_| is used to protect it. The locking overhead is only |
| 73 // paid if the underlying channel supports thread-safe |Send|. | 73 // paid if the underlying channel supports thread-safe |Send|. |
| 74 // | 74 // |
| 75 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { | 75 class IPC_EXPORT ChannelProxy : public Sender { |
| 76 public: | 76 public: |
| 77 #if defined(ENABLE_IPC_FUZZER) | 77 #if defined(ENABLE_IPC_FUZZER) |
| 78 // Interface for a filter to be imposed on outgoing messages which can | 78 // Interface for a filter to be imposed on outgoing messages which can |
| 79 // re-write the message. Used for testing. | 79 // re-write the message. Used for testing. |
| 80 class OutgoingMessageFilter { | 80 class OutgoingMessageFilter { |
| 81 public: | 81 public: |
| 82 virtual Message* Rewrite(Message* message) = 0; | 82 virtual Message* Rewrite(Message* message) = 0; |
| 83 }; | 83 }; |
| 84 #endif | 84 #endif |
| 85 | 85 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // can safely be destroyed while the background thread continues to do stuff | 397 // can safely be destroyed while the background thread continues to do stuff |
| 398 // that involves this data. | 398 // that involves this data. |
| 399 scoped_refptr<Context> context_; | 399 scoped_refptr<Context> context_; |
| 400 | 400 |
| 401 // Whether the channel has been initialized. | 401 // Whether the channel has been initialized. |
| 402 bool did_init_; | 402 bool did_init_; |
| 403 | 403 |
| 404 #if defined(ENABLE_IPC_FUZZER) | 404 #if defined(ENABLE_IPC_FUZZER) |
| 405 OutgoingMessageFilter* outgoing_message_filter_; | 405 OutgoingMessageFilter* outgoing_message_filter_; |
| 406 #endif | 406 #endif |
| 407 |
| 408 SEQUENCE_CHECKER(sequence_checker_); |
| 407 }; | 409 }; |
| 408 | 410 |
| 409 } // namespace IPC | 411 } // namespace IPC |
| 410 | 412 |
| 411 #endif // IPC_IPC_CHANNEL_PROXY_H_ | 413 #endif // IPC_IPC_CHANNEL_PROXY_H_ |
| OLD | NEW |