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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 explicit DOMOperationObserver(RenderViewHost* rvh) | 60 explicit DOMOperationObserver(RenderViewHost* rvh) |
61 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)), | 61 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)), |
62 did_respond_(false) { | 62 did_respond_(false) { |
63 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, | 63 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, |
64 Source<WebContents>(web_contents())); | 64 Source<WebContents>(web_contents())); |
65 message_loop_runner_ = new MessageLoopRunner; | 65 message_loop_runner_ = new MessageLoopRunner; |
66 } | 66 } |
67 | 67 |
68 virtual void Observe(int type, | 68 virtual void Observe(int type, |
69 const NotificationSource& source, | 69 const NotificationSource& source, |
70 const NotificationDetails& details) OVERRIDE { | 70 const NotificationDetails& details) override { |
71 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE); | 71 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE); |
72 Details<DomOperationNotificationDetails> dom_op_details(details); | 72 Details<DomOperationNotificationDetails> dom_op_details(details); |
73 response_ = dom_op_details->json; | 73 response_ = dom_op_details->json; |
74 did_respond_ = true; | 74 did_respond_ = true; |
75 message_loop_runner_->Quit(); | 75 message_loop_runner_->Quit(); |
76 } | 76 } |
77 | 77 |
78 // Overridden from WebContentsObserver: | 78 // Overridden from WebContentsObserver: |
79 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE { | 79 virtual void RenderProcessGone(base::TerminationStatus status) override { |
80 message_loop_runner_->Quit(); | 80 message_loop_runner_->Quit(); |
81 } | 81 } |
82 | 82 |
83 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT { | 83 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT { |
84 message_loop_runner_->Run(); | 84 message_loop_runner_->Run(); |
85 *response = response_; | 85 *response = response_; |
86 return did_respond_; | 86 return did_respond_; |
87 } | 87 } |
88 | 88 |
89 private: | 89 private: |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 } | 769 } |
770 // The queue should not be empty, unless we were quit because of a timeout. | 770 // The queue should not be empty, unless we were quit because of a timeout. |
771 if (message_queue_.empty()) | 771 if (message_queue_.empty()) |
772 return false; | 772 return false; |
773 *message = message_queue_.front(); | 773 *message = message_queue_.front(); |
774 message_queue_.pop(); | 774 message_queue_.pop(); |
775 return true; | 775 return true; |
776 } | 776 } |
777 | 777 |
778 } // namespace content | 778 } // namespace content |
OLD | NEW |