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

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

Issue 1478503003: EDK: Convert most uses of PlatformHandleVector to std::vector<ScopedPlatformHandle>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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/platform_handle_dispatcher.cc ('k') | mojo/edk/system/raw_channel.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RAW_CHANNEL_H_ 5 #ifndef MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
6 #define MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ 6 #define MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "mojo/edk/embedder/platform_handle_vector.h"
13 #include "mojo/edk/embedder/scoped_platform_handle.h" 12 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #include "mojo/edk/system/message_in_transit.h" 13 #include "mojo/edk/system/message_in_transit.h"
15 #include "mojo/edk/system/message_in_transit_queue.h" 14 #include "mojo/edk/system/message_in_transit_queue.h"
16 #include "mojo/edk/util/mutex.h" 15 #include "mojo/edk/util/mutex.h"
17 #include "mojo/edk/util/thread_annotations.h" 16 #include "mojo/edk/util/thread_annotations.h"
18 #include "mojo/public/cpp/system/macros.h" 17 #include "mojo/public/cpp/system/macros.h"
19 18
20 namespace base { 19 namespace base {
21 class MessageLoopForIO; 20 class MessageLoopForIO;
22 } 21 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Unknown read error. 59 // Unknown read error.
61 ERROR_READ_UNKNOWN, 60 ERROR_READ_UNKNOWN,
62 // Generic write error. 61 // Generic write error.
63 ERROR_WRITE 62 ERROR_WRITE
64 }; 63 };
65 64
66 // Called when a message is read. This may call the |RawChannel|'s 65 // Called when a message is read. This may call the |RawChannel|'s
67 // |Shutdown()| and then (if desired) destroy it. 66 // |Shutdown()| and then (if desired) destroy it.
68 virtual void OnReadMessage( 67 virtual void OnReadMessage(
69 const MessageInTransit::View& message_view, 68 const MessageInTransit::View& message_view,
70 embedder::ScopedPlatformHandleVectorPtr platform_handles) = 0; 69 std::unique_ptr<std::vector<embedder::ScopedPlatformHandle>>
70 platform_handles) = 0;
71 71
72 // Called when there's a (fatal) error. This may call the |RawChannel|'s 72 // Called when there's a (fatal) error. This may call the |RawChannel|'s
73 // |Shutdown()| and then (if desired) destroy it. 73 // |Shutdown()| and then (if desired) destroy it.
74 // 74 //
75 // For each raw channel, there'll be at most one |ERROR_READ_...| and at 75 // For each raw channel, there'll be at most one |ERROR_READ_...| and at
76 // most one |ERROR_WRITE| notification. After |OnError(ERROR_READ_...)|, 76 // most one |ERROR_WRITE| notification. After |OnError(ERROR_READ_...)|,
77 // |OnReadMessage()| won't be called again. 77 // |OnReadMessage()| won't be called again.
78 virtual void OnError(Error error) = 0; 78 virtual void OnError(Error error) = 0;
79 79
80 protected: 80 protected:
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Similar to |Read()|, except that the implementing subclass must also 254 // Similar to |Read()|, except that the implementing subclass must also
255 // guarantee that the method doesn't succeed synchronously, i.e., it only 255 // guarantee that the method doesn't succeed synchronously, i.e., it only
256 // returns |IO_FAILED_...| or |IO_PENDING|. 256 // returns |IO_FAILED_...| or |IO_PENDING|.
257 virtual IOResult ScheduleRead() MOJO_LOCKS_EXCLUDED(write_mutex_) = 0; 257 virtual IOResult ScheduleRead() MOJO_LOCKS_EXCLUDED(write_mutex_) = 0;
258 258
259 // Called by |OnReadCompleted()| to get the platform handles associated with 259 // Called by |OnReadCompleted()| to get the platform handles associated with
260 // the given platform handle table (from a message). This should only be 260 // the given platform handle table (from a message). This should only be
261 // called when |num_platform_handles| is nonzero. Returns null if the 261 // called when |num_platform_handles| is nonzero. Returns null if the
262 // |num_platform_handles| handles are not available. Only called on the I/O 262 // |num_platform_handles| handles are not available. Only called on the I/O
263 // thread. 263 // thread.
264 virtual embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( 264 virtual std::unique_ptr<std::vector<embedder::ScopedPlatformHandle>>
265 size_t num_platform_handles, 265 GetReadPlatformHandles(size_t num_platform_handles,
266 const void* platform_handle_table) MOJO_LOCKS_EXCLUDED(write_mutex_) = 0; 266 const void* platform_handle_table)
267 MOJO_LOCKS_EXCLUDED(write_mutex_) = 0;
267 268
268 // Writes contents in |write_buffer_no_lock()|. 269 // Writes contents in |write_buffer_no_lock()|.
269 // This class guarantees that: 270 // This class guarantees that:
270 // - the |PlatformHandle|s given by |GetPlatformHandlesToSend()| and the 271 // - the |PlatformHandle|s given by |GetPlatformHandlesToSend()| and the
271 // buffer(s) given by |GetBuffers()| will remain valid until write 272 // buffer(s) given by |GetBuffers()| will remain valid until write
272 // completion (see also the comments for |OnShutdownNoLock()|); 273 // completion (see also the comments for |OnShutdownNoLock()|);
273 // - a second write is not started if there is a pending write. 274 // - a second write is not started if there is a pending write.
274 // 275 //
275 // The implementing subclass must guarantee that: 276 // The implementing subclass must guarantee that:
276 // - |platform_handles_written| and |bytes_written| are untouched unless 277 // - |platform_handles_written| and |bytes_written| are untouched unless
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 base::WeakPtrFactory<RawChannel> weak_ptr_factory_ 331 base::WeakPtrFactory<RawChannel> weak_ptr_factory_
331 MOJO_GUARDED_BY(write_mutex_); 332 MOJO_GUARDED_BY(write_mutex_);
332 333
333 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel); 334 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel);
334 }; 335 };
335 336
336 } // namespace system 337 } // namespace system
337 } // namespace mojo 338 } // namespace mojo
338 339
339 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ 340 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/platform_handle_dispatcher.cc ('k') | mojo/edk/system/raw_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698