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

Side by Side Diff: chrome/renderer/pepper/pepper_shared_memory_message_filter.cc

Issue 2852803002: Remove base::SharedMemory::ShareToProcess. (Closed)
Patch Set: Compile error. Created 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/renderer/pepper/pepper_shared_memory_message_filter.h" 5 #include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/process/process_handle.h" 10 #include "base/process/process_handle.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 uint32_t size, 42 uint32_t size,
43 int* host_handle_id, 43 int* host_handle_id,
44 ppapi::proxy::SerializedHandle* plugin_handle) { 44 ppapi::proxy::SerializedHandle* plugin_handle) {
45 plugin_handle->set_null_shmem(); 45 plugin_handle->set_null_shmem();
46 *host_handle_id = -1; 46 *host_handle_id = -1;
47 std::unique_ptr<base::SharedMemory> shm( 47 std::unique_ptr<base::SharedMemory> shm(
48 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(size)); 48 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(size));
49 if (!shm.get()) 49 if (!shm.get())
50 return; 50 return;
51 51
52 base::SharedMemoryHandle host_shm_handle; 52 // TODO(erikchen): This appears to sometimes leak the SharedMemoryHandle.
53 shm->ShareToProcess(base::GetCurrentProcessHandle(), &host_shm_handle); 53 // https://crbug.com/640840.
54 base::SharedMemoryHandle host_shm_handle = shm->handle().Duplicate();
54 *host_handle_id = 55 *host_handle_id =
55 content::PepperPluginInstance::Get(instance) 56 content::PepperPluginInstance::Get(instance)
56 ->GetVarTracker() 57 ->GetVarTracker()
57 ->TrackSharedMemoryHandle(instance, host_shm_handle, size); 58 ->TrackSharedMemoryHandle(instance, host_shm_handle, size);
58 59
59 // We set auto_close to false since we need our file descriptor to 60 // We set auto_close to false since we need our file descriptor to
60 // actually be duplicated on linux. The shared memory destructor will 61 // actually be duplicated on linux. The shared memory destructor will
61 // close the original handle for us. 62 // close the original handle for us.
62 plugin_handle->set_shmem( 63 plugin_handle->set_shmem(
63 host_->ShareSharedMemoryHandleWithRemote(host_shm_handle), size); 64 host_->ShareSharedMemoryHandleWithRemote(host_shm_handle), size);
64 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698