| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 std::find(expected_titles_.begin(), | 575 std::find(expected_titles_.begin(), |
| 576 expected_titles_.end(), | 576 expected_titles_.end(), |
| 577 web_contents()->GetTitle()); | 577 web_contents()->GetTitle()); |
| 578 if (it == expected_titles_.end()) | 578 if (it == expected_titles_.end()) |
| 579 return; | 579 return; |
| 580 | 580 |
| 581 observed_title_ = *it; | 581 observed_title_ = *it; |
| 582 message_loop_runner_->Quit(); | 582 message_loop_runner_->Quit(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 WebContentsDestroyedWatcher::WebContentsDestroyedWatcher( |
| 586 WebContents* web_contents) |
| 587 : WebContentsObserver(web_contents), |
| 588 message_loop_runner_(new MessageLoopRunner) { |
| 589 EXPECT_TRUE(web_contents != NULL); |
| 590 } |
| 591 |
| 592 WebContentsDestroyedWatcher::~WebContentsDestroyedWatcher() { |
| 593 } |
| 594 |
| 595 void WebContentsDestroyedWatcher::Wait() { |
| 596 message_loop_runner_->Run(); |
| 597 } |
| 598 |
| 599 void WebContentsDestroyedWatcher::WebContentsDestroyed( |
| 600 WebContents* web_contents) { |
| 601 message_loop_runner_->Quit(); |
| 602 } |
| 603 |
| 585 DOMMessageQueue::DOMMessageQueue() : waiting_for_message_(false) { | 604 DOMMessageQueue::DOMMessageQueue() : waiting_for_message_(false) { |
| 586 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, | 605 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 587 NotificationService::AllSources()); | 606 NotificationService::AllSources()); |
| 588 } | 607 } |
| 589 | 608 |
| 590 DOMMessageQueue::~DOMMessageQueue() {} | 609 DOMMessageQueue::~DOMMessageQueue() {} |
| 591 | 610 |
| 592 void DOMMessageQueue::Observe(int type, | 611 void DOMMessageQueue::Observe(int type, |
| 593 const NotificationSource& source, | 612 const NotificationSource& source, |
| 594 const NotificationDetails& details) { | 613 const NotificationDetails& details) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 615 // The queue should not be empty, unless we were quit because of a timeout. | 634 // The queue should not be empty, unless we were quit because of a timeout. |
| 616 if (message_queue_.empty()) | 635 if (message_queue_.empty()) |
| 617 return false; | 636 return false; |
| 618 if (message) | 637 if (message) |
| 619 *message = message_queue_.front(); | 638 *message = message_queue_.front(); |
| 620 message_queue_.pop(); | 639 message_queue_.pop(); |
| 621 return true; | 640 return true; |
| 622 } | 641 } |
| 623 | 642 |
| 624 } // namespace content | 643 } // namespace content |
| OLD | NEW |