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

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

Issue 2035893003: Fix some MultiplexRouter behavior for sync messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/lib/multiplex_router.h" 5 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 return; 587 return;
588 588
589 while (!tasks_.empty()) { 589 while (!tasks_.empty()) {
590 std::unique_ptr<Task> task(std::move(tasks_.front())); 590 std::unique_ptr<Task> task(std::move(tasks_.front()));
591 tasks_.pop_front(); 591 tasks_.pop_front();
592 592
593 InterfaceId id = kInvalidInterfaceId; 593 InterfaceId id = kInvalidInterfaceId;
594 bool sync_message = task->IsMessageTask() && task->message && 594 bool sync_message = task->IsMessageTask() && task->message &&
595 task->message->has_flag(kMessageIsSync); 595 task->message->has_flag(kMessageIsSync);
596 if (sync_message) { 596 if (sync_message) {
597 InterfaceId id = task->message->interface_id(); 597 id = task->message->interface_id();
598 auto& sync_message_queue = sync_message_tasks_[id]; 598 auto& sync_message_queue = sync_message_tasks_[id];
599 DCHECK_EQ(task.get(), sync_message_queue.front()); 599 DCHECK_EQ(task.get(), sync_message_queue.front());
600 sync_message_queue.pop_front(); 600 sync_message_queue.pop_front();
601 } 601 }
602 602
603 bool processed = 603 bool processed =
604 task->IsNotifyErrorTask() 604 task->IsNotifyErrorTask()
605 ? ProcessNotifyErrorTask(task.get(), client_call_behavior, 605 ? ProcessNotifyErrorTask(task.get(), client_call_behavior,
606 current_task_runner) 606 current_task_runner)
607 : ProcessIncomingMessage(task->message.get(), client_call_behavior, 607 : ProcessIncomingMessage(task->message.get(), client_call_behavior,
608 current_task_runner); 608 current_task_runner);
609 609
610 if (!processed) { 610 if (!processed) {
611 tasks_.push_front(std::move(task));
612 if (sync_message) { 611 if (sync_message) {
613 auto& sync_message_queue = sync_message_tasks_[id]; 612 auto& sync_message_queue = sync_message_tasks_[id];
614 sync_message_queue.push_front(task.get()); 613 sync_message_queue.push_front(task.get());
615 } 614 }
615 tasks_.push_front(std::move(task));
616 break; 616 break;
617 } else { 617 } else {
618 if (sync_message) { 618 if (sync_message) {
619 auto iter = sync_message_tasks_.find(id); 619 auto iter = sync_message_tasks_.find(id);
620 if (iter != sync_message_tasks_.end() && iter->second.empty()) 620 if (iter != sync_message_tasks_.end() && iter->second.empty())
621 sync_message_tasks_.erase(iter); 621 sync_message_tasks_.erase(iter);
622 } 622 }
623 } 623 }
624 } 624 }
625 } 625 }
(...skipping 10 matching lines...) Expand all
636 636
637 DCHECK(task->IsMessageTask()); 637 DCHECK(task->IsMessageTask());
638 std::unique_ptr<Message> message(std::move(task->message)); 638 std::unique_ptr<Message> message(std::move(task->message));
639 639
640 // Note: after this call, |task| and |iter| may be invalidated. 640 // Note: after this call, |task| and |iter| may be invalidated.
641 bool processed = ProcessIncomingMessage( 641 bool processed = ProcessIncomingMessage(
642 message.get(), ALLOW_DIRECT_CLIENT_CALLS_FOR_SYNC_MESSAGES, nullptr); 642 message.get(), ALLOW_DIRECT_CLIENT_CALLS_FOR_SYNC_MESSAGES, nullptr);
643 DCHECK(processed); 643 DCHECK(processed);
644 644
645 iter = sync_message_tasks_.find(id); 645 iter = sync_message_tasks_.find(id);
646 return iter != sync_message_tasks_.end() && !iter->second.empty(); 646 if (iter == sync_message_tasks_.end())
647 return false;
648
649 if (iter->second.empty()) {
650 sync_message_tasks_.erase(iter);
651 return false;
652 }
653
654 return true;
647 } 655 }
648 656
649 bool MultiplexRouter::ProcessNotifyErrorTask( 657 bool MultiplexRouter::ProcessNotifyErrorTask(
650 Task* task, 658 Task* task,
651 ClientCallBehavior client_call_behavior, 659 ClientCallBehavior client_call_behavior,
652 base::SingleThreadTaskRunner* current_task_runner) { 660 base::SingleThreadTaskRunner* current_task_runner) {
653 DCHECK(!current_task_runner || current_task_runner->BelongsToCurrentThread()); 661 DCHECK(!current_task_runner || current_task_runner->BelongsToCurrentThread());
654 lock_.AssertAcquired(); 662 lock_.AssertAcquired();
655 InterfaceEndpoint* endpoint = task->endpoint_to_notify.get(); 663 InterfaceEndpoint* endpoint = task->endpoint_to_notify.get();
656 if (!endpoint->client()) 664 if (!endpoint->client())
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 *inserted = true; 829 *inserted = true;
822 } else { 830 } else {
823 endpoint = iter->second.get(); 831 endpoint = iter->second.get();
824 } 832 }
825 833
826 return endpoint; 834 return endpoint;
827 } 835 }
828 836
829 } // namespace internal 837 } // namespace internal
830 } // namespace mojo 838 } // 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