| 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> | 
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  223         mojo::GetProxy(proxy, GetAssociatedGroup()); |  223         mojo::GetProxy(proxy, GetAssociatedGroup()); | 
|  224     GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); |  224     GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); | 
|  225   } |  225   } | 
|  226  |  226  | 
|  227 #if defined(ENABLE_IPC_FUZZER) |  227 #if defined(ENABLE_IPC_FUZZER) | 
|  228   void set_outgoing_message_filter(OutgoingMessageFilter* filter) { |  228   void set_outgoing_message_filter(OutgoingMessageFilter* filter) { | 
|  229     outgoing_message_filter_ = filter; |  229     outgoing_message_filter_ = filter; | 
|  230   } |  230   } | 
|  231 #endif |  231 #endif | 
|  232  |  232  | 
 |  233   using RunOnIOThreadCallback = base::Callback<void(Channel*)>; | 
 |  234   // Invokes |callback| on the IO (IPC) thread. | 
 |  235   void RunOnIOThread(const RunOnIOThreadCallback& callback); | 
 |  236  | 
|  233   // Called to clear the pointer to the IPC task runner when it's going away. |  237   // Called to clear the pointer to the IPC task runner when it's going away. | 
|  234   void ClearIPCTaskRunner(); |  238   void ClearIPCTaskRunner(); | 
|  235  |  239  | 
|  236  protected: |  240  protected: | 
|  237   class Context; |  241   class Context; | 
|  238   // A subclass uses this constructor if it needs to add more information |  242   // A subclass uses this constructor if it needs to add more information | 
|  239   // to the internal state. |  243   // to the internal state. | 
|  240   explicit ChannelProxy(Context* context); |  244   explicit ChannelProxy(Context* context); | 
|  241  |  245  | 
|  242  |  | 
|  243   // Used internally to hold state that is referenced on the IPC thread. |  246   // Used internally to hold state that is referenced on the IPC thread. | 
|  244   class Context : public base::RefCountedThreadSafe<Context>, |  247   class Context : public base::RefCountedThreadSafe<Context>, | 
|  245                   public Listener { |  248                   public Listener { | 
|  246    public: |  249    public: | 
|  247     Context(Listener* listener, |  250     Context(Listener* listener, | 
|  248             const scoped_refptr<base::SingleThreadTaskRunner>& ipc_thread); |  251             const scoped_refptr<base::SingleThreadTaskRunner>& ipc_thread); | 
|  249     void ClearIPCTaskRunner(); |  252     void ClearIPCTaskRunner(); | 
|  250     base::SingleThreadTaskRunner* ipc_task_runner() const { |  253     base::SingleThreadTaskRunner* ipc_task_runner() const { | 
|  251       return ipc_task_runner_.get(); |  254       return ipc_task_runner_.get(); | 
|  252     } |  255     } | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  297     friend class ChannelProxy; |  300     friend class ChannelProxy; | 
|  298     friend class IpcSecurityTestUtil; |  301     friend class IpcSecurityTestUtil; | 
|  299  |  302  | 
|  300     // Create the Channel |  303     // Create the Channel | 
|  301     void CreateChannel(std::unique_ptr<ChannelFactory> factory); |  304     void CreateChannel(std::unique_ptr<ChannelFactory> factory); | 
|  302  |  305  | 
|  303     // Methods called on the IO thread. |  306     // Methods called on the IO thread. | 
|  304     void OnSendMessage(std::unique_ptr<Message> message_ptr); |  307     void OnSendMessage(std::unique_ptr<Message> message_ptr); | 
|  305     void OnAddFilter(); |  308     void OnAddFilter(); | 
|  306     void OnRemoveFilter(MessageFilter* filter); |  309     void OnRemoveFilter(MessageFilter* filter); | 
 |  310     void RunWithChannel(const RunOnIOThreadCallback& callback); | 
|  307  |  311  | 
|  308     // Methods called on the listener thread. |  312     // Methods called on the listener thread. | 
|  309     void AddFilter(MessageFilter* filter); |  313     void AddFilter(MessageFilter* filter); | 
|  310     void OnDispatchConnected(); |  314     void OnDispatchConnected(); | 
|  311     void OnDispatchError(); |  315     void OnDispatchError(); | 
|  312     void OnDispatchBadMessage(const Message& message); |  316     void OnDispatchBadMessage(const Message& message); | 
|  313     void OnDispatchAssociatedInterfaceRequest( |  317     void OnDispatchAssociatedInterfaceRequest( | 
|  314         const std::string& interface_name, |  318         const std::string& interface_name, | 
|  315         mojo::ScopedInterfaceEndpointHandle handle); |  319         mojo::ScopedInterfaceEndpointHandle handle); | 
|  316  |  320  | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  403   bool did_init_; |  407   bool did_init_; | 
|  404  |  408  | 
|  405 #if defined(ENABLE_IPC_FUZZER) |  409 #if defined(ENABLE_IPC_FUZZER) | 
|  406   OutgoingMessageFilter* outgoing_message_filter_; |  410   OutgoingMessageFilter* outgoing_message_filter_; | 
|  407 #endif |  411 #endif | 
|  408 }; |  412 }; | 
|  409  |  413  | 
|  410 }  // namespace IPC |  414 }  // namespace IPC | 
|  411  |  415  | 
|  412 #endif  // IPC_IPC_CHANNEL_PROXY_H_ |  416 #endif  // IPC_IPC_CHANNEL_PROXY_H_ | 
| OLD | NEW |