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