| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MOJO_HOST_H_ | 5 #ifndef IPC_IPC_CHANNEL_MOJO_HOST_H_ |
| 6 #define IPC_IPC_CHANNEL_MOJO_HOST_H_ | 6 #define IPC_IPC_CHANNEL_MOJO_HOST_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| 11 #include "ipc/ipc_export.h" | 11 #include "ipc/ipc_export.h" |
| 12 #include "ipc/mojo/ipc_channel_mojo.h" | 12 #include "ipc/mojo/ipc_channel_mojo.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class TaskRunner; | 15 class SequencedTaskRunner; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace IPC { | 18 namespace IPC { |
| 19 | 19 |
| 20 // Through ChannelMojoHost, ChannelMojo gets extra information that | 20 // Through ChannelMojoHost, ChannelMojo gets extra information that |
| 21 // its client provides, including the child process's process handle. Every | 21 // its client provides, including the child process's process handle. Every |
| 22 // server process that uses ChannelMojo must have a ChannelMojoHost | 22 // server process that uses ChannelMojo must have a ChannelMojoHost |
| 23 // instance and call OnClientLaunched(). | 23 // instance and call OnClientLaunched(). |
| 24 class IPC_MOJO_EXPORT ChannelMojoHost { | 24 class IPC_MOJO_EXPORT ChannelMojoHost { |
| 25 public: | 25 public: |
| 26 explicit ChannelMojoHost(scoped_refptr<base::TaskRunner> io_task_runner); | 26 explicit ChannelMojoHost( |
| 27 scoped_refptr<base::SequencedTaskRunner> io_task_runner); |
| 27 ~ChannelMojoHost(); | 28 ~ChannelMojoHost(); |
| 28 | 29 |
| 29 void OnClientLaunched(base::ProcessHandle process); | 30 void OnClientLaunched(base::ProcessHandle process); |
| 30 ChannelMojo::Delegate* channel_delegate() const; | 31 ChannelMojo::Delegate* channel_delegate() const; |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 class ChannelDelegate; | 34 class ChannelDelegate; |
| 35 class ChannelDelegateTraits; |
| 34 | 36 |
| 35 // Delegate talks to ChannelMojo, whch lives in IO thread, thus | 37 const scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
| 36 // the Delegate should also live and dies in the IO thread as well. | 38 scoped_refptr<ChannelDelegate> channel_delegate_; |
| 37 class DelegateDeleter { | |
| 38 public: | |
| 39 void operator()(ChannelDelegate* ptr) const; | |
| 40 }; | |
| 41 | |
| 42 const scoped_refptr<base::TaskRunner> io_task_runner_; | |
| 43 scoped_ptr<ChannelDelegate, DelegateDeleter> channel_delegate_; | |
| 44 base::WeakPtrFactory<ChannelMojoHost> weak_factory_; | 39 base::WeakPtrFactory<ChannelMojoHost> weak_factory_; |
| 45 | 40 |
| 46 DISALLOW_COPY_AND_ASSIGN(ChannelMojoHost); | 41 DISALLOW_COPY_AND_ASSIGN(ChannelMojoHost); |
| 47 }; | 42 }; |
| 48 | 43 |
| 49 } // namespace IPC | 44 } // namespace IPC |
| 50 | 45 |
| 51 #endif // IPC_IPC_CHANNEL_MOJO_HOST_H_ | 46 #endif // IPC_IPC_CHANNEL_MOJO_HOST_H_ |
| OLD | NEW |