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 "content/public/browser/browser_message_filter.h" | 5 #include "content/public/browser/browser_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/dump_without_crashing.h" | 10 #include "base/debug/dump_without_crashing.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 const uint32_t* message_classes_to_filter, | 107 const uint32_t* message_classes_to_filter, |
108 size_t num_message_classes_to_filter) | 108 size_t num_message_classes_to_filter) |
109 : internal_(nullptr), | 109 : internal_(nullptr), |
110 sender_(nullptr), | 110 sender_(nullptr), |
111 message_classes_to_filter_( | 111 message_classes_to_filter_( |
112 message_classes_to_filter, | 112 message_classes_to_filter, |
113 message_classes_to_filter + num_message_classes_to_filter) { | 113 message_classes_to_filter + num_message_classes_to_filter) { |
114 DCHECK(num_message_classes_to_filter); | 114 DCHECK(num_message_classes_to_filter); |
115 } | 115 } |
116 | 116 |
| 117 void BrowserMessageFilter::AddAssociatedInterface( |
| 118 const std::string& name, |
| 119 const IPC::ChannelProxy::GenericAssociatedInterfaceFactory& factory) { |
| 120 associated_interfaces_.emplace_back(name, factory); |
| 121 } |
| 122 |
117 base::ProcessHandle BrowserMessageFilter::PeerHandle() { | 123 base::ProcessHandle BrowserMessageFilter::PeerHandle() { |
118 return peer_process_.Handle(); | 124 return peer_process_.Handle(); |
119 } | 125 } |
120 | 126 |
121 void BrowserMessageFilter::OnDestruct() const { | 127 void BrowserMessageFilter::OnDestruct() const { |
122 delete this; | 128 delete this; |
123 } | 129 } |
124 | 130 |
125 bool BrowserMessageFilter::Send(IPC::Message* message) { | 131 bool BrowserMessageFilter::Send(IPC::Message* message) { |
126 if (message->is_sync()) { | 132 if (message->is_sync()) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 183 } |
178 | 184 |
179 IPC::MessageFilter* BrowserMessageFilter::GetFilter() { | 185 IPC::MessageFilter* BrowserMessageFilter::GetFilter() { |
180 // We create this on demand so that if a filter is used in a unit test but | 186 // We create this on demand so that if a filter is used in a unit test but |
181 // never attached to a channel, we don't leak Internal and this; | 187 // never attached to a channel, we don't leak Internal and this; |
182 DCHECK(!internal_) << "Should only be called once."; | 188 DCHECK(!internal_) << "Should only be called once."; |
183 internal_ = new Internal(this); | 189 internal_ = new Internal(this); |
184 return internal_; | 190 return internal_; |
185 } | 191 } |
186 | 192 |
| 193 void BrowserMessageFilter::RegisterAssociatedInterfaces( |
| 194 IPC::ChannelProxy* proxy) { |
| 195 for (const auto& entry : associated_interfaces_) |
| 196 proxy->AddGenericAssociatedInterfaceForIOThread(entry.first, entry.second); |
| 197 associated_interfaces_.clear(); |
| 198 } |
| 199 |
187 } // namespace content | 200 } // namespace content |
OLD | NEW |