| 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/native_message_port.h" | 5 #include "chrome/browser/extensions/api/messaging/native_message_port.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" | 8 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 | 10 |
| 11 namespace extensions { | 11 namespace extensions { |
| 12 | 12 |
| 13 NativeMessagePort::NativeMessagePort(NativeMessageProcessHost* native_process) | 13 NativeMessagePort::NativeMessagePort( |
| 14 : native_process_(native_process) { | 14 scoped_ptr<NativeMessageHost> native_message_host) { |
| 15 native_message_host_ = native_message_host.Pass(); |
| 15 } | 16 } |
| 16 | 17 |
| 17 NativeMessagePort::~NativeMessagePort() { | 18 NativeMessagePort::~NativeMessagePort() { |
| 18 content::BrowserThread::DeleteSoon( | 19 content::BrowserThread::DeleteSoon( |
| 19 content::BrowserThread::IO, FROM_HERE, native_process_); | 20 content::BrowserThread::IO, FROM_HERE, native_message_host_.release()); |
| 20 } | 21 } |
| 21 | 22 |
| 22 void NativeMessagePort::DispatchOnMessage( | 23 void NativeMessagePort::DispatchOnMessage( |
| 23 const Message& message, | 24 const Message& message, |
| 24 int target_port_id) { | 25 int target_port_id) { |
| 25 content::BrowserThread::PostTask( | 26 content::BrowserThread::PostTask( |
| 26 content::BrowserThread::IO, FROM_HERE, | 27 content::BrowserThread::IO, |
| 27 base::Bind(&NativeMessageProcessHost::Send, | 28 FROM_HERE, |
| 28 base::Unretained(native_process_), message.data)); | 29 base::Bind(&NativeMessageHost::Send, |
| 30 base::Unretained(native_message_host_.get()), |
| 31 message.data)); |
| 29 } | 32 } |
| 30 | 33 |
| 31 } // namespace extensions | 34 } // namespace extensions |
| 35 |
| OLD | NEW |