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

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

Issue 588193004: Mojo: Have |ProxyMessagePipeEndpoint|s constructed with a |ChannelEndpoint|. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « mojo/system/proxy_message_pipe_endpoint.h ('k') | mojo/system/remote_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/proxy_message_pipe_endpoint.h" 5 #include "mojo/system/proxy_message_pipe_endpoint.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/system/channel_endpoint.h" 10 #include "mojo/system/channel_endpoint.h"
11 #include "mojo/system/local_message_pipe_endpoint.h" 11 #include "mojo/system/local_message_pipe_endpoint.h"
12 #include "mojo/system/message_pipe_dispatcher.h" 12 #include "mojo/system/message_pipe_dispatcher.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace system { 15 namespace system {
16 16
17 ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint() 17 ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint(
18 : is_running_(false), is_peer_open_(true) { 18 ChannelEndpoint* channel_endpoint)
19 : channel_endpoint_(channel_endpoint),
20 is_running_(false),
21 is_peer_open_(true) {
19 } 22 }
20 23
21 ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint( 24 ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint(
25 ChannelEndpoint* channel_endpoint,
22 LocalMessagePipeEndpoint* local_message_pipe_endpoint, 26 LocalMessagePipeEndpoint* local_message_pipe_endpoint,
23 bool is_peer_open) 27 bool is_peer_open)
24 : is_running_(false), is_peer_open_(is_peer_open) { 28 : channel_endpoint_(channel_endpoint),
29 is_running_(false),
30 is_peer_open_(is_peer_open) {
25 paused_message_queue_.Swap(local_message_pipe_endpoint->message_queue()); 31 paused_message_queue_.Swap(local_message_pipe_endpoint->message_queue());
26 local_message_pipe_endpoint->Close(); 32 local_message_pipe_endpoint->Close();
27 } 33 }
28 34
29 ProxyMessagePipeEndpoint::~ProxyMessagePipeEndpoint() { 35 ProxyMessagePipeEndpoint::~ProxyMessagePipeEndpoint() {
30 DCHECK(!is_running()); 36 DCHECK(!is_running());
31 DCHECK(!is_attached()); 37 DCHECK(!is_attached());
32 DCHECK(paused_message_queue_.IsEmpty()); 38 DCHECK(paused_message_queue_.IsEmpty());
33 } 39 }
34 40
(...skipping 30 matching lines...) Expand all
65 scoped_ptr<MessageInTransit> message) { 71 scoped_ptr<MessageInTransit> message) {
66 if (is_running()) { 72 if (is_running()) {
67 DCHECK(channel_endpoint_.get()); 73 DCHECK(channel_endpoint_.get());
68 LOG_IF(WARNING, !channel_endpoint_->EnqueueMessage(message.Pass())) 74 LOG_IF(WARNING, !channel_endpoint_->EnqueueMessage(message.Pass()))
69 << "Failed to write enqueue message to channel"; 75 << "Failed to write enqueue message to channel";
70 } else { 76 } else {
71 paused_message_queue_.AddMessage(message.Pass()); 77 paused_message_queue_.AddMessage(message.Pass());
72 } 78 }
73 } 79 }
74 80
75 void ProxyMessagePipeEndpoint::Attach(ChannelEndpoint* channel_endpoint) {
76 DCHECK(channel_endpoint);
77 DCHECK(!is_attached());
78 channel_endpoint_ = channel_endpoint;
79 }
80
81 bool ProxyMessagePipeEndpoint::Run() { 81 bool ProxyMessagePipeEndpoint::Run() {
82 // Assertions about current state: 82 // Assertions about current state:
83 DCHECK(is_attached()); 83 DCHECK(is_attached());
84 DCHECK(!is_running()); 84 DCHECK(!is_running());
85 85
86 is_running_ = true; 86 is_running_ = true;
87 87
88 while (!paused_message_queue_.IsEmpty()) { 88 while (!paused_message_queue_.IsEmpty()) {
89 LOG_IF( 89 LOG_IF(
90 WARNING, 90 WARNING,
(...skipping 17 matching lines...) Expand all
108 DCHECK(is_attached()); 108 DCHECK(is_attached());
109 109
110 channel_endpoint_->DetachFromMessagePipe(); 110 channel_endpoint_->DetachFromMessagePipe();
111 channel_endpoint_ = NULL; 111 channel_endpoint_ = NULL;
112 is_running_ = false; 112 is_running_ = false;
113 paused_message_queue_.Clear(); 113 paused_message_queue_.Clear();
114 } 114 }
115 115
116 } // namespace system 116 } // namespace system
117 } // namespace mojo 117 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/proxy_message_pipe_endpoint.h ('k') | mojo/system/remote_message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698