Chromium Code Reviews| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1006 | 1006 |
| 1007 void FrameWatcher::WaitFrames(int frames_to_wait) { | 1007 void FrameWatcher::WaitFrames(int frames_to_wait) { |
| 1008 if (frames_to_wait <= 0) | 1008 if (frames_to_wait <= 0) |
| 1009 return; | 1009 return; |
| 1010 base::RunLoop run_loop; | 1010 base::RunLoop run_loop; |
| 1011 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1011 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
| 1012 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 1012 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
| 1013 run_loop.Run(); | 1013 run_loop.Run(); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 RenderViewHostDeletedObserver::RenderViewHostDeletedObserver( | |
| 1017 RenderViewHost* rvh) | |
| 1018 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)), | |
| 1019 process_id_(rvh->GetProcess()->GetID()), | |
| 1020 routing_id_(rvh->GetRoutingID()), | |
| 1021 deleted_(false) { | |
| 1022 } | |
| 1023 | |
| 1024 RenderViewHostDeletedObserver::~RenderViewHostDeletedObserver() { | |
| 1025 } | |
| 1026 | |
| 1027 void RenderViewHostDeletedObserver::RenderViewDeleted( | |
| 1028 RenderViewHost* render_view_host) { | |
| 1029 if (render_view_host->GetProcess()->GetID() == process_id_ && | |
| 1030 render_view_host->GetRoutingID() == routing_id_) { | |
| 1031 deleted_ = true; | |
| 1032 | |
| 1033 if (runner_.get()) { | |
| 1034 runner_->Quit(); | |
| 1035 runner_.reset(nullptr); | |
|
nasko
2015/06/26 11:46:11
Do you really need to delete the RunLoop object? I
lfg
2015/06/26 16:49:39
Good catch, this is a bug. Fixed.
| |
| 1036 } | |
| 1037 } | |
| 1038 } | |
| 1039 | |
| 1040 bool RenderViewHostDeletedObserver::deleted() { | |
| 1041 return deleted_; | |
| 1042 } | |
| 1043 | |
| 1044 void RenderViewHostDeletedObserver::WaitUntilDeleted() { | |
| 1045 if (deleted_) | |
| 1046 return; | |
| 1047 | |
| 1048 runner_.reset(new base::RunLoop()); | |
| 1049 runner_->Run(); | |
| 1050 } | |
| 1051 | |
| 1052 RenderFrameHostDeletedObserver::RenderFrameHostDeletedObserver( | |
| 1053 RenderFrameHost* rfh) | |
| 1054 : WebContentsObserver(WebContents::FromRenderFrameHost(rfh)), | |
| 1055 process_id_(rfh->GetProcess()->GetID()), | |
| 1056 routing_id_(rfh->GetRoutingID()), | |
| 1057 deleted_(false) { | |
| 1058 } | |
| 1059 | |
| 1060 RenderFrameHostDeletedObserver::~RenderFrameHostDeletedObserver() { | |
| 1061 } | |
| 1062 | |
| 1063 void RenderFrameHostDeletedObserver::RenderFrameDeleted( | |
| 1064 RenderFrameHost* render_frame_host) { | |
| 1065 if (render_frame_host->GetProcess()->GetID() == process_id_ && | |
| 1066 render_frame_host->GetRoutingID() == routing_id_) { | |
| 1067 deleted_ = true; | |
| 1068 | |
| 1069 if (runner_.get()) | |
| 1070 runner_->Quit(); | |
|
nasko
2015/06/26 11:46:11
Why the inconsistency between the two classes? The
lfg
2015/06/26 16:49:39
I had fixed this one before, but not the other sin
nasko
2015/06/29 08:22:09
Yes, we should only expose code that is needed. Al
| |
| 1071 } | |
| 1072 } | |
| 1073 | |
| 1074 bool RenderFrameHostDeletedObserver::deleted() { | |
| 1075 return deleted_; | |
| 1076 } | |
| 1077 | |
| 1078 void RenderFrameHostDeletedObserver::WaitUntilDeleted() { | |
| 1079 if (deleted_) | |
| 1080 return; | |
| 1081 | |
| 1082 runner_.reset(new base::RunLoop()); | |
| 1083 runner_->Run(); | |
| 1084 runner_.reset(nullptr); | |
| 1085 } | |
| 1086 | |
| 1016 } // namespace content | 1087 } // namespace content |
| OLD | NEW |