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

Side by Side Diff: media/mojo/services/mojo_cdm_allocator.cc

Issue 2253943004: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/mojo/services/main.cc ('k') | media/mojo/services/mojo_cdm_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mojo/services/mojo_cdm_allocator.h" 5 #include "media/mojo/services/mojo_cdm_allocator.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // memory available for another MojoCdmBuffer. 191 // memory available for another MojoCdmBuffer.
192 return MojoCdmBuffer::Create( 192 return MojoCdmBuffer::Create(
193 std::move(buffer), capacity, 193 std::move(buffer), capacity,
194 base::Bind(&MojoCdmAllocator::AddBufferToAvailableMap, 194 base::Bind(&MojoCdmAllocator::AddBufferToAvailableMap,
195 weak_ptr_factory_.GetWeakPtr())); 195 weak_ptr_factory_.GetWeakPtr()));
196 } 196 }
197 197
198 // Creates a new MojoCdmVideoFrame on every request. 198 // Creates a new MojoCdmVideoFrame on every request.
199 std::unique_ptr<VideoFrameImpl> MojoCdmAllocator::CreateCdmVideoFrame() { 199 std::unique_ptr<VideoFrameImpl> MojoCdmAllocator::CreateCdmVideoFrame() {
200 DCHECK(thread_checker_.CalledOnValidThread()); 200 DCHECK(thread_checker_.CalledOnValidThread());
201 return base::WrapUnique(new MojoCdmVideoFrame( 201 return base::MakeUnique<MojoCdmVideoFrame>(
202 base::Bind(&MojoCdmAllocator::AddBufferToAvailableMap, 202 base::Bind(&MojoCdmAllocator::AddBufferToAvailableMap,
203 weak_ptr_factory_.GetWeakPtr()))); 203 weak_ptr_factory_.GetWeakPtr()));
204 } 204 }
205 205
206 mojo::ScopedSharedBufferHandle MojoCdmAllocator::AllocateNewBuffer( 206 mojo::ScopedSharedBufferHandle MojoCdmAllocator::AllocateNewBuffer(
207 size_t* capacity) { 207 size_t* capacity) {
208 DCHECK(thread_checker_.CalledOnValidThread()); 208 DCHECK(thread_checker_.CalledOnValidThread());
209 209
210 // Always pad new allocated buffer so that we don't need to reallocate 210 // Always pad new allocated buffer so that we don't need to reallocate
211 // buffers frequently if requested sizes fluctuate slightly. 211 // buffers frequently if requested sizes fluctuate slightly.
212 static const size_t kBufferPadding = 512; 212 static const size_t kBufferPadding = 512;
213 213
(...skipping 29 matching lines...) Expand all
243 MojoHandle MojoCdmAllocator::GetHandleForTesting(cdm::Buffer* buffer) { 243 MojoHandle MojoCdmAllocator::GetHandleForTesting(cdm::Buffer* buffer) {
244 MojoCdmBuffer* mojo_buffer = static_cast<MojoCdmBuffer*>(buffer); 244 MojoCdmBuffer* mojo_buffer = static_cast<MojoCdmBuffer*>(buffer);
245 return mojo_buffer->Handle().value(); 245 return mojo_buffer->Handle().value();
246 } 246 }
247 247
248 size_t MojoCdmAllocator::GetAvailableBufferCountForTesting() { 248 size_t MojoCdmAllocator::GetAvailableBufferCountForTesting() {
249 return available_buffers_.size(); 249 return available_buffers_.size();
250 } 250 }
251 251
252 } // namespace media 252 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/main.cc ('k') | media/mojo/services/mojo_cdm_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698