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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, | 68 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 69 Source<WebContents>(web_contents())); | 69 Source<WebContents>(web_contents())); |
| 70 message_loop_runner_ = new MessageLoopRunner; | 70 message_loop_runner_ = new MessageLoopRunner; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void Observe(int type, | 73 void Observe(int type, |
| 74 const NotificationSource& source, | 74 const NotificationSource& source, |
| 75 const NotificationDetails& details) override { | 75 const NotificationDetails& details) override { |
| 76 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE); | 76 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE); |
| 77 Details<DomOperationNotificationDetails> dom_op_details(details); | 77 Details<DomOperationNotificationDetails> dom_op_details(details); |
| 78 response_ = dom_op_details->json; | 78 if (!did_respond_) { |
|
Charlie Reis
2015/08/14 22:54:13
I'm a bit concerned about this one, but partly bec
alexmos
2015/08/14 23:51:32
Yes, it definitely continues to process any messag
Charlie Reis
2015/08/15 00:09:50
Ok, sounds good.
| |
| 79 did_respond_ = true; | 79 response_ = dom_op_details->json; |
| 80 message_loop_runner_->Quit(); | 80 did_respond_ = true; |
| 81 message_loop_runner_->Quit(); | |
| 82 } | |
| 81 } | 83 } |
| 82 | 84 |
| 83 // Overridden from WebContentsObserver: | 85 // Overridden from WebContentsObserver: |
| 84 void RenderProcessGone(base::TerminationStatus status) override { | 86 void RenderProcessGone(base::TerminationStatus status) override { |
| 85 message_loop_runner_->Quit(); | 87 message_loop_runner_->Quit(); |
| 86 } | 88 } |
| 87 | 89 |
| 88 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT { | 90 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT { |
| 89 message_loop_runner_->Run(); | 91 message_loop_runner_->Run(); |
| 90 *response = response_; | 92 *response = response_; |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 void FrameWatcher::WaitFrames(int frames_to_wait) { | 987 void FrameWatcher::WaitFrames(int frames_to_wait) { |
| 986 if (frames_to_wait <= 0) | 988 if (frames_to_wait <= 0) |
| 987 return; | 989 return; |
| 988 base::RunLoop run_loop; | 990 base::RunLoop run_loop; |
| 989 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 991 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
| 990 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 992 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
| 991 run_loop.Run(); | 993 run_loop.Run(); |
| 992 } | 994 } |
| 993 | 995 |
| 994 } // namespace content | 996 } // namespace content |
| OLD | NEW |