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

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

Issue 399313007: Mojo: Convert assert()s under mojo/public/cpp/bindings/... to MOJO_DCHECK()s. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 <stddef.h>
8 #include <stdlib.h>
9 8
10 #include "mojo/public/cpp/bindings/error_handler.h" 9 #include "mojo/public/cpp/bindings/error_handler.h"
10 #include "mojo/public/cpp/environment/logging.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace internal { 13 namespace internal {
14 14
15 // ---------------------------------------------------------------------------- 15 // ----------------------------------------------------------------------------
16 16
17 Connector::Connector(ScopedMessagePipeHandle message_pipe, 17 Connector::Connector(ScopedMessagePipeHandle message_pipe,
18 const MojoAsyncWaiter* waiter) 18 const MojoAsyncWaiter* waiter)
19 : error_handler_(NULL), 19 : error_handler_(NULL),
20 waiter_(waiter), 20 waiter_(waiter),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 MOJO_DEADLINE_INDEFINITE); 59 MOJO_DEADLINE_INDEFINITE);
60 if (rv != MOJO_RESULT_OK) { 60 if (rv != MOJO_RESULT_OK) {
61 NotifyError(); 61 NotifyError();
62 return false; 62 return false;
63 } 63 }
64 mojo_ignore_result(ReadSingleMessage(&rv)); 64 mojo_ignore_result(ReadSingleMessage(&rv));
65 return (rv == MOJO_RESULT_OK); 65 return (rv == MOJO_RESULT_OK);
66 } 66 }
67 67
68 bool Connector::Accept(Message* message) { 68 bool Connector::Accept(Message* message) {
69 assert(message_pipe_.is_valid()); 69 MOJO_DCHECK(message_pipe_.is_valid());
70 70
71 if (error_) 71 if (error_)
72 return false; 72 return false;
73 73
74 if (drop_writes_) 74 if (drop_writes_)
75 return true; 75 return true;
76 76
77 MojoResult rv = WriteMessageRaw( 77 MojoResult rv = WriteMessageRaw(
78 message_pipe_.get(), 78 message_pipe_.get(),
79 message->data(), 79 message->data(),
(...skipping 25 matching lines...) Expand all
105 return true; 105 return true;
106 } 106 }
107 107
108 // static 108 // static
109 void Connector::CallOnHandleReady(void* closure, MojoResult result) { 109 void Connector::CallOnHandleReady(void* closure, MojoResult result) {
110 Connector* self = static_cast<Connector*>(closure); 110 Connector* self = static_cast<Connector*>(closure);
111 self->OnHandleReady(result); 111 self->OnHandleReady(result);
112 } 112 }
113 113
114 void Connector::OnHandleReady(MojoResult result) { 114 void Connector::OnHandleReady(MojoResult result) {
115 assert(async_wait_id_ != 0); 115 MOJO_DCHECK(async_wait_id_ != 0);
116 async_wait_id_ = 0; 116 async_wait_id_ = 0;
117 if (result != MOJO_RESULT_OK) { 117 if (result != MOJO_RESULT_OK) {
118 NotifyError(); 118 NotifyError();
119 return; 119 return;
120 } 120 }
121 ReadAllAvailableMessages(); 121 ReadAllAvailableMessages();
122 // At this point, this object might have been deleted. Return. 122 // At this point, this object might have been deleted. Return.
123 } 123 }
124 124
125 void Connector::WaitToReadMore() { 125 void Connector::WaitToReadMore() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // should end early. 183 // should end early.
184 if (destroyed_flag_) { 184 if (destroyed_flag_) {
185 *destroyed_flag_ = true; // Propagate flag. 185 *destroyed_flag_ = true; // Propagate flag.
186 } 186 }
187 if (error_handler_) 187 if (error_handler_)
188 error_handler_->OnConnectionError(); 188 error_handler_->OnConnectionError();
189 } 189 }
190 190
191 } // namespace internal 191 } // namespace internal
192 } // namespace mojo 192 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698