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

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

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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 (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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/browsing_instance.h" 10 #include "content/browser/browsing_instance.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 int browsing_delete_counter = 0; 197 int browsing_delete_counter = 0;
198 const GURL url("test:foo"); 198 const GURL url("test:foo");
199 199
200 // Ensure that instances are deleted when their NavigationEntries are gone. 200 // Ensure that instances are deleted when their NavigationEntries are gone.
201 TestSiteInstance* instance = 201 TestSiteInstance* instance =
202 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter, 202 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter,
203 &browsing_delete_counter); 203 &browsing_delete_counter);
204 EXPECT_EQ(0, site_delete_counter); 204 EXPECT_EQ(0, site_delete_counter);
205 205
206 NavigationEntryImpl* e1 = new NavigationEntryImpl( 206 NavigationEntryImpl* e1 = new NavigationEntryImpl(
207 instance, 0, url, Referrer(), base::string16(), PAGE_TRANSITION_LINK, 207 instance, 0, url, Referrer(), base::string16(), ui::PAGE_TRANSITION_LINK,
208 false); 208 false);
209 209
210 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. 210 // Redundantly setting e1's SiteInstance shouldn't affect the ref count.
211 e1->set_site_instance(instance); 211 e1->set_site_instance(instance);
212 EXPECT_EQ(0, site_delete_counter); 212 EXPECT_EQ(0, site_delete_counter);
213 213
214 // Add a second reference 214 // Add a second reference
215 NavigationEntryImpl* e2 = new NavigationEntryImpl( 215 NavigationEntryImpl* e2 = new NavigationEntryImpl(
216 instance, 0, url, Referrer(), base::string16(), PAGE_TRANSITION_LINK, 216 instance, 0, url, Referrer(), base::string16(), ui::PAGE_TRANSITION_LINK,
217 false); 217 false);
218 218
219 // Now delete both entries and be sure the SiteInstance goes away. 219 // Now delete both entries and be sure the SiteInstance goes away.
220 delete e1; 220 delete e1;
221 EXPECT_EQ(0, site_delete_counter); 221 EXPECT_EQ(0, site_delete_counter);
222 EXPECT_EQ(0, browsing_delete_counter); 222 EXPECT_EQ(0, browsing_delete_counter);
223 delete e2; 223 delete e2;
224 EXPECT_EQ(1, site_delete_counter); 224 EXPECT_EQ(1, site_delete_counter);
225 // instance is now deleted 225 // instance is now deleted
226 EXPECT_EQ(1, browsing_delete_counter); 226 EXPECT_EQ(1, browsing_delete_counter);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 const GURL url("test:foo"); 259 const GURL url("test:foo");
260 260
261 SiteInstanceImpl* instance1 = 261 SiteInstanceImpl* instance1 =
262 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter1, 262 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter1,
263 &browsing_delete_counter); 263 &browsing_delete_counter);
264 SiteInstanceImpl* instance2 = 264 SiteInstanceImpl* instance2 =
265 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter2, 265 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter2,
266 &browsing_delete_counter); 266 &browsing_delete_counter);
267 267
268 NavigationEntryImpl* e1 = new NavigationEntryImpl( 268 NavigationEntryImpl* e1 = new NavigationEntryImpl(
269 instance1, 0, url, Referrer(), base::string16(), PAGE_TRANSITION_LINK, 269 instance1, 0, url, Referrer(), base::string16(), ui::PAGE_TRANSITION_LINK,
270 false); 270 false);
271 // Clone the entry 271 // Clone the entry
272 NavigationEntryImpl* e2 = new NavigationEntryImpl(*e1); 272 NavigationEntryImpl* e2 = new NavigationEntryImpl(*e1);
273 273
274 // Should be able to change the SiteInstance of the cloned entry. 274 // Should be able to change the SiteInstance of the cloned entry.
275 e2->set_site_instance(instance2); 275 e2->set_site_instance(instance2);
276 276
277 // The first SiteInstance should go away after deleting e1, since e2 should 277 // The first SiteInstance should go away after deleting e1, since e2 should
278 // no longer be referencing it. 278 // no longer be referencing it.
279 delete e1; 279 delete e1;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 EXPECT_TRUE(instance->GetSiteURL().is_empty()); 777 EXPECT_TRUE(instance->GetSiteURL().is_empty());
778 host.reset(instance->GetProcess()); 778 host.reset(instance->GetProcess());
779 779
780 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( 780 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite(
781 browser_context.get(), GURL())); 781 browser_context.get(), GURL()));
782 782
783 DrainMessageLoops(); 783 DrainMessageLoops();
784 } 784 }
785 785
786 } // namespace content 786 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_url_request_job.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698