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

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

Issue 137273003: Mojo: Rename PlatformChannelHandle to PlatformHandle, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 11 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/channel.h ('k') | mojo/system/multiprocess_message_pipe_unittest.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 #include "mojo/system/channel.h" 5 #include "mojo/system/channel.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 19 matching lines...) Expand all
30 port(port) { 30 port(port) {
31 } 31 }
32 32
33 Channel::EndpointInfo::~EndpointInfo() { 33 Channel::EndpointInfo::~EndpointInfo() {
34 } 34 }
35 35
36 Channel::Channel() 36 Channel::Channel()
37 : next_local_id_(kBootstrapEndpointId) { 37 : next_local_id_(kBootstrapEndpointId) {
38 } 38 }
39 39
40 bool Channel::Init(const PlatformChannelHandle& handle) { 40 bool Channel::Init(ScopedPlatformHandle handle) {
41 DCHECK(creation_thread_checker_.CalledOnValidThread()); 41 DCHECK(creation_thread_checker_.CalledOnValidThread());
42 42
43 // No need to take |lock_|, since this must be called before this object 43 // No need to take |lock_|, since this must be called before this object
44 // becomes thread-safe. 44 // becomes thread-safe.
45 DCHECK(!raw_channel_.get()); 45 DCHECK(!raw_channel_.get());
46 46
47 raw_channel_.reset( 47 raw_channel_.reset(
48 RawChannel::Create(handle, this, base::MessageLoop::current())); 48 RawChannel::Create(handle.Pass(), this, base::MessageLoop::current()));
49 if (!raw_channel_->Init()) { 49 if (!raw_channel_->Init()) {
50 raw_channel_.reset(); 50 raw_channel_.reset();
51 return false; 51 return false;
52 } 52 }
53 53
54 return true; 54 return true;
55 } 55 }
56 56
57 void Channel::Shutdown() { 57 void Channel::Shutdown() {
58 DCHECK(creation_thread_checker_.CalledOnValidThread()); 58 DCHECK(creation_thread_checker_.CalledOnValidThread());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 endpoint_info.message_pipe->Run(endpoint_info.port, remote_id); 105 endpoint_info.message_pipe->Run(endpoint_info.port, remote_id);
106 } 106 }
107 107
108 bool Channel::WriteMessage(MessageInTransit* message) { 108 bool Channel::WriteMessage(MessageInTransit* message) {
109 base::AutoLock locker(lock_); 109 base::AutoLock locker(lock_);
110 if (!raw_channel_.get()) { 110 if (!raw_channel_.get()) {
111 // TODO(vtl): I think this is probably not an error condition, but I should 111 // TODO(vtl): I think this is probably not an error condition, but I should
112 // think about it (and the shutdown sequence) more carefully. 112 // think about it (and the shutdown sequence) more carefully.
113 LOG(INFO) << "WriteMessage() after shutdown"; 113 LOG(WARNING) << "WriteMessage() after shutdown";
114 return false; 114 return false;
115 } 115 }
116 116
117 return raw_channel_->WriteMessage(message); 117 return raw_channel_->WriteMessage(message);
118 } 118 }
119 119
120 void Channel::DetachMessagePipeEndpoint(MessageInTransit::EndpointId local_id) { 120 void Channel::DetachMessagePipeEndpoint(MessageInTransit::EndpointId local_id) {
121 DCHECK_NE(local_id, MessageInTransit::kInvalidEndpointId); 121 DCHECK_NE(local_id, MessageInTransit::kInvalidEndpointId);
122 122
123 base::AutoLock locker_(lock_); 123 base::AutoLock locker_(lock_);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 197
198 void Channel::OnReadMessageForChannel(const MessageInTransit& message) { 198 void Channel::OnReadMessageForChannel(const MessageInTransit& message) {
199 // TODO(vtl): Currently no channel-only messages yet. 199 // TODO(vtl): Currently no channel-only messages yet.
200 HandleRemoteError("Received invalid channel message"); 200 HandleRemoteError("Received invalid channel message");
201 NOTREACHED(); 201 NOTREACHED();
202 } 202 }
203 203
204 void Channel::HandleRemoteError(const base::StringPiece& error_message) { 204 void Channel::HandleRemoteError(const base::StringPiece& error_message) {
205 // TODO(vtl): Is this how we really want to handle this? 205 // TODO(vtl): Is this how we really want to handle this?
206 LOG(INFO) << error_message; 206 LOG(WARNING) << error_message;
207 } 207 }
208 208
209 void Channel::HandleLocalError(const base::StringPiece& error_message) { 209 void Channel::HandleLocalError(const base::StringPiece& error_message) {
210 // TODO(vtl): Is this how we really want to handle this? 210 // TODO(vtl): Is this how we really want to handle this?
211 LOG(FATAL) << error_message; 211 LOG(FATAL) << error_message;
212 } 212 }
213 213
214 } // namespace system 214 } // namespace system
215 } // namespace mojo 215 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/channel.h ('k') | mojo/system/multiprocess_message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698