OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 | 1294 |
1295 std::string PepperPluginDelegateImpl::GetFlashCommandLineArgs() { | 1295 std::string PepperPluginDelegateImpl::GetFlashCommandLineArgs() { |
1296 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 1296 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
1297 switches::kPpapiFlashArgs); | 1297 switches::kPpapiFlashArgs); |
1298 } | 1298 } |
1299 | 1299 |
1300 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory( | 1300 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory( |
1301 uint32_t size) { | 1301 uint32_t size) { |
1302 if (size == 0) | 1302 if (size == 0) |
1303 return NULL; | 1303 return NULL; |
1304 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | |
1305 if (shm->CreateAnonymous(size)) | |
1306 return shm.release(); | |
1307 // The sandbox can prevent CreateAnonymous from succeeding, in which case we | |
1308 // need to IPC to the browser process. | |
1309 base::SharedMemoryHandle handle; | 1304 base::SharedMemoryHandle handle; |
1310 if (!render_view_->Send( | 1305 if (!render_view_->Send( |
1311 new ViewHostMsg_AllocateSharedMemoryBuffer(size, &handle))) { | 1306 new ViewHostMsg_AllocateSharedMemoryBuffer(size, &handle))) { |
1312 DLOG(WARNING) << "Browser allocation request message failed"; | 1307 DLOG(WARNING) << "Browser allocation request message failed"; |
1313 return NULL; | 1308 return NULL; |
1314 } | 1309 } |
1315 if (!base::SharedMemory::IsHandleValid(handle)) { | 1310 if (!base::SharedMemory::IsHandleValid(handle)) { |
1316 DLOG(WARNING) << "Browser failed to allocate shared memory"; | 1311 DLOG(WARNING) << "Browser failed to allocate shared memory"; |
1317 return NULL; | 1312 return NULL; |
1318 } | 1313 } |
1319 shm.reset(new base::SharedMemory(handle, false)); | 1314 return new base::SharedMemory(handle, false); |
1320 return shm.release(); | |
1321 } | 1315 } |
OLD | NEW |