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

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

Issue 623883002: Revert "Move mojo edk into mojo/edk" (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
« no previous file with comments | « mojo/edk/system/run_all_unittests.cc ('k') | mojo/edk/system/shared_buffer_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
7
8 #include "base/macros.h"
9 #include "mojo/edk/embedder/platform_shared_buffer.h"
10 #include "mojo/edk/system/memory.h"
11 #include "mojo/edk/system/simple_dispatcher.h"
12 #include "mojo/edk/system/system_impl_export.h"
13
14 namespace mojo {
15
16 namespace embedder {
17 class PlatformSupport;
18 }
19
20 namespace system {
21
22 // TODO(vtl): We derive from SimpleDispatcher, even though we don't currently
23 // have anything that's waitable. I want to add a "transferrable" wait flag
24 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.).
25 class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher : public SimpleDispatcher {
26 public:
27 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses
28 // should obtain this via |ValidateCreateOptions()| with a null |in_options|;
29 // this is exposed directly for testing convenience.)
30 static const MojoCreateSharedBufferOptions kDefaultCreateOptions;
31
32 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|.
33 // If non-null, |in_options| must point to a struct of at least
34 // |in_options->struct_size| bytes. |out_options| must point to a (current)
35 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success
36 // (it may be partly overwritten on failure).
37 static MojoResult ValidateCreateOptions(
38 UserPointer<const MojoCreateSharedBufferOptions> in_options,
39 MojoCreateSharedBufferOptions* out_options);
40
41 // Static factory method: |validated_options| must be validated (obviously).
42 // On failure, |*result| will be left as-is.
43 static MojoResult Create(
44 embedder::PlatformSupport* platform_support,
45 const MojoCreateSharedBufferOptions& validated_options,
46 uint64_t num_bytes,
47 scoped_refptr<SharedBufferDispatcher>* result);
48
49 // |Dispatcher| public methods:
50 virtual Type GetType() const override;
51
52 // The "opposite" of |SerializeAndClose()|. (Typically this is called by
53 // |Dispatcher::Deserialize()|.)
54 static scoped_refptr<SharedBufferDispatcher> Deserialize(
55 Channel* channel,
56 const void* source,
57 size_t size,
58 embedder::PlatformHandleVector* platform_handles);
59
60 private:
61 explicit SharedBufferDispatcher(
62 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_);
63 virtual ~SharedBufferDispatcher();
64
65 // Validates and/or sets default options for
66 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to
67 // a struct of at least |in_options->struct_size| bytes. |out_options| must
68 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be
69 // entirely overwritten on success (it may be partly overwritten on failure).
70 static MojoResult ValidateDuplicateOptions(
71 UserPointer<const MojoDuplicateBufferHandleOptions> in_options,
72 MojoDuplicateBufferHandleOptions* out_options);
73
74 // |Dispatcher| protected methods:
75 virtual void CloseImplNoLock() override;
76 virtual scoped_refptr<Dispatcher>
77 CreateEquivalentDispatcherAndCloseImplNoLock() override;
78 virtual MojoResult DuplicateBufferHandleImplNoLock(
79 UserPointer<const MojoDuplicateBufferHandleOptions> options,
80 scoped_refptr<Dispatcher>* new_dispatcher) override;
81 virtual MojoResult MapBufferImplNoLock(
82 uint64_t offset,
83 uint64_t num_bytes,
84 MojoMapBufferFlags flags,
85 scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping) override;
86 virtual void StartSerializeImplNoLock(Channel* channel,
87 size_t* max_size,
88 size_t* max_platform_handles) override;
89 virtual bool EndSerializeAndCloseImplNoLock(
90 Channel* channel,
91 void* destination,
92 size_t* actual_size,
93 embedder::PlatformHandleVector* platform_handles) override;
94
95 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_;
96
97 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher);
98 };
99
100 } // namespace system
101 } // namespace mojo
102
103 #endif // MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/run_all_unittests.cc ('k') | mojo/edk/system/shared_buffer_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698