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

Side by Side Diff: content/common/gpu/media/video_decode_accelerator_unittest.cc

Issue 651253002: Enforce handle ownership in base::Process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years, 2 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) 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 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 17 matching lines...) Expand all
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 29
30 #include "base/at_exit.h" 30 #include "base/at_exit.h"
31 #include "base/bind.h" 31 #include "base/bind.h"
32 #include "base/command_line.h" 32 #include "base/command_line.h"
33 #include "base/files/file.h" 33 #include "base/files/file.h"
34 #include "base/files/file_util.h" 34 #include "base/files/file_util.h"
35 #include "base/format_macros.h" 35 #include "base/format_macros.h"
36 #include "base/md5.h" 36 #include "base/md5.h"
37 #include "base/message_loop/message_loop_proxy.h" 37 #include "base/message_loop/message_loop_proxy.h"
38 #include "base/process/process.h" 38 #include "base/process/process_handle.h"
39 #include "base/stl_util.h" 39 #include "base/stl_util.h"
40 #include "base/strings/string_number_conversions.h" 40 #include "base/strings/string_number_conversions.h"
41 #include "base/strings/string_split.h" 41 #include "base/strings/string_split.h"
42 #include "base/strings/stringize_macros.h" 42 #include "base/strings/stringize_macros.h"
43 #include "base/strings/stringprintf.h" 43 #include "base/strings/stringprintf.h"
44 #include "base/strings/utf_string_conversions.h" 44 #include "base/strings/utf_string_conversions.h"
45 #include "base/synchronization/condition_variable.h" 45 #include "base/synchronization/condition_variable.h"
46 #include "base/synchronization/lock.h" 46 #include "base/synchronization/lock.h"
47 #include "base/synchronization/waitable_event.h" 47 #include "base/synchronization/waitable_event.h"
48 #include "base/threading/thread.h" 48 #include "base/threading/thread.h"
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 if (reset_here) 768 if (reset_here)
769 reset_after_frame_num_ = END_OF_STREAM_RESET; 769 reset_after_frame_num_ = END_OF_STREAM_RESET;
770 } 770 }
771 771
772 // Populate the shared memory buffer w/ the fragment, duplicate its handle, 772 // Populate the shared memory buffer w/ the fragment, duplicate its handle,
773 // and hand it off to the decoder. 773 // and hand it off to the decoder.
774 base::SharedMemory shm; 774 base::SharedMemory shm;
775 CHECK(shm.CreateAndMapAnonymous(next_fragment_size)); 775 CHECK(shm.CreateAndMapAnonymous(next_fragment_size));
776 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); 776 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size);
777 base::SharedMemoryHandle dup_handle; 777 base::SharedMemoryHandle dup_handle;
778 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle)); 778 CHECK(shm.ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle));
779 media::BitstreamBuffer bitstream_buffer( 779 media::BitstreamBuffer bitstream_buffer(
780 next_bitstream_buffer_id_, dup_handle, next_fragment_size); 780 next_bitstream_buffer_id_, dup_handle, next_fragment_size);
781 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); 781 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now();
782 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. 782 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
783 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; 783 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
784 decoder_->Decode(bitstream_buffer); 784 decoder_->Decode(bitstream_buffer);
785 ++outstanding_decodes_; 785 ++outstanding_decodes_;
786 if (!remaining_play_throughs_ && 786 if (!remaining_play_throughs_ &&
787 -delete_decoder_state_ == next_bitstream_buffer_id_) { 787 -delete_decoder_state_ == next_bitstream_buffer_id_) {
788 DeleteDecoder(); 788 DeleteDecoder();
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 if (it->first == "v" || it->first == "vmodule") 1429 if (it->first == "v" || it->first == "vmodule")
1430 continue; 1430 continue;
1431 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1431 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1432 } 1432 }
1433 1433
1434 base::ShadowingAtExitManager at_exit_manager; 1434 base::ShadowingAtExitManager at_exit_manager;
1435 content::RenderingHelper::InitializeOneOff(); 1435 content::RenderingHelper::InitializeOneOff();
1436 1436
1437 return RUN_ALL_TESTS(); 1437 return RUN_ALL_TESTS();
1438 } 1438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698