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

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

Issue 145483005: Mojo: More work towards sending message pipe handles over remote message pipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: toned down comment Created 6 years, 10 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
« no previous file with comments | « mojo/system/message_pipe_dispatcher.h ('k') | mojo/system/proxy_message_pipe_endpoint.h » ('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 #include "mojo/system/message_pipe_dispatcher.h" 5 #include "mojo/system/message_pipe_dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/system/constants.h" 8 #include "mojo/system/constants.h"
9 #include "mojo/system/memory.h" 9 #include "mojo/system/memory.h"
10 #include "mojo/system/message_pipe.h" 10 #include "mojo/system/message_pipe.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace system { 13 namespace system {
14 14
15 const unsigned kInvalidPort = static_cast<unsigned>(-1); 15 const unsigned kInvalidPort = static_cast<unsigned>(-1);
16 16
17 MessagePipeDispatcher::MessagePipeDispatcher() 17 MessagePipeDispatcher::MessagePipeDispatcher()
18 : port_(kInvalidPort) { 18 : port_(kInvalidPort) {
19 } 19 }
20 20
21 void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe, 21 void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe,
22 unsigned port) { 22 unsigned port) {
23 DCHECK(message_pipe.get()); 23 DCHECK(message_pipe.get());
24 DCHECK(port == 0 || port == 1); 24 DCHECK(port == 0 || port == 1);
25 25
26 message_pipe_ = message_pipe; 26 message_pipe_ = message_pipe;
27 port_ = port; 27 port_ = port;
28 } 28 }
29 29
30 MessagePipe* MessagePipeDispatcher::GetMessagePipeNoLock() const {
31 lock().AssertAcquired();
32 return message_pipe_.get();
33 }
34
35 unsigned MessagePipeDispatcher::GetPortNoLock() const {
36 lock().AssertAcquired();
37 return port_;
38 }
39
30 Dispatcher::Type MessagePipeDispatcher::GetType() { 40 Dispatcher::Type MessagePipeDispatcher::GetType() {
31 return kTypeMessagePipe; 41 return kTypeMessagePipe;
32 } 42 }
33 43
34 MessagePipeDispatcher::~MessagePipeDispatcher() { 44 MessagePipeDispatcher::~MessagePipeDispatcher() {
35 // |Close()|/|CloseImplNoLock()| should have taken care of the pipe. 45 // |Close()|/|CloseImplNoLock()| should have taken care of the pipe.
36 DCHECK(!message_pipe_.get()); 46 DCHECK(!message_pipe_.get());
37 } 47 }
38 48
39 void MessagePipeDispatcher::CancelAllWaitersNoLock() { 49 void MessagePipeDispatcher::CancelAllWaitersNoLock() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 117
108 scoped_refptr<MessagePipeDispatcher> rv = new MessagePipeDispatcher(); 118 scoped_refptr<MessagePipeDispatcher> rv = new MessagePipeDispatcher();
109 rv->Init(message_pipe_, port_); 119 rv->Init(message_pipe_, port_);
110 message_pipe_ = NULL; 120 message_pipe_ = NULL;
111 port_ = kInvalidPort; 121 port_ = kInvalidPort;
112 return scoped_refptr<Dispatcher>(rv.get()); 122 return scoped_refptr<Dispatcher>(rv.get());
113 } 123 }
114 124
115 } // namespace system 125 } // namespace system
116 } // namespace mojo 126 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/message_pipe_dispatcher.h ('k') | mojo/system/proxy_message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698