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

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

Issue 475223002: Mojo: Add embedder::PlatformSupport and a simple implementation (and a bit of plumbing). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 5 #ifndef MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
6 #define MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 6 #define MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "mojo/embedder/platform_shared_buffer.h" 9 #include "mojo/embedder/platform_shared_buffer.h"
10 #include "mojo/system/memory.h" 10 #include "mojo/system/memory.h"
11 #include "mojo/system/simple_dispatcher.h" 11 #include "mojo/system/simple_dispatcher.h"
12 #include "mojo/system/system_impl_export.h" 12 #include "mojo/system/system_impl_export.h"
13 13
14 namespace mojo { 14 namespace mojo {
15
16 namespace embedder {
17 class PlatformSupport;
18 }
19
15 namespace system { 20 namespace system {
16 21
17 // TODO(vtl): We derive from SimpleDispatcher, even though we don't currently 22 // TODO(vtl): We derive from SimpleDispatcher, even though we don't currently
18 // have anything that's waitable. I want to add a "transferrable" wait flag 23 // have anything that's waitable. I want to add a "transferrable" wait flag
19 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.). 24 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.).
20 class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher : public SimpleDispatcher { 25 class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher : public SimpleDispatcher {
21 public: 26 public:
22 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses 27 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses
23 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; 28 // should obtain this via |ValidateCreateOptions()| with a null |in_options|;
24 // this is exposed directly for testing convenience.) 29 // this is exposed directly for testing convenience.)
25 static const MojoCreateSharedBufferOptions kDefaultCreateOptions; 30 static const MojoCreateSharedBufferOptions kDefaultCreateOptions;
26 31
27 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|. 32 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|.
28 // If non-null, |in_options| must point to a struct of at least 33 // If non-null, |in_options| must point to a struct of at least
29 // |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)
30 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success 35 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success
31 // (it may be partly overwritten on failure). 36 // (it may be partly overwritten on failure).
32 static MojoResult ValidateCreateOptions( 37 static MojoResult ValidateCreateOptions(
33 UserPointer<const MojoCreateSharedBufferOptions> in_options, 38 UserPointer<const MojoCreateSharedBufferOptions> in_options,
34 MojoCreateSharedBufferOptions* out_options); 39 MojoCreateSharedBufferOptions* out_options);
35 40
36 // Static factory method: |validated_options| must be validated (obviously). 41 // Static factory method: |validated_options| must be validated (obviously).
37 // On failure, |*result| will be left as-is. 42 // On failure, |*result| will be left as-is.
38 static MojoResult Create( 43 static MojoResult Create(
44 embedder::PlatformSupport* platform_support,
39 const MojoCreateSharedBufferOptions& validated_options, 45 const MojoCreateSharedBufferOptions& validated_options,
40 uint64_t num_bytes, 46 uint64_t num_bytes,
41 scoped_refptr<SharedBufferDispatcher>* result); 47 scoped_refptr<SharedBufferDispatcher>* result);
42 48
43 // |Dispatcher| public methods: 49 // |Dispatcher| public methods:
44 virtual Type GetType() const OVERRIDE; 50 virtual Type GetType() const OVERRIDE;
45 51
46 // The "opposite" of |SerializeAndClose()|. (Typically this is called by 52 // The "opposite" of |SerializeAndClose()|. (Typically this is called by
47 // |Dispatcher::Deserialize()|.) 53 // |Dispatcher::Deserialize()|.)
48 static scoped_refptr<SharedBufferDispatcher> Deserialize( 54 static scoped_refptr<SharedBufferDispatcher> Deserialize(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 94
89 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_; 95 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_;
90 96
91 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); 97 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher);
92 }; 98 };
93 99
94 } // namespace system 100 } // namespace system
95 } // namespace mojo 101 } // namespace mojo
96 102
97 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 103 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698