| 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 #include "ipc/mojo/ipc_channel_mojo_host.h" | 5 #include "ipc/mojo/ipc_channel_mojo_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "ipc/mojo/ipc_channel_mojo.h" | 9 #include "ipc/mojo/ipc_channel_mojo.h" |
| 10 | 10 |
| 11 namespace IPC { | 11 namespace IPC { |
| 12 | 12 |
| 13 // The delete class lives on the IO thread to talk to ChannelMojo on | 13 // The delete class lives on the IO thread to talk to ChannelMojo on |
| 14 // behalf of ChannelMojoHost. | 14 // behalf of ChannelMojoHost. |
| 15 // | 15 // |
| 16 // The object must be touched only on the IO thread. | 16 // The object must be touched only on the IO thread. |
| 17 class ChannelMojoHost::ChannelDelegate : public ChannelMojo::Delegate { | 17 class ChannelMojoHost::ChannelDelegate : public ChannelMojo::Delegate { |
| 18 public: | 18 public: |
| 19 explicit ChannelDelegate(scoped_refptr<base::TaskRunner> io_task_runner); | 19 explicit ChannelDelegate(scoped_refptr<base::TaskRunner> io_task_runner); |
| 20 virtual ~ChannelDelegate(); | 20 ~ChannelDelegate() override; |
| 21 | 21 |
| 22 // ChannelMojo::Delegate | 22 // ChannelMojo::Delegate |
| 23 virtual base::WeakPtr<Delegate> ToWeakPtr() override; | 23 base::WeakPtr<Delegate> ToWeakPtr() override; |
| 24 virtual void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) override; | 24 void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) override; |
| 25 virtual scoped_refptr<base::TaskRunner> GetIOTaskRunner() override; | 25 scoped_refptr<base::TaskRunner> GetIOTaskRunner() override; |
| 26 | 26 |
| 27 // Returns an weak ptr of ChannelDelegate instead of Delegate | 27 // Returns an weak ptr of ChannelDelegate instead of Delegate |
| 28 base::WeakPtr<ChannelDelegate> GetWeakPtr(); | 28 base::WeakPtr<ChannelDelegate> GetWeakPtr(); |
| 29 void OnClientLaunched(base::ProcessHandle process); | 29 void OnClientLaunched(base::ProcessHandle process); |
| 30 void DeleteThisSoon(); | 30 void DeleteThisSoon(); |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 scoped_refptr<base::TaskRunner> io_task_runner_; | 33 scoped_refptr<base::TaskRunner> io_task_runner_; |
| 34 base::WeakPtr<ChannelMojo> channel_; | 34 base::WeakPtr<ChannelMojo> channel_; |
| 35 base::WeakPtrFactory<ChannelDelegate> weak_factory_; | 35 base::WeakPtrFactory<ChannelDelegate> weak_factory_; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ChannelMojo::Delegate* ChannelMojoHost::channel_delegate() const { | 106 ChannelMojo::Delegate* ChannelMojoHost::channel_delegate() const { |
| 107 return channel_delegate_.get(); | 107 return channel_delegate_.get(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ChannelMojoHost::DelegateDeleter::operator()( | 110 void ChannelMojoHost::DelegateDeleter::operator()( |
| 111 ChannelMojoHost::ChannelDelegate* ptr) const { | 111 ChannelMojoHost::ChannelDelegate* ptr) const { |
| 112 ptr->DeleteThisSoon(); | 112 ptr->DeleteThisSoon(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace IPC | 115 } // namespace IPC |
| OLD | NEW |