Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: components/guest_view/browser/test_guest_view_manager.cc

Issue 1237343002: Fix nested GuestView's container bounds calculation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix type mismatch for win_x64 compile Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/guest_view/browser/test_guest_view_manager.h" 5 #include "components/guest_view/browser/test_guest_view_manager.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "components/guest_view/browser/guest_view_manager_delegate.h" 8 #include "components/guest_view/browser/guest_view_manager_delegate.h"
9 9
10 namespace guest_view { 10 namespace guest_view {
11 11
12 TestGuestViewManager::TestGuestViewManager( 12 TestGuestViewManager::TestGuestViewManager(
13 content::BrowserContext* context, 13 content::BrowserContext* context,
14 scoped_ptr<GuestViewManagerDelegate> delegate) 14 scoped_ptr<GuestViewManagerDelegate> delegate)
15 : GuestViewManager(context, delegate.Pass()), 15 : GuestViewManager(context, delegate.Pass()),
16 num_embedder_processes_destroyed_(0), 16 num_embedder_processes_destroyed_(0),
17 num_guests_created_(0), 17 num_guests_created_(0),
18 num_views_garbage_collected_(0) { 18 expected_num_guests_created_(0),
19 num_views_garbage_collected_(0),
20 waiting_for_guests_created_(false) {
19 } 21 }
20 22
21 TestGuestViewManager::~TestGuestViewManager() { 23 TestGuestViewManager::~TestGuestViewManager() {
22 } 24 }
23 25
24 size_t TestGuestViewManager::GetNumGuestsActive() const { 26 size_t TestGuestViewManager::GetNumGuestsActive() const {
25 return guest_web_contents_by_instance_id_.size(); 27 return guest_web_contents_by_instance_id_.size();
26 } 28 }
27 29
28 size_t TestGuestViewManager::GetNumRemovedInstanceIDs() const { 30 size_t TestGuestViewManager::GetNumRemovedInstanceIDs() const {
(...skipping 15 matching lines...) Expand all
44 // Make sure that every guest that was created has been removed. 46 // Make sure that every guest that was created has been removed.
45 for (auto& watcher : guest_web_contents_watchers_) 47 for (auto& watcher : guest_web_contents_watchers_)
46 watcher->Wait(); 48 watcher->Wait();
47 } 49 }
48 50
49 void TestGuestViewManager::WaitForLastGuestDeleted() { 51 void TestGuestViewManager::WaitForLastGuestDeleted() {
50 // Wait for the last guest that was created to be deleted. 52 // Wait for the last guest that was created to be deleted.
51 guest_web_contents_watchers_.back()->Wait(); 53 guest_web_contents_watchers_.back()->Wait();
52 }; 54 };
53 55
54 void TestGuestViewManager::WaitForGuestCreated() {
55 created_message_loop_runner_ = new content::MessageLoopRunner;
56 created_message_loop_runner_->Run();
57 }
58
59 content::WebContents* TestGuestViewManager::WaitForSingleGuestCreated() { 56 content::WebContents* TestGuestViewManager::WaitForSingleGuestCreated() {
60 if (!GetNumGuestsActive()) { 57 if (!GetNumGuestsActive()) {
61 // Guests have been created and subsequently destroyed. 58 // Guests have been created and subsequently destroyed.
62 if (num_guests_created() > 0) 59 if (num_guests_created() > 0)
63 return nullptr; 60 return nullptr;
64 WaitForGuestCreated(); 61 WaitForNumGuestsCreated(1u);
65 } 62 }
66 63
67 return GetLastGuestCreated(); 64 return GetLastGuestCreated();
68 } 65 }
69 66
67 void TestGuestViewManager::WaitForNumGuestsCreated(size_t count) {
68 if (count == num_guests_created_)
69 return;
70
71 waiting_for_guests_created_ = true;
72 expected_num_guests_created_ = count;
73
74 created_message_loop_runner_ = new content::MessageLoopRunner;
75 created_message_loop_runner_->Run();
76 }
77
70 void TestGuestViewManager::WaitForViewGarbageCollected() { 78 void TestGuestViewManager::WaitForViewGarbageCollected() {
71 gc_message_loop_runner_ = new content::MessageLoopRunner; 79 gc_message_loop_runner_ = new content::MessageLoopRunner;
72 gc_message_loop_runner_->Run(); 80 gc_message_loop_runner_->Run();
73 } 81 }
74 82
75 void TestGuestViewManager::WaitForSingleViewGarbageCollected() { 83 void TestGuestViewManager::WaitForSingleViewGarbageCollected() {
76 if (!num_views_garbage_collected()) 84 if (!num_views_garbage_collected())
77 WaitForViewGarbageCollected(); 85 WaitForViewGarbageCollected();
78 } 86 }
79 87
80 void TestGuestViewManager::AddGuest(int guest_instance_id, 88 void TestGuestViewManager::AddGuest(int guest_instance_id,
81 content::WebContents* guest_web_contents) { 89 content::WebContents* guest_web_contents) {
82 GuestViewManager::AddGuest(guest_instance_id, guest_web_contents); 90 GuestViewManager::AddGuest(guest_instance_id, guest_web_contents);
83 91
84 guest_web_contents_watchers_.push_back( 92 guest_web_contents_watchers_.push_back(
85 linked_ptr<content::WebContentsDestroyedWatcher>( 93 linked_ptr<content::WebContentsDestroyedWatcher>(
86 new content::WebContentsDestroyedWatcher(guest_web_contents))); 94 new content::WebContentsDestroyedWatcher(guest_web_contents)));
87 95
88 ++num_guests_created_; 96 ++num_guests_created_;
97 if (!waiting_for_guests_created_ &&
98 num_guests_created_ != expected_num_guests_created_) {
99 return;
100 }
89 101
90 if (created_message_loop_runner_.get()) 102 if (created_message_loop_runner_.get())
91 created_message_loop_runner_->Quit(); 103 created_message_loop_runner_->Quit();
92 } 104 }
93 105
106 void TestGuestViewManager::GetGuestWebContentsList(
107 std::vector<content::WebContents*>* guest_web_contents_list) {
108 for (auto& watcher : guest_web_contents_watchers_)
109 guest_web_contents_list->push_back(watcher->web_contents());
110 }
111
94 void TestGuestViewManager::RemoveGuest(int guest_instance_id) { 112 void TestGuestViewManager::RemoveGuest(int guest_instance_id) {
95 GuestViewManager::RemoveGuest(guest_instance_id); 113 GuestViewManager::RemoveGuest(guest_instance_id);
96 } 114 }
97 115
98 void TestGuestViewManager::EmbedderWillBeDestroyed(int embedder_process_id) { 116 void TestGuestViewManager::EmbedderWillBeDestroyed(int embedder_process_id) {
99 ++num_embedder_processes_destroyed_; 117 ++num_embedder_processes_destroyed_;
100 GuestViewManager::EmbedderWillBeDestroyed(embedder_process_id); 118 GuestViewManager::EmbedderWillBeDestroyed(embedder_process_id);
101 } 119 }
102 120
103 void TestGuestViewManager::ViewGarbageCollected(int embedder_process_id, 121 void TestGuestViewManager::ViewGarbageCollected(int embedder_process_id,
(...skipping 16 matching lines...) Expand all
120 content::BrowserContext* context, 138 content::BrowserContext* context,
121 scoped_ptr<GuestViewManagerDelegate> delegate) { 139 scoped_ptr<GuestViewManagerDelegate> delegate) {
122 if (!test_guest_view_manager_) { 140 if (!test_guest_view_manager_) {
123 test_guest_view_manager_ = 141 test_guest_view_manager_ =
124 new TestGuestViewManager(context, delegate.Pass()); 142 new TestGuestViewManager(context, delegate.Pass());
125 } 143 }
126 return test_guest_view_manager_; 144 return test_guest_view_manager_;
127 } 145 }
128 146
129 } // namespace guest_view 147 } // namespace guest_view
OLDNEW
« no previous file with comments | « components/guest_view/browser/test_guest_view_manager.h ('k') | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698