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

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

Issue 2721333004: Mojo C++ bindings: handle the case where a message is recevied for an interface after it has encoun… (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/interface_endpoint_client.h" 5 #include "mojo/public/cpp/bindings/interface_endpoint_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/stl_util.h" 17 #include "base/stl_util.h"
17 #include "mojo/public/cpp/bindings/associated_group.h" 18 #include "mojo/public/cpp/bindings/associated_group.h"
18 #include "mojo/public/cpp/bindings/associated_group_controller.h" 19 #include "mojo/public/cpp/bindings/associated_group_controller.h"
19 #include "mojo/public/cpp/bindings/interface_endpoint_controller.h" 20 #include "mojo/public/cpp/bindings/interface_endpoint_controller.h"
20 #include "mojo/public/cpp/bindings/lib/validation_util.h" 21 #include "mojo/public/cpp/bindings/lib/validation_util.h"
21 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" 22 #include "mojo/public/cpp/bindings/sync_call_restrictions.h"
22 23
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 ScopedInterfaceEndpointHandle::PEER_CLOSED_BEFORE_ASSOCIATION) { 354 ScopedInterfaceEndpointHandle::PEER_CLOSED_BEFORE_ASSOCIATION) {
354 task_runner_->PostTask(FROM_HERE, 355 task_runner_->PostTask(FROM_HERE,
355 base::Bind(&InterfaceEndpointClient::NotifyError, 356 base::Bind(&InterfaceEndpointClient::NotifyError,
356 weak_ptr_factory_.GetWeakPtr(), 357 weak_ptr_factory_.GetWeakPtr(),
357 handle_.disconnect_reason())); 358 handle_.disconnect_reason()));
358 } 359 }
359 } 360 }
360 361
361 bool InterfaceEndpointClient::HandleValidatedMessage(Message* message) { 362 bool InterfaceEndpointClient::HandleValidatedMessage(Message* message) {
362 DCHECK_EQ(handle_.id(), message->interface_id()); 363 DCHECK_EQ(handle_.id(), message->interface_id());
363 DCHECK(!encountered_error_); 364
365 if (encountered_error_) {
366 // This message is received after error has been encountered. For associated
367 // interfaces, this means the remote side sends a
368 // PeerAssociatedEndpointClosed event but continues to send more messages
369 // for the same interface. Close the pipe because this shouldn't happen.
370 DVLOG(1) << "A message is received for an interface after it has been "
371 << "disconnected. Closing the pipe.";
372 return false;
373 }
364 374
365 if (message->has_flag(Message::kFlagExpectsResponse)) { 375 if (message->has_flag(Message::kFlagExpectsResponse)) {
366 MessageReceiverWithStatus* responder = 376 MessageReceiverWithStatus* responder =
367 new ResponderThunk(weak_ptr_factory_.GetWeakPtr(), task_runner_); 377 new ResponderThunk(weak_ptr_factory_.GetWeakPtr(), task_runner_);
368 bool ok = false; 378 bool ok = false;
369 if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) { 379 if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) {
370 ok = control_message_handler_.AcceptWithResponder(message, responder); 380 ok = control_message_handler_.AcceptWithResponder(message, responder);
371 } else { 381 } else {
372 ok = incoming_receiver_->AcceptWithResponder(message, responder); 382 ok = incoming_receiver_->AcceptWithResponder(message, responder);
373 } 383 }
(...skipping 20 matching lines...) Expand all
394 return responder->Accept(message); 404 return responder->Accept(message);
395 } else { 405 } else {
396 if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) 406 if (mojo::internal::ControlMessageHandler::IsControlMessage(message))
397 return control_message_handler_.Accept(message); 407 return control_message_handler_.Accept(message);
398 408
399 return incoming_receiver_->Accept(message); 409 return incoming_receiver_->Accept(message);
400 } 410 }
401 } 411 }
402 412
403 } // namespace mojo 413 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698