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

Side by Side Diff: mojo/system/message_pipe_dispatcher.cc

Issue 23621056: Initial in-process implementation of some Mojo primitives. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/system/message_pipe_dispatcher.h"
6
7 #include "base/logging.h"
8 #include "mojo/system/message_pipe.h"
9
10 namespace mojo {
11 namespace system {
12
13 MessagePipeDispatcher::MessagePipeDispatcher() {
14 }
15
16 void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe,
17 unsigned port) {
18 DCHECK(message_pipe.get());
19 DCHECK(port == 0 || port == 1);
20
21 message_pipe_ = message_pipe;
22 port_ = port;
23 }
24
25 MessagePipeDispatcher::~MessagePipeDispatcher() {
26 // |Close()|/|CloseImplNoLock()| should have taken care of the pipe.
27 DCHECK(!message_pipe_.get());
28 }
29
30 void MessagePipeDispatcher::CancelAllWaitersNoLock() {
31 lock().AssertAcquired();
32 message_pipe_->CancelAllWaiters(port_);
33 }
34
35 MojoResult MessagePipeDispatcher::CloseImplNoLock() {
36 lock().AssertAcquired();
37 message_pipe_->Close(port_);
38 message_pipe_ = NULL;
39 return MOJO_RESULT_OK;
40 }
41
42 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock(
43 const void* bytes, uint32_t num_bytes,
44 const MojoHandle* handles, uint32_t num_handles,
45 MojoWriteMessageFlags flags) {
46 lock().AssertAcquired();
47 return message_pipe_->WriteMessage(port_,
48 bytes, num_bytes,
49 handles, num_handles,
50 flags);
51 }
52
53 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock(
54 void* bytes, uint32_t* num_bytes,
55 MojoHandle* handles, uint32_t* num_handles,
56 MojoReadMessageFlags flags) {
57 lock().AssertAcquired();
58 return message_pipe_->ReadMessage(port_,
59 bytes, num_bytes,
60 handles, num_handles,
61 flags);
62 }
63
64 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock(Waiter* waiter,
65 MojoWaitFlags flags,
66 MojoResult wake_result) {
67 lock().AssertAcquired();
68 return message_pipe_->AddWaiter(port_, waiter, flags, wake_result);
69 }
70
71 void MessagePipeDispatcher::RemoveWaiterImplNoLock(Waiter* waiter) {
72 lock().AssertAcquired();
73 message_pipe_->RemoveWaiter(port_, waiter);
74 }
75
76 } // namespace system
77 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698