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

Side by Side Diff: media/base/test_helpers.cc

Issue 2914603002: Replace deprecated base::NonThreadSafe in media in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « media/base/test_helpers.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "media/base/test_helpers.h" 5 #include "media/base/test_helpers.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return base::Bind(&MockCallback::RunWithStatus, callback); 62 return base::Bind(&MockCallback::RunWithStatus, callback);
63 } 63 }
64 64
65 WaitableMessageLoopEvent::WaitableMessageLoopEvent() 65 WaitableMessageLoopEvent::WaitableMessageLoopEvent()
66 : WaitableMessageLoopEvent(TestTimeouts::action_timeout()) {} 66 : WaitableMessageLoopEvent(TestTimeouts::action_timeout()) {}
67 67
68 WaitableMessageLoopEvent::WaitableMessageLoopEvent(base::TimeDelta timeout) 68 WaitableMessageLoopEvent::WaitableMessageLoopEvent(base::TimeDelta timeout)
69 : signaled_(false), status_(PIPELINE_OK), timeout_(timeout) {} 69 : signaled_(false), status_(PIPELINE_OK), timeout_(timeout) {}
70 70
71 WaitableMessageLoopEvent::~WaitableMessageLoopEvent() { 71 WaitableMessageLoopEvent::~WaitableMessageLoopEvent() {
72 DCHECK(CalledOnValidThread()); 72 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
73 } 73 }
74 74
75 base::Closure WaitableMessageLoopEvent::GetClosure() { 75 base::Closure WaitableMessageLoopEvent::GetClosure() {
76 DCHECK(CalledOnValidThread()); 76 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
77 return BindToCurrentLoop(base::Bind( 77 return BindToCurrentLoop(base::Bind(
78 &WaitableMessageLoopEvent::OnCallback, base::Unretained(this), 78 &WaitableMessageLoopEvent::OnCallback, base::Unretained(this),
79 PIPELINE_OK)); 79 PIPELINE_OK));
80 } 80 }
81 81
82 PipelineStatusCB WaitableMessageLoopEvent::GetPipelineStatusCB() { 82 PipelineStatusCB WaitableMessageLoopEvent::GetPipelineStatusCB() {
83 DCHECK(CalledOnValidThread()); 83 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
84 return BindToCurrentLoop(base::Bind( 84 return BindToCurrentLoop(base::Bind(
85 &WaitableMessageLoopEvent::OnCallback, base::Unretained(this))); 85 &WaitableMessageLoopEvent::OnCallback, base::Unretained(this)));
86 } 86 }
87 87
88 void WaitableMessageLoopEvent::RunAndWait() { 88 void WaitableMessageLoopEvent::RunAndWait() {
89 DCHECK(CalledOnValidThread()); 89 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
90 RunAndWaitForStatus(PIPELINE_OK); 90 RunAndWaitForStatus(PIPELINE_OK);
91 } 91 }
92 92
93 void WaitableMessageLoopEvent::RunAndWaitForStatus(PipelineStatus expected) { 93 void WaitableMessageLoopEvent::RunAndWaitForStatus(PipelineStatus expected) {
94 DCHECK(CalledOnValidThread()); 94 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
95 if (signaled_) { 95 if (signaled_) {
96 EXPECT_EQ(expected, status_); 96 EXPECT_EQ(expected, status_);
97 return; 97 return;
98 } 98 }
99 99
100 run_loop_.reset(new base::RunLoop()); 100 run_loop_.reset(new base::RunLoop());
101 base::Timer timer(false, false); 101 base::Timer timer(false, false);
102 timer.Start( 102 timer.Start(
103 FROM_HERE, timeout_, 103 FROM_HERE, timeout_,
104 base::Bind(&WaitableMessageLoopEvent::OnTimeout, base::Unretained(this))); 104 base::Bind(&WaitableMessageLoopEvent::OnTimeout, base::Unretained(this)));
105 105
106 run_loop_->Run(); 106 run_loop_->Run();
107 EXPECT_TRUE(signaled_); 107 EXPECT_TRUE(signaled_);
108 EXPECT_EQ(expected, status_); 108 EXPECT_EQ(expected, status_);
109 run_loop_.reset(); 109 run_loop_.reset();
110 } 110 }
111 111
112 void WaitableMessageLoopEvent::OnCallback(PipelineStatus status) { 112 void WaitableMessageLoopEvent::OnCallback(PipelineStatus status) {
113 DCHECK(CalledOnValidThread()); 113 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
114 signaled_ = true; 114 signaled_ = true;
115 status_ = status; 115 status_ = status;
116 116
117 // |run_loop_| may be null if the callback fires before RunAndWaitForStatus(). 117 // |run_loop_| may be null if the callback fires before RunAndWaitForStatus().
118 if (run_loop_) 118 if (run_loop_)
119 run_loop_->Quit(); 119 run_loop_->Quit();
120 } 120 }
121 121
122 void WaitableMessageLoopEvent::OnTimeout() { 122 void WaitableMessageLoopEvent::OnTimeout() {
123 DCHECK(CalledOnValidThread()); 123 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
124 ADD_FAILURE() << "Timed out waiting for message loop to quit"; 124 ADD_FAILURE() << "Timed out waiting for message loop to quit";
125 run_loop_->Quit(); 125 run_loop_->Quit();
126 } 126 }
127 127
128 static VideoDecoderConfig GetTestConfig(VideoCodec codec, 128 static VideoDecoderConfig GetTestConfig(VideoCodec codec,
129 gfx::Size coded_size, 129 gfx::Size coded_size,
130 bool is_encrypted) { 130 bool is_encrypted) {
131 gfx::Rect visible_rect(coded_size.width(), coded_size.height()); 131 gfx::Rect visible_rect(coded_size.width(), coded_size.height());
132 gfx::Size natural_size = coded_size; 132 gfx::Size natural_size = coded_size;
133 133
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 int width = 0; 276 int width = 0;
277 int height = 0; 277 int height = 0;
278 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && 278 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) &&
279 pickle.ReadInt(&height); 279 pickle.ReadInt(&height);
280 return (success && header == kFakeVideoBufferHeader && 280 return (success && header == kFakeVideoBufferHeader &&
281 width == config.coded_size().width() && 281 width == config.coded_size().width() &&
282 height == config.coded_size().height()); 282 height == config.coded_size().height());
283 } 283 }
284 284
285 } // namespace media 285 } // namespace media
OLDNEW
« no previous file with comments | « media/base/test_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698