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

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

Issue 1350183002: EDK: More scoped_ptr -> std::unique_ptr conversions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: gah Created 5 years, 3 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 | « no previous file | mojo/edk/embedder/simple_platform_shared_buffer.h » ('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 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_PLATFORM_SHARED_BUFFER_H_ 5 #ifndef MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_
6 #define MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ 6 #define MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
11
10 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "mojo/edk/embedder/scoped_platform_handle.h" 13 #include "mojo/edk/embedder/scoped_platform_handle.h"
13 #include "mojo/edk/system/system_impl_export.h" 14 #include "mojo/edk/system/system_impl_export.h"
14 #include "mojo/public/cpp/system/macros.h" 15 #include "mojo/public/cpp/system/macros.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace embedder { 18 namespace embedder {
18 19
19 class PlatformSharedBufferMapping; 20 class PlatformSharedBufferMapping;
20 21
21 // |PlatformSharedBuffer| is an interface for a thread-safe, ref-counted wrapper 22 // |PlatformSharedBuffer| is an interface for a thread-safe, ref-counted wrapper
(...skipping 13 matching lines...) Expand all
35 // TODO(vtl): Rectify this with |base::SharedMemory|. 36 // TODO(vtl): Rectify this with |base::SharedMemory|.
36 class MOJO_SYSTEM_IMPL_EXPORT PlatformSharedBuffer 37 class MOJO_SYSTEM_IMPL_EXPORT PlatformSharedBuffer
37 : public base::RefCountedThreadSafe<PlatformSharedBuffer> { 38 : public base::RefCountedThreadSafe<PlatformSharedBuffer> {
38 public: 39 public:
39 // Gets the size of shared buffer (in number of bytes). 40 // Gets the size of shared buffer (in number of bytes).
40 virtual size_t GetNumBytes() const = 0; 41 virtual size_t GetNumBytes() const = 0;
41 42
42 // Maps (some) of the shared buffer into memory; [|offset|, |offset + length|] 43 // Maps (some) of the shared buffer into memory; [|offset|, |offset + length|]
43 // must be contained in [0, |num_bytes|], and |length| must be at least 1. 44 // must be contained in [0, |num_bytes|], and |length| must be at least 1.
44 // Returns null on failure. 45 // Returns null on failure.
45 virtual scoped_ptr<PlatformSharedBufferMapping> Map(size_t offset, 46 virtual std::unique_ptr<PlatformSharedBufferMapping> Map(size_t offset,
46 size_t length) = 0; 47 size_t length) = 0;
47 48
48 // Checks if |offset| and |length| are valid arguments. 49 // Checks if |offset| and |length| are valid arguments.
49 virtual bool IsValidMap(size_t offset, size_t length) = 0; 50 virtual bool IsValidMap(size_t offset, size_t length) = 0;
50 51
51 // Like |Map()|, but doesn't check its arguments (which should have been 52 // Like |Map()|, but doesn't check its arguments (which should have been
52 // preflighted using |IsValidMap()|). 53 // preflighted using |IsValidMap()|).
53 virtual scoped_ptr<PlatformSharedBufferMapping> MapNoCheck(size_t offset, 54 virtual std::unique_ptr<PlatformSharedBufferMapping> MapNoCheck(
54 size_t length) = 0; 55 size_t offset,
56 size_t length) = 0;
55 57
56 // Duplicates the underlying platform handle and passes it to the caller. 58 // Duplicates the underlying platform handle and passes it to the caller.
57 // TODO(vtl): On POSIX, we'll need two FDs to support sharing read-only. 59 // TODO(vtl): On POSIX, we'll need two FDs to support sharing read-only.
58 virtual ScopedPlatformHandle DuplicatePlatformHandle() = 0; 60 virtual ScopedPlatformHandle DuplicatePlatformHandle() = 0;
59 61
60 // Passes the underlying platform handle to the caller. This should only be 62 // Passes the underlying platform handle to the caller. This should only be
61 // called if there's a unique reference to this object (owned by the caller). 63 // called if there's a unique reference to this object (owned by the caller).
62 // After calling this, this object should no longer be used, but should only 64 // After calling this, this object should no longer be used, but should only
63 // be disposed of. 65 // be disposed of.
64 virtual ScopedPlatformHandle PassPlatformHandle() = 0; 66 virtual ScopedPlatformHandle PassPlatformHandle() = 0;
(...skipping 28 matching lines...) Expand all
93 PlatformSharedBufferMapping() {} 95 PlatformSharedBufferMapping() {}
94 96
95 private: 97 private:
96 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformSharedBufferMapping); 98 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformSharedBufferMapping);
97 }; 99 };
98 100
99 } // namespace embedder 101 } // namespace embedder
100 } // namespace mojo 102 } // namespace mojo
101 103
102 #endif // MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ 104 #endif // MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/edk/embedder/simple_platform_shared_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698