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

Side by Side Diff: content/shell/browser/layout_test/blink_test_controller.cc

Issue 2955123002: Mojo-ify ShellViewHostMsg_LayoutDumpResponse. (Closed)
Patch Set: Addressed CR feedback from alexmos@. Created 3 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
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 "content/shell/browser/layout_test/blink_test_controller.h" 5 #include "content/shell/browser/layout_test/blink_test_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <iostream> 9 #include <iostream>
10 #include <set> 10 #include <set>
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GetBluetoothManualChooserEvents, 519 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GetBluetoothManualChooserEvents,
520 OnGetBluetoothManualChooserEvents) 520 OnGetBluetoothManualChooserEvents)
521 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SendBluetoothManualChooserEvent, 521 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SendBluetoothManualChooserEvent,
522 OnSendBluetoothManualChooserEvent) 522 OnSendBluetoothManualChooserEvent)
523 IPC_MESSAGE_UNHANDLED(handled = false) 523 IPC_MESSAGE_UNHANDLED(handled = false)
524 IPC_END_MESSAGE_MAP() 524 IPC_END_MESSAGE_MAP()
525 525
526 return handled; 526 return handled;
527 } 527 }
528 528
529 bool BlinkTestController::OnMessageReceived(
530 const IPC::Message& message,
531 RenderFrameHost* render_frame_host) {
532 bool handled = true;
533 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BlinkTestController, message,
534 render_frame_host)
535 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LayoutDumpResponse,
536 OnLayoutDumpResponse)
537 IPC_MESSAGE_UNHANDLED(handled = false)
538 IPC_END_MESSAGE_MAP()
539 return handled;
540 }
541
542 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, 529 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path,
543 base::ProcessId plugin_pid) { 530 base::ProcessId plugin_pid) {
544 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 531 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
545 printer_->AddErrorMessage( 532 printer_->AddErrorMessage(
546 base::StringPrintf("#CRASHED - plugin (pid %d)", plugin_pid)); 533 base::StringPrintf("#CRASHED - plugin (pid %d)", plugin_pid));
547 base::ThreadTaskRunnerHandle::Get()->PostTask( 534 base::ThreadTaskRunnerHandle::Get()->PostTask(
548 FROM_HERE, 535 FROM_HERE,
549 base::Bind(base::IgnoreResult(&BlinkTestController::DiscardMainWindow), 536 base::Bind(base::IgnoreResult(&BlinkTestController::DiscardMainWindow),
550 base::Unretained(this))); 537 base::Unretained(this)));
551 } 538 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 printer_->PrintTextFooter(); 771 printer_->PrintTextFooter();
785 } 772 }
786 773
787 void BlinkTestController::OnInitiateLayoutDump() { 774 void BlinkTestController::OnInitiateLayoutDump() {
788 int number_of_messages = 0; 775 int number_of_messages = 0;
789 for (RenderFrameHost* rfh : main_window_->web_contents()->GetAllFrames()) { 776 for (RenderFrameHost* rfh : main_window_->web_contents()->GetAllFrames()) {
790 if (!rfh->IsRenderFrameLive()) 777 if (!rfh->IsRenderFrameLive())
791 continue; 778 continue;
792 779
793 ++number_of_messages; 780 ++number_of_messages;
794 GetLayoutTestControlPtr(rfh)->LayoutDumpRequest(); 781 GetLayoutTestControlPtr(rfh)->DumpFrameLayout(
782 base::Bind(&BlinkTestController::OnDumpFrameLayoutResponse,
783 base::Unretained(this), rfh->GetFrameTreeNodeId()));
795 } 784 }
796 785
797 pending_layout_dumps_ = number_of_messages; 786 pending_layout_dumps_ = number_of_messages;
798 } 787 }
799 788
800 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( 789 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged(
801 int sender_process_host_id, 790 int sender_process_host_id,
802 const base::DictionaryValue& changed_layout_test_runtime_flags) { 791 const base::DictionaryValue& changed_layout_test_runtime_flags) {
803 // Stash the accumulated changes for future, not-yet-created renderers. 792 // Stash the accumulated changes for future, not-yet-created renderers.
804 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( 793 accumulated_layout_test_runtime_flags_changes_.MergeDictionary(
805 &changed_layout_test_runtime_flags); 794 &changed_layout_test_runtime_flags);
806 795
807 // Propagate the changes to all the tracked renderer processes. 796 // Propagate the changes to all the tracked renderer processes.
808 for (RenderProcessHost* process : all_observed_render_process_hosts_) { 797 for (RenderProcessHost* process : all_observed_render_process_hosts_) {
809 // Do not propagate the changes back to the process that originated them. 798 // Do not propagate the changes back to the process that originated them.
810 // (propagating them back could also clobber subsequent changes in the 799 // (propagating them back could also clobber subsequent changes in the
811 // originator). 800 // originator).
812 if (process->GetID() == sender_process_host_id) 801 if (process->GetID() == sender_process_host_id)
813 continue; 802 continue;
814 803
815 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( 804 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges(
816 changed_layout_test_runtime_flags)); 805 changed_layout_test_runtime_flags));
817 } 806 }
818 } 807 }
819 808
820 void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender, 809 void BlinkTestController::OnDumpFrameLayoutResponse(int frame_tree_node_id,
821 const std::string& dump) { 810 const std::string& dump) {
822 // Store the result. 811 // Store the result.
823 auto pair = frame_to_layout_dump_map_.insert( 812 auto pair = frame_to_layout_dump_map_.insert(
824 std::make_pair(sender->GetFrameTreeNodeId(), dump)); 813 std::make_pair(frame_tree_node_id, dump));
825 bool insertion_took_place = pair.second; 814 bool insertion_took_place = pair.second;
826 DCHECK(insertion_took_place); 815 DCHECK(insertion_took_place);
827 816
828 // See if we need to wait for more responses. 817 // See if we need to wait for more responses.
829 pending_layout_dumps_--; 818 pending_layout_dumps_--;
830 DCHECK_LE(0, pending_layout_dumps_); 819 DCHECK_LE(0, pending_layout_dumps_);
831 if (pending_layout_dumps_ > 0) 820 if (pending_layout_dumps_ > 0)
832 return; 821 return;
833 822
834 // Stitch the frame-specific results in the right order. 823 // Stitch the frame-specific results in the right order.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 } 1045 }
1057 DCHECK(layout_test_control_map_[frame].get()); 1046 DCHECK(layout_test_control_map_[frame].get());
1058 return layout_test_control_map_[frame].get(); 1047 return layout_test_control_map_[frame].get();
1059 } 1048 }
1060 1049
1061 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { 1050 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) {
1062 layout_test_control_map_.erase(frame); 1051 layout_test_control_map_.erase(frame);
1063 } 1052 }
1064 1053
1065 } // namespace content 1054 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/blink_test_controller.h ('k') | content/shell/common/layout_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698