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

Side by Side Diff: services/media/framework/allocator.cc

Issue 1577953002: Motown in-proc streaming framework used to implement media services. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Various fixes based on feedback. Created 4 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <cstdlib>
6
7 #include "base/logging.h"
8 #include "services/media/framework/allocator.h"
9
10 namespace mojo {
11 namespace media {
12
13 namespace {
14
15 class DefaultAllocator : public Allocator {
16 public:
17 // Allocator implementation.
18 void* AllocatePayloadBuffer(uint64_t size) override;
19
20 void ReleasePayloadBuffer(uint64_t size, void* buffer) override;
21 };
22
23 void* DefaultAllocator::AllocatePayloadBuffer(uint64_t size) {
24 DCHECK(size > 0);
25 return std::malloc(static_cast<size_t>(size));
26 }
27
28 void DefaultAllocator::ReleasePayloadBuffer(uint64_t size, void* buffer) {
29 DCHECK(size > 0);
30 DCHECK(buffer);
31 std::free(buffer);
32 }
33
34 class NullAllocator : public Allocator {
35 public:
36 // Allocator implementation.
37 void* AllocatePayloadBuffer(uint64_t size) override;
38
39 void ReleasePayloadBuffer(uint64_t size, void* buffer) override;
40 };
41
42 void* NullAllocator::AllocatePayloadBuffer(uint64_t size) {
43 NOTREACHED();
44 return nullptr;
45 }
46
47 void NullAllocator::ReleasePayloadBuffer(uint64_t size, void* buffer) {
48 DCHECK(size > 0);
49 DCHECK(buffer);
johngro 2016/01/28 19:14:54 Given that allocate is NOTREACHED, shouldn't this
dalesat 2016/01/29 01:08:29 NullAllocator is used when the packet packet paylo
johngro 2016/02/01 22:38:16 Acknowledged.
50 }
51
52 static DefaultAllocator default_allocator;
53 static NullAllocator null_allocator;
johngro 2016/01/28 19:14:55 quick reminder, remember to make the Null allocato
dalesat 2016/01/29 01:08:29 Done.
54
55 } // namespace
56
57 // static
58 Allocator* Allocator::GetDefault() {
59 return &default_allocator;
60 }
61
62 // static
63 Allocator* Allocator::GetNull() {
64 return &null_allocator;
65 }
66
67 } // namespace media
68 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698