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

Side by Side Diff: mojo/public/cpp/bindings/lib/connector.cc

Issue 265793015: Mojo: Replace RemotePtr with InterfacePtr and InterfaceImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Force InterfaceImpl subclasses to implement OnConnectionError Created 6 years, 7 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
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/public/cpp/bindings/lib/connector.h" 5 #include "mojo/public/cpp/bindings/lib/connector.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "mojo/public/cpp/bindings/error_handler.h" 10 #include "mojo/public/cpp/bindings/error_handler.h"
(...skipping 20 matching lines...) Expand all
31 31
32 Connector::~Connector() { 32 Connector::~Connector() {
33 if (async_wait_id_) 33 if (async_wait_id_)
34 waiter_->CancelWait(waiter_, async_wait_id_); 34 waiter_->CancelWait(waiter_, async_wait_id_);
35 } 35 }
36 36
37 void Connector::CloseMessagePipe() { 37 void Connector::CloseMessagePipe() {
38 Close(message_pipe_.Pass()); 38 Close(message_pipe_.Pass());
39 } 39 }
40 40
41 ScopedMessagePipeHandle Connector::ReleaseMessagePipe() {
42 if (async_wait_id_) {
43 waiter_->CancelWait(waiter_, async_wait_id_);
44 async_wait_id_ = 0;
45 }
46 return message_pipe_.Pass();
47 }
48
41 bool Connector::Accept(Message* message) { 49 bool Connector::Accept(Message* message) {
50 assert(message_pipe_.is_valid());
51
42 if (error_) 52 if (error_)
43 return false; 53 return false;
44 54
45 if (drop_writes_) 55 if (drop_writes_)
46 return true; 56 return true;
47 57
48 MojoResult rv = WriteMessageRaw( 58 MojoResult rv = WriteMessageRaw(
49 message_pipe_.get(), 59 message_pipe_.get(),
50 message->data(), 60 message->data(),
51 message->data_num_bytes(), 61 message->data_num_bytes(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void Connector::OnHandleReady(MojoResult result) { 102 void Connector::OnHandleReady(MojoResult result) {
93 async_wait_id_ = 0; 103 async_wait_id_ = 0;
94 104
95 if (result == MOJO_RESULT_OK) { 105 if (result == MOJO_RESULT_OK) {
96 ReadMore(); 106 ReadMore();
97 } else { 107 } else {
98 error_ = true; 108 error_ = true;
99 } 109 }
100 110
101 if (error_ && error_handler_) 111 if (error_ && error_handler_)
102 error_handler_->OnError(); 112 error_handler_->OnConnectionError();
103 } 113 }
104 114
105 void Connector::WaitToReadMore() { 115 void Connector::WaitToReadMore() {
106 async_wait_id_ = waiter_->AsyncWait(waiter_, 116 async_wait_id_ = waiter_->AsyncWait(waiter_,
107 message_pipe_.get().value(), 117 message_pipe_.get().value(),
108 MOJO_WAIT_FLAG_READABLE, 118 MOJO_WAIT_FLAG_READABLE,
109 MOJO_DEADLINE_INDEFINITE, 119 MOJO_DEADLINE_INDEFINITE,
110 &Connector::CallOnHandleReady, 120 &Connector::CallOnHandleReady,
111 this); 121 this);
112 } 122 }
(...skipping 10 matching lines...) Expand all
123 if (rv != MOJO_RESULT_OK || 133 if (rv != MOJO_RESULT_OK ||
124 (enforce_errors_from_incoming_receiver_ && !receiver_result)) { 134 (enforce_errors_from_incoming_receiver_ && !receiver_result)) {
125 error_ = true; 135 error_ = true;
126 break; 136 break;
127 } 137 }
128 } 138 }
129 } 139 }
130 140
131 } // namespace internal 141 } // namespace internal
132 } // namespace mojo 142 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698