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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 : public base::RefCountedThreadSafe<ChannelMojoHost::ChannelDelegate, | 23 : public base::RefCountedThreadSafe<ChannelMojoHost::ChannelDelegate, |
24 ChannelMojoHost::ChannelDelegateTraits>, | 24 ChannelMojoHost::ChannelDelegateTraits>, |
25 public ChannelMojo::Delegate { | 25 public ChannelMojo::Delegate { |
26 public: | 26 public: |
27 explicit ChannelDelegate( | 27 explicit ChannelDelegate( |
28 scoped_refptr<base::SequencedTaskRunner> io_task_runner); | 28 scoped_refptr<base::SequencedTaskRunner> io_task_runner); |
29 | 29 |
30 // ChannelMojo::Delegate | 30 // ChannelMojo::Delegate |
31 base::WeakPtr<Delegate> ToWeakPtr() override; | 31 base::WeakPtr<Delegate> ToWeakPtr() override; |
32 void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) override; | 32 void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) override; |
| 33 scoped_refptr<base::TaskRunner> GetIOTaskRunner() override; |
33 | 34 |
34 // Returns an weak ptr of ChannelDelegate instead of Delegate | 35 // Returns an weak ptr of ChannelDelegate instead of Delegate |
35 base::WeakPtr<ChannelDelegate> GetWeakPtr(); | 36 base::WeakPtr<ChannelDelegate> GetWeakPtr(); |
36 void OnClientLaunched(base::ProcessHandle process); | 37 void OnClientLaunched(base::ProcessHandle process); |
37 void DeleteThisSoon() const; | 38 void DeleteThisSoon() const; |
38 | 39 |
39 private: | 40 private: |
40 friend class base::DeleteHelper<ChannelDelegate>; | 41 friend class base::DeleteHelper<ChannelDelegate>; |
41 | 42 |
42 ~ChannelDelegate() override; | 43 ~ChannelDelegate() override; |
(...skipping 22 matching lines...) Expand all Loading... |
65 ChannelMojoHost::ChannelDelegate::GetWeakPtr() { | 66 ChannelMojoHost::ChannelDelegate::GetWeakPtr() { |
66 return weak_factory_.GetWeakPtr(); | 67 return weak_factory_.GetWeakPtr(); |
67 } | 68 } |
68 | 69 |
69 void ChannelMojoHost::ChannelDelegate::OnChannelCreated( | 70 void ChannelMojoHost::ChannelDelegate::OnChannelCreated( |
70 base::WeakPtr<ChannelMojo> channel) { | 71 base::WeakPtr<ChannelMojo> channel) { |
71 DCHECK(!channel_); | 72 DCHECK(!channel_); |
72 channel_ = channel; | 73 channel_ = channel; |
73 } | 74 } |
74 | 75 |
| 76 scoped_refptr<base::TaskRunner> |
| 77 ChannelMojoHost::ChannelDelegate::GetIOTaskRunner() { |
| 78 return io_task_runner_; |
| 79 } |
| 80 |
75 void ChannelMojoHost::ChannelDelegate::OnClientLaunched( | 81 void ChannelMojoHost::ChannelDelegate::OnClientLaunched( |
76 base::ProcessHandle process) { | 82 base::ProcessHandle process) { |
77 if (channel_) | 83 if (channel_) |
78 channel_->OnClientLaunched(process); | 84 channel_->OnClientLaunched(process); |
79 } | 85 } |
80 | 86 |
81 void ChannelMojoHost::ChannelDelegate::DeleteThisSoon() const { | 87 void ChannelMojoHost::ChannelDelegate::DeleteThisSoon() const { |
82 io_task_runner_->DeleteSoon(FROM_HERE, this); | 88 io_task_runner_->DeleteSoon(FROM_HERE, this); |
83 } | 89 } |
84 | 90 |
(...skipping 25 matching lines...) Expand all Loading... |
110 return channel_delegate_.get(); | 116 return channel_delegate_.get(); |
111 } | 117 } |
112 | 118 |
113 // static | 119 // static |
114 void ChannelMojoHost::ChannelDelegateTraits::Destruct( | 120 void ChannelMojoHost::ChannelDelegateTraits::Destruct( |
115 const ChannelMojoHost::ChannelDelegate* ptr) { | 121 const ChannelMojoHost::ChannelDelegate* ptr) { |
116 ptr->DeleteThisSoon(); | 122 ptr->DeleteThisSoon(); |
117 } | 123 } |
118 | 124 |
119 } // namespace IPC | 125 } // namespace IPC |
OLD | NEW |