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

Side by Side Diff: ppapi/proxy/video_decoder_resource_unittest.cc

Issue 2852803002: Remove base::SharedMemory::ShareToProcess. (Closed)
Patch Set: Rebase. 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 int32_t CallDecode(PP_Resource pp_decoder, 140 int32_t CallDecode(PP_Resource pp_decoder,
141 MockCompletionCallback* cb, 141 MockCompletionCallback* cb,
142 const PpapiHostMsg_VideoDecoder_GetShm* expected_shm_msg) { 142 const PpapiHostMsg_VideoDecoder_GetShm* expected_shm_msg) {
143 // Set up a handler in case the resource sends a sync message to create 143 // Set up a handler in case the resource sends a sync message to create
144 // shared memory. 144 // shared memory.
145 PpapiPluginMsg_VideoDecoder_GetShmReply shm_msg_reply(kShmSize); 145 PpapiPluginMsg_VideoDecoder_GetShmReply shm_msg_reply(kShmSize);
146 ResourceSyncCallHandler shm_msg_handler( 146 ResourceSyncCallHandler shm_msg_handler(
147 &sink(), PpapiHostMsg_VideoDecoder_GetShm::ID, PP_OK, shm_msg_reply); 147 &sink(), PpapiHostMsg_VideoDecoder_GetShm::ID, PP_OK, shm_msg_reply);
148 sink().AddFilter(&shm_msg_handler); 148 sink().AddFilter(&shm_msg_handler);
149 149
150 std::unique_ptr<base::SharedMemoryHandle> shm_handle; 150 std::unique_ptr<base::SharedMemoryHandle> shm_handle;
Nico 2017/05/02 20:08:01 I don't understand why this is heap-allocated inst
erikchen 2017/05/02 21:33:10 Changed to stack allocated.
151 std::unique_ptr<SerializedHandle> serialized_handle; 151 std::unique_ptr<SerializedHandle> serialized_handle;
152 base::SharedMemory shm; 152 base::SharedMemory shm;
153 if (expected_shm_msg) { 153 if (expected_shm_msg) {
154 shm.CreateAnonymous(kShmSize); 154 shm.CreateAnonymous(kShmSize);
155 shm_handle.reset(new base::SharedMemoryHandle()); 155 shm_handle.reset(new base::SharedMemoryHandle(shm.handle().Duplicate()));
156 shm.ShareToProcess(base::GetCurrentProcessHandle(), shm_handle.get());
157 serialized_handle.reset(new SerializedHandle(*shm_handle, kShmSize)); 156 serialized_handle.reset(new SerializedHandle(*shm_handle, kShmSize));
158 shm_msg_handler.set_serialized_handle(serialized_handle.get()); 157 shm_msg_handler.set_serialized_handle(serialized_handle.get());
159 } 158 }
160 159
161 memset(decode_buffer_, 0x55, kDecodeBufferSize); 160 memset(decode_buffer_, 0x55, kDecodeBufferSize);
162 int32_t result = 161 int32_t result =
163 decoder_iface()->Decode(pp_decoder, 162 decoder_iface()->Decode(pp_decoder,
164 kDecodeId, 163 kDecodeId,
165 kDecodeBufferSize, 164 kDecodeBufferSize,
166 decode_buffer_, 165 decode_buffer_,
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 ASSERT_FALSE(uncalled_cb.called()); 583 ASSERT_FALSE(uncalled_cb.called());
585 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb)); 584 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb));
586 ASSERT_FALSE(uncalled_cb.called()); 585 ASSERT_FALSE(uncalled_cb.called());
587 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); 586 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb));
588 ASSERT_FALSE(uncalled_cb.called()); 587 ASSERT_FALSE(uncalled_cb.called());
589 } 588 }
590 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 589 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
591 590
592 } // namespace proxy 591 } // namespace proxy
593 } // namespace ppapi 592 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698