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

Side by Side Diff: third_party/WebKit/Source/core/loader/NavigationScheduler.cpp

Issue 1962053002: Allow expensive task blocking if there is pending iframe navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use an enum Created 4 years, 7 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2009 Adam Barth. All rights reserved. 5 * Copyright (C) 2009 Adam Barth. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 { 251 {
252 ASSERT(m_submission->form()); 252 ASSERT(m_submission->form());
253 } 253 }
254 254
255 Member<FormSubmission> m_submission; 255 Member<FormSubmission> m_submission;
256 }; 256 };
257 257
258 NavigationScheduler::NavigationScheduler(LocalFrame* frame) 258 NavigationScheduler::NavigationScheduler(LocalFrame* frame)
259 : m_frame(frame) 259 : m_frame(frame)
260 , m_navigateTaskFactory(CancellableTaskFactory::create(this, &NavigationSche duler::navigateTask)) 260 , m_navigateTaskFactory(CancellableTaskFactory::create(this, &NavigationSche duler::navigateTask))
261 , m_frameType(m_frame->isMainFrame() ? WebScheduler::NavigatingFrameType::kM ainFrame : WebScheduler::NavigatingFrameType::kChildFrame)
261 { 262 {
262 } 263 }
263 264
264 NavigationScheduler::~NavigationScheduler() 265 NavigationScheduler::~NavigationScheduler()
265 { 266 {
266 // TODO(alexclarke): Can remove this if oilpan is on since any pending task should 267 // TODO(alexclarke): Can remove this if oilpan is on since any pending task should
267 // keep the NavigationScheduler alive. 268 // keep the NavigationScheduler alive.
268 if (m_navigateTaskFactory->isPending()) 269 if (m_navigateTaskFactory->isPending())
269 Platform::current()->currentThread()->scheduler()->removePendingNavigati on(); 270 Platform::current()->currentThread()->scheduler()->removePendingNavigati on(m_frameType);
270 } 271 }
271 272
272 bool NavigationScheduler::locationChangePending() 273 bool NavigationScheduler::locationChangePending()
273 { 274 {
274 return m_redirect && m_redirect->isLocationChange(); 275 return m_redirect && m_redirect->isLocationChange();
275 } 276 }
276 277
277 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const 278 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const
278 { 279 {
279 return m_redirect && m_redirect->delay() <= interval; 280 return m_redirect && m_redirect->delay() <= interval;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 { 378 {
378 if (!shouldScheduleReload()) 379 if (!shouldScheduleReload())
379 return; 380 return;
380 if (m_frame->document()->url().isEmpty()) 381 if (m_frame->document()->url().isEmpty())
381 return; 382 return;
382 schedule(ScheduledReload::create()); 383 schedule(ScheduledReload::create());
383 } 384 }
384 385
385 void NavigationScheduler::navigateTask() 386 void NavigationScheduler::navigateTask()
386 { 387 {
387 Platform::current()->currentThread()->scheduler()->removePendingNavigation() ; 388 Platform::current()->currentThread()->scheduler()->removePendingNavigation(m _frameType);
388 389
389 if (!m_frame->page()) 390 if (!m_frame->page())
390 return; 391 return;
391 if (m_frame->page()->defersLoading()) { 392 if (m_frame->page()->defersLoading()) {
392 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); 393 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
393 return; 394 return;
394 } 395 }
395 396
396 ScheduledNavigation* redirect(m_redirect.release()); 397 ScheduledNavigation* redirect(m_redirect.release());
397 redirect->fire(m_frame); 398 redirect->fire(m_frame);
(...skipping 24 matching lines...) Expand all
422 if (!m_redirect) 423 if (!m_redirect)
423 return; 424 return;
424 425
425 ASSERT(m_frame->page()); 426 ASSERT(m_frame->page());
426 if (m_navigateTaskFactory->isPending()) 427 if (m_navigateTaskFactory->isPending())
427 return; 428 return;
428 if (!m_redirect->shouldStartTimer(m_frame)) 429 if (!m_redirect->shouldStartTimer(m_frame))
429 return; 430 return;
430 431
431 WebScheduler* scheduler = Platform::current()->currentThread()->scheduler(); 432 WebScheduler* scheduler = Platform::current()->currentThread()->scheduler();
432 scheduler->addPendingNavigation(); 433 scheduler->addPendingNavigation(m_frameType);
433 scheduler->loadingTaskRunner()->postDelayedTask( 434 scheduler->loadingTaskRunner()->postDelayedTask(
434 BLINK_FROM_HERE, m_navigateTaskFactory->cancelAndCreate(), m_redirect->d elay() * 1000.0); 435 BLINK_FROM_HERE, m_navigateTaskFactory->cancelAndCreate(), m_redirect->d elay() * 1000.0);
435 436
436 InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->dela y()); 437 InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->dela y());
437 } 438 }
438 439
439 void NavigationScheduler::cancel() 440 void NavigationScheduler::cancel()
440 { 441 {
441 if (m_navigateTaskFactory->isPending()) { 442 if (m_navigateTaskFactory->isPending()) {
442 Platform::current()->currentThread()->scheduler()->removePendingNavigati on(); 443 Platform::current()->currentThread()->scheduler()->removePendingNavigati on(m_frameType);
443 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); 444 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
444 } 445 }
445 m_navigateTaskFactory->cancel(); 446 m_navigateTaskFactory->cancel();
446 m_redirect.clear(); 447 m_redirect.clear();
447 } 448 }
448 449
449 DEFINE_TRACE(NavigationScheduler) 450 DEFINE_TRACE(NavigationScheduler)
450 { 451 {
451 visitor->trace(m_frame); 452 visitor->trace(m_frame);
452 visitor->trace(m_redirect); 453 visitor->trace(m_redirect);
453 } 454 }
454 455
455 } // namespace blink 456 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/NavigationScheduler.h ('k') | third_party/WebKit/Source/platform/TimerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698