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

Side by Side Diff: mojo/edk/system/shared_buffer_dispatcher.h

Issue 1423713009: EDK: Move ref counting classes to mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
7 7
8 #include "mojo/edk/embedder/platform_shared_buffer.h" 8 #include "mojo/edk/embedder/platform_shared_buffer.h"
9 #include "mojo/edk/system/memory.h" 9 #include "mojo/edk/system/memory.h"
10 #include "mojo/edk/system/ref_ptr.h"
11 #include "mojo/edk/system/simple_dispatcher.h" 10 #include "mojo/edk/system/simple_dispatcher.h"
11 #include "mojo/edk/util/ref_ptr.h"
12 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/system/macros.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 15
16 namespace embedder { 16 namespace embedder {
17 class PlatformSupport; 17 class PlatformSupport;
18 } 18 }
19 19
20 namespace system { 20 namespace system {
21 21
(...skipping 12 matching lines...) Expand all
34 // |in_options->struct_size| bytes. |out_options| must point to a (current) 34 // |in_options->struct_size| bytes. |out_options| must point to a (current)
35 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success 35 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success
36 // (it may be partly overwritten on failure). 36 // (it may be partly overwritten on failure).
37 static MojoResult ValidateCreateOptions( 37 static MojoResult ValidateCreateOptions(
38 UserPointer<const MojoCreateSharedBufferOptions> in_options, 38 UserPointer<const MojoCreateSharedBufferOptions> in_options,
39 MojoCreateSharedBufferOptions* out_options); 39 MojoCreateSharedBufferOptions* out_options);
40 40
41 // Static factory method: |validated_options| must be validated (obviously). 41 // Static factory method: |validated_options| must be validated (obviously).
42 // Returns null on error; |*result| will be set to an appropriate result 42 // Returns null on error; |*result| will be set to an appropriate result
43 // code). 43 // code).
44 static RefPtr<SharedBufferDispatcher> Create( 44 static util::RefPtr<SharedBufferDispatcher> Create(
45 embedder::PlatformSupport* platform_support, 45 embedder::PlatformSupport* platform_support,
46 const MojoCreateSharedBufferOptions& validated_options, 46 const MojoCreateSharedBufferOptions& validated_options,
47 uint64_t num_bytes, 47 uint64_t num_bytes,
48 MojoResult* result); 48 MojoResult* result);
49 49
50 // |Dispatcher| public methods: 50 // |Dispatcher| public methods:
51 Type GetType() const override; 51 Type GetType() const override;
52 52
53 // The "opposite" of |SerializeAndClose()|. (Typically this is called by 53 // The "opposite" of |SerializeAndClose()|. (Typically this is called by
54 // |Dispatcher::Deserialize()|.) 54 // |Dispatcher::Deserialize()|.)
55 static RefPtr<SharedBufferDispatcher> Deserialize( 55 static util::RefPtr<SharedBufferDispatcher> Deserialize(
56 Channel* channel, 56 Channel* channel,
57 const void* source, 57 const void* source,
58 size_t size, 58 size_t size,
59 embedder::PlatformHandleVector* platform_handles); 59 embedder::PlatformHandleVector* platform_handles);
60 60
61 private: 61 private:
62 static RefPtr<SharedBufferDispatcher> CreateInternal( 62 static util::RefPtr<SharedBufferDispatcher> CreateInternal(
63 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer) { 63 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer) {
64 return AdoptRef(new SharedBufferDispatcher(shared_buffer.Pass())); 64 return AdoptRef(new SharedBufferDispatcher(shared_buffer.Pass()));
65 } 65 }
66 66
67 explicit SharedBufferDispatcher( 67 explicit SharedBufferDispatcher(
68 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer); 68 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer);
69 ~SharedBufferDispatcher() override; 69 ~SharedBufferDispatcher() override;
70 70
71 // Validates and/or sets default options for 71 // Validates and/or sets default options for
72 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to 72 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to
73 // a struct of at least |in_options->struct_size| bytes. |out_options| must 73 // a struct of at least |in_options->struct_size| bytes. |out_options| must
74 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be 74 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be
75 // entirely overwritten on success (it may be partly overwritten on failure). 75 // entirely overwritten on success (it may be partly overwritten on failure).
76 static MojoResult ValidateDuplicateOptions( 76 static MojoResult ValidateDuplicateOptions(
77 UserPointer<const MojoDuplicateBufferHandleOptions> in_options, 77 UserPointer<const MojoDuplicateBufferHandleOptions> in_options,
78 MojoDuplicateBufferHandleOptions* out_options); 78 MojoDuplicateBufferHandleOptions* out_options);
79 79
80 // |Dispatcher| protected methods: 80 // |Dispatcher| protected methods:
81 void CloseImplNoLock() override; 81 void CloseImplNoLock() override;
82 RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() override; 82 util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock()
83 override;
83 MojoResult DuplicateBufferHandleImplNoLock( 84 MojoResult DuplicateBufferHandleImplNoLock(
84 UserPointer<const MojoDuplicateBufferHandleOptions> options, 85 UserPointer<const MojoDuplicateBufferHandleOptions> options,
85 RefPtr<Dispatcher>* new_dispatcher) override; 86 util::RefPtr<Dispatcher>* new_dispatcher) override;
86 MojoResult MapBufferImplNoLock( 87 MojoResult MapBufferImplNoLock(
87 uint64_t offset, 88 uint64_t offset,
88 uint64_t num_bytes, 89 uint64_t num_bytes,
89 MojoMapBufferFlags flags, 90 MojoMapBufferFlags flags,
90 std::unique_ptr<embedder::PlatformSharedBufferMapping>* mapping) override; 91 std::unique_ptr<embedder::PlatformSharedBufferMapping>* mapping) override;
91 void StartSerializeImplNoLock(Channel* channel, 92 void StartSerializeImplNoLock(Channel* channel,
92 size_t* max_size, 93 size_t* max_size,
93 size_t* max_platform_handles) override 94 size_t* max_platform_handles) override
94 MOJO_NOT_THREAD_SAFE; 95 MOJO_NOT_THREAD_SAFE;
95 bool EndSerializeAndCloseImplNoLock( 96 bool EndSerializeAndCloseImplNoLock(
96 Channel* channel, 97 Channel* channel,
97 void* destination, 98 void* destination,
98 size_t* actual_size, 99 size_t* actual_size,
99 embedder::PlatformHandleVector* platform_handles) override 100 embedder::PlatformHandleVector* platform_handles) override
100 MOJO_NOT_THREAD_SAFE; 101 MOJO_NOT_THREAD_SAFE;
101 102
102 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_ 103 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_
103 MOJO_GUARDED_BY(mutex()); 104 MOJO_GUARDED_BY(mutex());
104 105
105 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); 106 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher);
106 }; 107 };
107 108
108 } // namespace system 109 } // namespace system
109 } // namespace mojo 110 } // namespace mojo
110 111
111 #endif // MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 112 #endif // MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/remote_producer_data_pipe_impl.cc ('k') | mojo/edk/system/shared_buffer_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698