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

Side by Side Diff: mojo/edk/embedder/simple_platform_shared_buffer.h

Issue 668663006: Standardize usage of virtual/override/final in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ 5 #ifndef MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_
6 #define MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ 6 #define MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "mojo/edk/embedder/platform_shared_buffer.h" 11 #include "mojo/edk/embedder/platform_shared_buffer.h"
12 #include "mojo/edk/system/system_impl_export.h" 12 #include "mojo/edk/system/system_impl_export.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace embedder { 15 namespace embedder {
16 16
17 // A simple implementation of |PlatformSharedBuffer|. 17 // A simple implementation of |PlatformSharedBuffer|.
18 class MOJO_SYSTEM_IMPL_EXPORT SimplePlatformSharedBuffer 18 class MOJO_SYSTEM_IMPL_EXPORT SimplePlatformSharedBuffer
19 : public PlatformSharedBuffer { 19 : public PlatformSharedBuffer {
20 public: 20 public:
21 // Creates a shared buffer of size |num_bytes| bytes (initially zero-filled). 21 // Creates a shared buffer of size |num_bytes| bytes (initially zero-filled).
22 // |num_bytes| must be nonzero. Returns null on failure. 22 // |num_bytes| must be nonzero. Returns null on failure.
23 static SimplePlatformSharedBuffer* Create(size_t num_bytes); 23 static SimplePlatformSharedBuffer* Create(size_t num_bytes);
24 24
25 static SimplePlatformSharedBuffer* CreateFromPlatformHandle( 25 static SimplePlatformSharedBuffer* CreateFromPlatformHandle(
26 size_t num_bytes, 26 size_t num_bytes,
27 ScopedPlatformHandle platform_handle); 27 ScopedPlatformHandle platform_handle);
28 28
29 // |PlatformSharedBuffer| implementation: 29 // |PlatformSharedBuffer| implementation:
30 virtual size_t GetNumBytes() const override; 30 size_t GetNumBytes() const override;
31 virtual scoped_ptr<PlatformSharedBufferMapping> Map(size_t offset, 31 scoped_ptr<PlatformSharedBufferMapping> Map(size_t offset,
32 size_t length) override; 32 size_t length) override;
33 virtual bool IsValidMap(size_t offset, size_t length) override; 33 bool IsValidMap(size_t offset, size_t length) override;
34 virtual scoped_ptr<PlatformSharedBufferMapping> MapNoCheck( 34 scoped_ptr<PlatformSharedBufferMapping> MapNoCheck(size_t offset,
35 size_t offset, 35 size_t length) override;
36 size_t length) override; 36 ScopedPlatformHandle DuplicatePlatformHandle() override;
37 virtual ScopedPlatformHandle DuplicatePlatformHandle() override; 37 ScopedPlatformHandle PassPlatformHandle() override;
38 virtual ScopedPlatformHandle PassPlatformHandle() override;
39 38
40 private: 39 private:
41 explicit SimplePlatformSharedBuffer(size_t num_bytes); 40 explicit SimplePlatformSharedBuffer(size_t num_bytes);
42 virtual ~SimplePlatformSharedBuffer(); 41 ~SimplePlatformSharedBuffer() override;
43 42
44 // Implemented in simple_platform_shared_buffer_{posix,win}.cc: 43 // Implemented in simple_platform_shared_buffer_{posix,win}.cc:
45 44
46 // This is called by |Create()| before this object is given to anyone. 45 // This is called by |Create()| before this object is given to anyone.
47 bool Init(); 46 bool Init();
48 47
49 // This is like |Init()|, but for |CreateFromPlatformHandle()|. (Note: It 48 // This is like |Init()|, but for |CreateFromPlatformHandle()|. (Note: It
50 // should verify that |platform_handle| is an appropriate handle for the 49 // should verify that |platform_handle| is an appropriate handle for the
51 // claimed |num_bytes_|.) 50 // claimed |num_bytes_|.)
52 bool InitFromPlatformHandle(ScopedPlatformHandle platform_handle); 51 bool InitFromPlatformHandle(ScopedPlatformHandle platform_handle);
53 52
54 // The platform-dependent part of |Map()|; doesn't check arguments. 53 // The platform-dependent part of |Map()|; doesn't check arguments.
55 scoped_ptr<PlatformSharedBufferMapping> MapImpl(size_t offset, size_t length); 54 scoped_ptr<PlatformSharedBufferMapping> MapImpl(size_t offset, size_t length);
56 55
57 const size_t num_bytes_; 56 const size_t num_bytes_;
58 57
59 // This is set in |Init()|/|InitFromPlatformHandle()| and never modified 58 // This is set in |Init()|/|InitFromPlatformHandle()| and never modified
60 // (except by |PassPlatformHandle()|; see the comments above its declaration), 59 // (except by |PassPlatformHandle()|; see the comments above its declaration),
61 // hence does not need to be protected by a lock. 60 // hence does not need to be protected by a lock.
62 ScopedPlatformHandle handle_; 61 ScopedPlatformHandle handle_;
63 62
64 DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBuffer); 63 DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBuffer);
65 }; 64 };
66 65
67 // An implementation of |PlatformSharedBufferMapping|, produced by 66 // An implementation of |PlatformSharedBufferMapping|, produced by
68 // |SimplePlatformSharedBuffer|. 67 // |SimplePlatformSharedBuffer|.
69 class MOJO_SYSTEM_IMPL_EXPORT SimplePlatformSharedBufferMapping 68 class MOJO_SYSTEM_IMPL_EXPORT SimplePlatformSharedBufferMapping
70 : public PlatformSharedBufferMapping { 69 : public PlatformSharedBufferMapping {
71 public: 70 public:
72 virtual ~SimplePlatformSharedBufferMapping(); 71 ~SimplePlatformSharedBufferMapping() override;
73 72
74 virtual void* GetBase() const override; 73 void* GetBase() const override;
75 virtual size_t GetLength() const override; 74 size_t GetLength() const override;
76 75
77 private: 76 private:
78 friend class SimplePlatformSharedBuffer; 77 friend class SimplePlatformSharedBuffer;
79 78
80 SimplePlatformSharedBufferMapping(void* base, 79 SimplePlatformSharedBufferMapping(void* base,
81 size_t length, 80 size_t length,
82 void* real_base, 81 void* real_base,
83 size_t real_length) 82 size_t real_length)
84 : base_(base), 83 : base_(base),
85 length_(length), 84 length_(length),
86 real_base_(real_base), 85 real_base_(real_base),
87 real_length_(real_length) {} 86 real_length_(real_length) {}
88 void Unmap(); 87 void Unmap();
89 88
90 void* const base_; 89 void* const base_;
91 const size_t length_; 90 const size_t length_;
92 91
93 void* const real_base_; 92 void* const real_base_;
94 const size_t real_length_; 93 const size_t real_length_;
95 94
96 DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBufferMapping); 95 DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBufferMapping);
97 }; 96 };
98 97
99 } // namespace embedder 98 } // namespace embedder
100 } // namespace mojo 99 } // namespace mojo
101 100
102 #endif // MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ 101 #endif // MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_
OLDNEW
« no previous file with comments | « mojo/converters/input_events/mojo_extended_key_event_data.h ('k') | mojo/edk/embedder/simple_platform_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698