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 "chrome/browser/extensions/api/messaging/extension_message_port.h" | 5 #include "chrome/browser/extensions/api/messaging/extension_message_port.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "content/public/browser/interstitial_page.h" | 10 #include "content/public/browser/interstitial_page.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 source.frame_id = source_frame_id; | 210 source.frame_id = source_frame_id; |
211 | 211 |
212 ExtensionMsg_ExternalConnectionInfo info; | 212 ExtensionMsg_ExternalConnectionInfo info; |
213 info.target_id = target_extension_id; | 213 info.target_id = target_extension_id; |
214 info.source_id = source_extension_id; | 214 info.source_id = source_extension_id; |
215 info.source_url = source_url; | 215 info.source_url = source_url; |
216 info.guest_process_id = guest_process_id; | 216 info.guest_process_id = guest_process_id; |
217 info.guest_render_frame_routing_id = guest_render_frame_routing_id; | 217 info.guest_render_frame_routing_id = guest_render_frame_routing_id; |
218 | 218 |
219 SendToPort(base::WrapUnique(new ExtensionMsg_DispatchOnConnect( | 219 SendToPort(base::MakeUnique<ExtensionMsg_DispatchOnConnect>( |
220 MSG_ROUTING_NONE, port_id_, channel_name, source, info, tls_channel_id))); | 220 MSG_ROUTING_NONE, port_id_, channel_name, source, info, tls_channel_id)); |
221 } | 221 } |
222 | 222 |
223 void ExtensionMessagePort::DispatchOnDisconnect( | 223 void ExtensionMessagePort::DispatchOnDisconnect( |
224 const std::string& error_message) { | 224 const std::string& error_message) { |
225 SendToPort(base::WrapUnique(new ExtensionMsg_DispatchOnDisconnect( | 225 SendToPort(base::MakeUnique<ExtensionMsg_DispatchOnDisconnect>( |
226 MSG_ROUTING_NONE, port_id_, error_message))); | 226 MSG_ROUTING_NONE, port_id_, error_message)); |
227 } | 227 } |
228 | 228 |
229 void ExtensionMessagePort::DispatchOnMessage(const Message& message) { | 229 void ExtensionMessagePort::DispatchOnMessage(const Message& message) { |
230 SendToPort(base::WrapUnique(new ExtensionMsg_DeliverMessage( | 230 SendToPort(base::MakeUnique<ExtensionMsg_DeliverMessage>( |
231 MSG_ROUTING_NONE, port_id_, opener_tab_id_, message))); | 231 MSG_ROUTING_NONE, port_id_, opener_tab_id_, message)); |
232 } | 232 } |
233 | 233 |
234 void ExtensionMessagePort::IncrementLazyKeepaliveCount() { | 234 void ExtensionMessagePort::IncrementLazyKeepaliveCount() { |
235 ProcessManager* pm = ProcessManager::Get(browser_context_); | 235 ProcessManager* pm = ProcessManager::Get(browser_context_); |
236 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); | 236 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); |
237 if (host && BackgroundInfo::HasLazyBackgroundPage(host->extension())) | 237 if (host && BackgroundInfo::HasLazyBackgroundPage(host->extension())) |
238 pm->IncrementLazyKeepaliveCount(host->extension()); | 238 pm->IncrementLazyKeepaliveCount(host->extension()); |
239 | 239 |
240 // Keep track of the background host, so when we decrement, we only do so if | 240 // Keep track of the background host, so when we decrement, we only do so if |
241 // the host hasn't reloaded. | 241 // the host hasn't reloaded. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 return; | 304 return; |
305 } | 305 } |
306 for (content::RenderFrameHost* rfh : frames_) { | 306 for (content::RenderFrameHost* rfh : frames_) { |
307 IPC::Message* msg_copy = new IPC::Message(*msg); | 307 IPC::Message* msg_copy = new IPC::Message(*msg); |
308 msg_copy->set_routing_id(rfh->GetRoutingID()); | 308 msg_copy->set_routing_id(rfh->GetRoutingID()); |
309 rfh->Send(msg_copy); | 309 rfh->Send(msg_copy); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 } // namespace extensions | 313 } // namespace extensions |
OLD | NEW |