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

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: Add empty line 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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 if (reset_here) 771 if (reset_here)
772 reset_after_frame_num_ = END_OF_STREAM_RESET; 772 reset_after_frame_num_ = END_OF_STREAM_RESET;
773 } 773 }
774 774
775 // Populate the shared memory buffer w/ the fragment, duplicate its handle, 775 // Populate the shared memory buffer w/ the fragment, duplicate its handle,
776 // and hand it off to the decoder. 776 // and hand it off to the decoder.
777 base::SharedMemory shm; 777 base::SharedMemory shm;
778 CHECK(shm.CreateAndMapAnonymous(next_fragment_size)); 778 CHECK(shm.CreateAndMapAnonymous(next_fragment_size));
779 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); 779 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size);
780 base::SharedMemoryHandle dup_handle; 780 base::SharedMemoryHandle dup_handle;
781 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle)); 781 CHECK(shm.ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle));
782 media::BitstreamBuffer bitstream_buffer( 782 media::BitstreamBuffer bitstream_buffer(
783 next_bitstream_buffer_id_, dup_handle, next_fragment_size); 783 next_bitstream_buffer_id_, dup_handle, next_fragment_size);
784 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); 784 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now();
785 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. 785 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
786 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; 786 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
787 decoder_->Decode(bitstream_buffer); 787 decoder_->Decode(bitstream_buffer);
788 ++outstanding_decodes_; 788 ++outstanding_decodes_;
789 if (!remaining_play_throughs_ && 789 if (!remaining_play_throughs_ &&
790 -delete_decoder_state_ == next_bitstream_buffer_id_) { 790 -delete_decoder_state_ == next_bitstream_buffer_id_) {
791 DeleteDecoder(); 791 DeleteDecoder();
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 if (it->first == "v" || it->first == "vmodule") 1439 if (it->first == "v" || it->first == "vmodule")
1440 continue; 1440 continue;
1441 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1441 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1442 } 1442 }
1443 1443
1444 base::ShadowingAtExitManager at_exit_manager; 1444 base::ShadowingAtExitManager at_exit_manager;
1445 content::RenderingHelper::InitializeOneOff(); 1445 content::RenderingHelper::InitializeOneOff();
1446 1446
1447 return RUN_ALL_TESTS(); 1447 return RUN_ALL_TESTS();
1448 } 1448 }
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/common/gpu/media/video_encode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698