| 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/nacl/nacl_ipc_manager.h" | 5 #include "chrome/nacl/nacl_ipc_manager.h" |
| 6 | 6 |
| 7 #include "chrome/nacl/nacl_ipc_adapter.h" | 7 #include "chrome/nacl/nacl_ipc_adapter.h" |
| 8 #include "content/common/child_process.h" | 8 #include "content/common/child_process.h" |
| 9 | 9 |
| 10 NaClIPCManager::NaClIPCManager() { | 10 NaClIPCManager::NaClIPCManager() { |
| 11 } | 11 } |
| 12 | 12 |
| 13 NaClIPCManager::~NaClIPCManager() { | 13 NaClIPCManager::~NaClIPCManager() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 void NaClIPCManager::Init( |
| 17 scoped_refptr<base::MessageLoopProxy> message_loop_proxy) { |
| 18 message_loop_proxy_ = message_loop_proxy; |
| 19 } |
| 20 |
| 16 void* NaClIPCManager::CreateChannel(const IPC::ChannelHandle& handle) { | 21 void* NaClIPCManager::CreateChannel(const IPC::ChannelHandle& handle) { |
| 17 scoped_refptr<NaClIPCAdapter> adapter( | 22 scoped_refptr<NaClIPCAdapter> adapter( |
| 18 new NaClIPCAdapter(handle, | 23 new NaClIPCAdapter(handle, message_loop_proxy_.get())); |
| 19 ChildProcess::current()->io_message_loop_proxy())); | |
| 20 | 24 |
| 21 // Use the object's address as the handle given to nacl. We just need a | 25 // Use the object's address as the handle given to nacl. We just need a |
| 22 // unique void* to give to nacl for us to look it up when we get calls on | 26 // unique void* to give to nacl for us to look it up when we get calls on |
| 23 // this handle in the future. | 27 // this handle in the future. |
| 24 void* nacl_handle = adapter.get(); | 28 void* nacl_handle = adapter.get(); |
| 25 adapters_.insert(std::make_pair(nacl_handle, adapter)); | 29 adapters_.insert(std::make_pair(nacl_handle, adapter)); |
| 26 return nacl_handle; | 30 return nacl_handle; |
| 27 } | 31 } |
| 28 | 32 |
| 29 void NaClIPCManager::DestroyChannel(void* handle) { | 33 void NaClIPCManager::DestroyChannel(void* handle) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 51 return adapter->BlockingReceive(buffer, buffer_length); | 55 return adapter->BlockingReceive(buffer, buffer_length); |
| 52 } | 56 } |
| 53 | 57 |
| 54 scoped_refptr<NaClIPCAdapter> NaClIPCManager::GetAdapter(void* handle) { | 58 scoped_refptr<NaClIPCAdapter> NaClIPCManager::GetAdapter(void* handle) { |
| 55 base::AutoLock lock(lock_); | 59 base::AutoLock lock(lock_); |
| 56 AdapterMap::iterator found = adapters_.find(handle); | 60 AdapterMap::iterator found = adapters_.find(handle); |
| 57 if (found == adapters_.end()) | 61 if (found == adapters_.end()) |
| 58 return scoped_refptr<NaClIPCAdapter>(); | 62 return scoped_refptr<NaClIPCAdapter>(); |
| 59 return found->second; | 63 return found->second; |
| 60 } | 64 } |
| OLD | NEW |