| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 return false; | 1060 return false; |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 bool RequestFrame(WebContents* web_contents) { | 1063 bool RequestFrame(WebContents* web_contents) { |
| 1064 DCHECK(web_contents); | 1064 DCHECK(web_contents); |
| 1065 return RenderWidgetHostImpl::From( | 1065 return RenderWidgetHostImpl::From( |
| 1066 web_contents->GetRenderViewHost()->GetWidget()) | 1066 web_contents->GetRenderViewHost()->GetWidget()) |
| 1067 ->ScheduleComposite(); | 1067 ->ScheduleComposite(); |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 FrameWatcher::FrameWatcher() | 1070 FrameWatcher::FrameWatcher() : MessageFilter(), frames_to_wait_(0) {} |
| 1071 : BrowserMessageFilter(ViewMsgStart), frames_to_wait_(0) { | |
| 1072 } | |
| 1073 | 1071 |
| 1074 FrameWatcher::~FrameWatcher() { | 1072 FrameWatcher::~FrameWatcher() { |
| 1075 } | 1073 } |
| 1076 | 1074 |
| 1077 void FrameWatcher::ReceivedFrameSwap(cc::CompositorFrameMetadata metadata) { | 1075 void FrameWatcher::ReceivedFrameSwap(cc::CompositorFrameMetadata metadata) { |
| 1078 --frames_to_wait_; | 1076 --frames_to_wait_; |
| 1079 last_metadata_ = metadata; | 1077 last_metadata_ = metadata; |
| 1080 if (frames_to_wait_ == 0) | 1078 if (frames_to_wait_ == 0) |
| 1081 quit_.Run(); | 1079 quit_.Run(); |
| 1082 } | 1080 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1093 BrowserThread::UI, FROM_HERE, | 1091 BrowserThread::UI, FROM_HERE, |
| 1094 base::Bind(&FrameWatcher::ReceivedFrameSwap, this, frame->metadata)); | 1092 base::Bind(&FrameWatcher::ReceivedFrameSwap, this, frame->metadata)); |
| 1095 } | 1093 } |
| 1096 return false; | 1094 return false; |
| 1097 } | 1095 } |
| 1098 | 1096 |
| 1099 void FrameWatcher::AttachTo(WebContents* web_contents) { | 1097 void FrameWatcher::AttachTo(WebContents* web_contents) { |
| 1100 DCHECK(web_contents); | 1098 DCHECK(web_contents); |
| 1101 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( | 1099 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( |
| 1102 web_contents->GetRenderViewHost()->GetWidget()); | 1100 web_contents->GetRenderViewHost()->GetWidget()); |
| 1103 widget_host->GetProcess()->AddFilter(this); | 1101 widget_host->GetProcess()->GetChannel()->AddFilter(this); |
| 1104 } | 1102 } |
| 1105 | 1103 |
| 1106 void FrameWatcher::WaitFrames(int frames_to_wait) { | 1104 void FrameWatcher::WaitFrames(int frames_to_wait) { |
| 1107 if (frames_to_wait <= 0) | 1105 if (frames_to_wait <= 0) |
| 1108 return; | 1106 return; |
| 1109 base::RunLoop run_loop; | 1107 base::RunLoop run_loop; |
| 1110 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1108 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
| 1111 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 1109 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
| 1112 run_loop.Run(); | 1110 run_loop.Run(); |
| 1113 } | 1111 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1189 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1192 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) | 1190 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) |
| 1193 return ack_result_; | 1191 return ack_result_; |
| 1194 base::RunLoop run_loop; | 1192 base::RunLoop run_loop; |
| 1195 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1193 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
| 1196 run_loop.Run(); | 1194 run_loop.Run(); |
| 1197 return ack_result_; | 1195 return ack_result_; |
| 1198 } | 1196 } |
| 1199 | 1197 |
| 1200 } // namespace content | 1198 } // namespace content |
| OLD | NEW |