Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: chrome/nacl/nacl_ipc_manager.cc

Issue 10214007: Add an IPC channel between the NaCl loader process and the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698