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

Side by Side Diff: content/browser/site_instance_unittest.cc

Issue 8806011: Make NavigationEntry and friends use content::Referrer instead of plain URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "content/browser/browsing_instance.h" 9 #include "content/browser/browsing_instance.h"
10 #include "content/browser/child_process_security_policy.h" 10 #include "content/browser/child_process_security_policy.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 int siteDeleteCounter = 0; 166 int siteDeleteCounter = 0;
167 int browsingDeleteCounter = 0; 167 int browsingDeleteCounter = 0;
168 const GURL url("test:foo"); 168 const GURL url("test:foo");
169 169
170 // Ensure that instances are deleted when their NavigationEntries are gone. 170 // Ensure that instances are deleted when their NavigationEntries are gone.
171 TestSiteInstance* instance = 171 TestSiteInstance* instance =
172 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter, 172 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter,
173 &browsingDeleteCounter); 173 &browsingDeleteCounter);
174 EXPECT_EQ(0, siteDeleteCounter); 174 EXPECT_EQ(0, siteDeleteCounter);
175 175
176 NavigationEntry* e1 = new NavigationEntry(instance, 0, url, GURL(), 176 NavigationEntry* e1 = new NavigationEntry(instance, 0, url,
177 content::Referrer(),
177 string16(), 178 string16(),
178 content::PAGE_TRANSITION_LINK, 179 content::PAGE_TRANSITION_LINK,
179 false); 180 false);
180 181
181 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. 182 // Redundantly setting e1's SiteInstance shouldn't affect the ref count.
182 e1->set_site_instance(instance); 183 e1->set_site_instance(instance);
183 EXPECT_EQ(0, siteDeleteCounter); 184 EXPECT_EQ(0, siteDeleteCounter);
184 185
185 // Add a second reference 186 // Add a second reference
186 NavigationEntry* e2 = new NavigationEntry(instance, 0, url, 187 NavigationEntry* e2 = new NavigationEntry(instance, 0, url,
187 GURL(), string16(), 188 content::Referrer(), string16(),
188 content::PAGE_TRANSITION_LINK, 189 content::PAGE_TRANSITION_LINK,
189 false); 190 false);
190 191
191 // Now delete both entries and be sure the SiteInstance goes away. 192 // Now delete both entries and be sure the SiteInstance goes away.
192 delete e1; 193 delete e1;
193 EXPECT_EQ(0, siteDeleteCounter); 194 EXPECT_EQ(0, siteDeleteCounter);
194 EXPECT_EQ(0, browsingDeleteCounter); 195 EXPECT_EQ(0, browsingDeleteCounter);
195 delete e2; 196 delete e2;
196 EXPECT_EQ(1, siteDeleteCounter); 197 EXPECT_EQ(1, siteDeleteCounter);
197 // instance is now deleted 198 // instance is now deleted
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 int browsingDeleteCounter = 0; 233 int browsingDeleteCounter = 0;
233 const GURL url("test:foo"); 234 const GURL url("test:foo");
234 235
235 SiteInstance* instance1 = 236 SiteInstance* instance1 =
236 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1, 237 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1,
237 &browsingDeleteCounter); 238 &browsingDeleteCounter);
238 SiteInstance* instance2 = 239 SiteInstance* instance2 =
239 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, 240 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2,
240 &browsingDeleteCounter); 241 &browsingDeleteCounter);
241 242
242 NavigationEntry* e1 = new NavigationEntry(instance1, 0, url, GURL(), 243 NavigationEntry* e1 = new NavigationEntry(instance1, 0, url,
243 string16(), 244 content::Referrer(), string16(),
244 content::PAGE_TRANSITION_LINK, 245 content::PAGE_TRANSITION_LINK,
245 false); 246 false);
246 // Clone the entry 247 // Clone the entry
247 NavigationEntry* e2 = new NavigationEntry(*e1); 248 NavigationEntry* e2 = new NavigationEntry(*e1);
248 249
249 // Should be able to change the SiteInstance of the cloned entry. 250 // Should be able to change the SiteInstance of the cloned entry.
250 e2->set_site_instance(instance2); 251 e2->set_site_instance(instance2);
251 252
252 // The first SiteInstance should go away after deleting e1, since e2 should 253 // The first SiteInstance should go away after deleting e1, since e2 should
253 // no longer be referencing it. 254 // no longer be referencing it.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // Make sure none of differing privilege processes are mixed. 548 // Make sure none of differing privilege processes are mixed.
548 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); 549 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess());
549 550
550 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { 551 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) {
551 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); 552 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]);
552 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); 553 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]);
553 } 554 }
554 555
555 STLDeleteContainerPointers(hosts.begin(), hosts.end()); 556 STLDeleteContainerPointers(hosts.begin(), hosts.end());
556 } 557 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc ('k') | content/browser/tab_contents/navigation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698