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

Side by Side Diff: mojo/services/media/common/cpp/mapped_shared_buffer.h

Issue 1822333002: Motown: wholesale clang-format (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: dalesat Created 4 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_BUFFER_H_ 5 #ifndef MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_BUFFER_H_
6 #define MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_BUFFER_H_ 6 #define MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_BUFFER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "mojo/public/cpp/system/buffer.h" 10 #include "mojo/public/cpp/system/buffer.h"
(...skipping 28 matching lines...) Expand all
39 // Gets the size of the buffer. 39 // Gets the size of the buffer.
40 uint64_t size() const; 40 uint64_t size() const;
41 41
42 // Gets a duplicate handle for the shared buffer. 42 // Gets a duplicate handle for the shared buffer.
43 ScopedSharedBufferHandle GetDuplicateHandle() const; 43 ScopedSharedBufferHandle GetDuplicateHandle() const;
44 44
45 // Translates an offset into a pointer. 45 // Translates an offset into a pointer.
46 void* PtrFromOffset(uint64_t offset) const; 46 void* PtrFromOffset(uint64_t offset) const;
47 47
48 // Translates a pointer into an offset. 48 // Translates a pointer into an offset.
49 uint64_t OffsetFromPtr(void *payload_ptr) const; 49 uint64_t OffsetFromPtr(void* payload_ptr) const;
50 50
51 protected: 51 protected:
52 void InitInternal(const ScopedSharedBufferHandle& handle); 52 void InitInternal(const ScopedSharedBufferHandle& handle);
53 53
54 // Does nothing. Called when initialization is complete. Subclasses may 54 // Does nothing. Called when initialization is complete. Subclasses may
55 // override. 55 // override.
56 virtual void OnInit(); 56 virtual void OnInit();
57 57
58 private: 58 private:
59 struct MappedBufferDeleter { 59 struct MappedBufferDeleter {
60 inline void operator()(uint8_t* ptr) const { 60 inline void operator()(uint8_t* ptr) const { UnmapBuffer(ptr); }
61 UnmapBuffer(ptr);
62 }
63 }; 61 };
64 62
65 // Size of the shared buffer. 63 // Size of the shared buffer.
66 uint64_t size_; 64 uint64_t size_;
67 65
68 // Shared buffer when initialized with InitNew. 66 // Shared buffer when initialized with InitNew.
69 std::unique_ptr<SharedBuffer> buffer_; 67 std::unique_ptr<SharedBuffer> buffer_;
70 68
71 // Handle to shared buffer when initialized with InitFromHandle. 69 // Handle to shared buffer when initialized with InitFromHandle.
72 ScopedSharedBufferHandle handle_; 70 ScopedSharedBufferHandle handle_;
73 71
74 // Pointer to the mapped buffer. 72 // Pointer to the mapped buffer.
75 std::unique_ptr<uint8_t, MappedBufferDeleter> buffer_ptr_; 73 std::unique_ptr<uint8_t, MappedBufferDeleter> buffer_ptr_;
76 }; 74 };
77 75
78 } // namespace media 76 } // namespace media
79 } // namespace mojo 77 } // namespace mojo
80 78
81 #endif // MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_BUFFER_H_ 79 #endif // MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_BUFFER_H_
OLDNEW
« no previous file with comments | « mojo/services/media/common/cpp/fifo_allocator.cc ('k') | mojo/services/media/common/cpp/mapped_shared_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698