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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Called on the IPC::Channel thread | 86 // Called on the IPC::Channel thread |
87 bool ChannelProxy::Context::OnMessageReceived(const Message& message) { | 87 bool ChannelProxy::Context::OnMessageReceived(const Message& message) { |
88 // First give a chance to the filters to process this message. | 88 // First give a chance to the filters to process this message. |
89 if (!TryFilters(message)) | 89 if (!TryFilters(message)) |
90 OnMessageReceivedNoFilter(message); | 90 OnMessageReceivedNoFilter(message); |
91 return true; | 91 return true; |
92 } | 92 } |
93 | 93 |
94 // Called on the IPC::Channel thread | 94 // Called on the IPC::Channel thread |
95 bool ChannelProxy::Context::OnMessageReceivedNoFilter(const Message& message) { | 95 bool ChannelProxy::Context::OnMessageReceivedNoFilter(const Message& message) { |
96 // NOTE: This code relies on the listener's message loop not going away while | |
97 // this thread is active. That should be a reasonable assumption, but it | |
98 // feels risky. We may want to invent some more indirect way of referring to | |
99 // a MessageLoop if this becomes a problem. | |
100 listener_task_runner_->PostTask( | 96 listener_task_runner_->PostTask( |
101 FROM_HERE, base::Bind(&Context::OnDispatchMessage, this, message)); | 97 FROM_HERE, base::Bind(&Context::OnDispatchMessage, this, message)); |
102 return true; | 98 return true; |
103 } | 99 } |
104 | 100 |
105 // Called on the IPC::Channel thread | 101 // Called on the IPC::Channel thread |
106 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { | 102 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { |
107 // Add any pending filters. This avoids a race condition where someone | 103 // Add any pending filters. This avoids a race condition where someone |
108 // creates a ChannelProxy, calls AddFilter, and then right after starts the | 104 // creates a ChannelProxy, calls AddFilter, and then right after starts the |
109 // peer process. The IO thread could receive a message before the task to add | 105 // peer process. The IO thread could receive a message before the task to add |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 Channel* channel = context_.get()->channel_.get(); | 411 Channel* channel = context_.get()->channel_.get(); |
416 // Channel must have been created first. | 412 // Channel must have been created first. |
417 DCHECK(channel) << context_.get()->channel_id_; | 413 DCHECK(channel) << context_.get()->channel_id_; |
418 return channel->GetPeerEuid(peer_euid); | 414 return channel->GetPeerEuid(peer_euid); |
419 } | 415 } |
420 #endif | 416 #endif |
421 | 417 |
422 //----------------------------------------------------------------------------- | 418 //----------------------------------------------------------------------------- |
423 | 419 |
424 } // namespace IPC | 420 } // namespace IPC |
OLD | NEW |