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

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

Issue 1305933007: Make NavigationScheduler post loading tasks instead of timers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « Source/core/loader/NavigationScheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30 matching lines...) Expand all
41 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
42 #include "core/loader/DocumentLoader.h" 42 #include "core/loader/DocumentLoader.h"
43 #include "core/loader/FormSubmission.h" 43 #include "core/loader/FormSubmission.h"
44 #include "core/loader/FrameLoadRequest.h" 44 #include "core/loader/FrameLoadRequest.h"
45 #include "core/loader/FrameLoader.h" 45 #include "core/loader/FrameLoader.h"
46 #include "core/loader/FrameLoaderClient.h" 46 #include "core/loader/FrameLoaderClient.h"
47 #include "core/loader/FrameLoaderStateMachine.h" 47 #include "core/loader/FrameLoaderStateMachine.h"
48 #include "core/page/Page.h" 48 #include "core/page/Page.h"
49 #include "platform/SharedBuffer.h" 49 #include "platform/SharedBuffer.h"
50 #include "platform/UserGestureIndicator.h" 50 #include "platform/UserGestureIndicator.h"
51 #include "public/platform/Platform.h"
51 #include "wtf/CurrentTime.h" 52 #include "wtf/CurrentTime.h"
52 53
53 namespace blink { 54 namespace blink {
54 55
55 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; 56 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0;
56 57
57 FrameNavigationDisabler::FrameNavigationDisabler(LocalFrame* frame) 58 FrameNavigationDisabler::FrameNavigationDisabler(LocalFrame* frame)
58 : m_navigationScheduler(frame->navigationScheduler()) 59 : m_navigationScheduler(frame->navigationScheduler())
59 { 60 {
60 m_navigationScheduler.disableFrameNavigation(); 61 m_navigationScheduler.disableFrameNavigation();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 , m_submission(submission) 260 , m_submission(submission)
260 { 261 {
261 ASSERT(m_submission->form()); 262 ASSERT(m_submission->form());
262 } 263 }
263 264
264 RefPtrWillBeMember<FormSubmission> m_submission; 265 RefPtrWillBeMember<FormSubmission> m_submission;
265 }; 266 };
266 267
267 NavigationScheduler::NavigationScheduler(LocalFrame* frame) 268 NavigationScheduler::NavigationScheduler(LocalFrame* frame)
268 : m_frame(frame) 269 : m_frame(frame)
269 , m_timer(this, &NavigationScheduler::timerFired) 270 , m_navigateTaskFactory(WTF::bind(&NavigationScheduler::navigateTask, this))
haraken 2015/09/03 23:43:30 Sigbjorn: NavigationScheduler is a part of object.
sof 2015/09/04 06:28:34 It will work out fine, but https://codereview.chro
haraken 2015/09/04 06:32:40 Makes sense.
270 , m_navigationDisableCount(0) 271 , m_navigationDisableCount(0)
271 { 272 {
272 } 273 }
273 274
274 NavigationScheduler::~NavigationScheduler() 275 NavigationScheduler::~NavigationScheduler()
275 { 276 {
276 } 277 }
277 278
278 bool NavigationScheduler::locationChangePending() 279 bool NavigationScheduler::locationChangePending()
279 { 280 {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 365
365 void NavigationScheduler::scheduleReload() 366 void NavigationScheduler::scheduleReload()
366 { 367 {
367 if (!shouldScheduleReload()) 368 if (!shouldScheduleReload())
368 return; 369 return;
369 if (m_frame->document()->url().isEmpty()) 370 if (m_frame->document()->url().isEmpty())
370 return; 371 return;
371 schedule(ScheduledReload::create()); 372 schedule(ScheduledReload::create());
372 } 373 }
373 374
374 void NavigationScheduler::timerFired(Timer<NavigationScheduler>*) 375 void NavigationScheduler::navigateTask()
375 { 376 {
376 if (!m_frame->page()) 377 if (!m_frame->page())
377 return; 378 return;
378 if (m_frame->page()->defersLoading()) { 379 if (m_frame->page()->defersLoading()) {
379 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); 380 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
380 return; 381 return;
381 } 382 }
382 383
383 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 384 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
384 385
(...skipping 21 matching lines...) Expand all
406 m_redirect = redirect; 407 m_redirect = redirect;
407 startTimer(); 408 startTimer();
408 } 409 }
409 410
410 void NavigationScheduler::startTimer() 411 void NavigationScheduler::startTimer()
411 { 412 {
412 if (!m_redirect) 413 if (!m_redirect)
413 return; 414 return;
414 415
415 ASSERT(m_frame->page()); 416 ASSERT(m_frame->page());
416 if (m_timer.isActive()) 417 if (m_navigateTaskFactory.isPending())
417 return; 418 return;
418 if (!m_redirect->shouldStartTimer(m_frame)) 419 if (!m_redirect->shouldStartTimer(m_frame))
419 return; 420 return;
420 421
421 m_timer.startOneShot(m_redirect->delay(), FROM_HERE); 422 Platform::current()->currentThread()->scheduler()->loadingTaskRunner()->post DelayedTask(
423 FROM_HERE, m_navigateTaskFactory.cancelAndCreate(), m_redirect->delay()) ;
jochen (gone - plz use gerrit) 2015/09/07 14:50:59 this is wrong: startOneShot takes seconds, postDel
424
422 InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->dela y()); 425 InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->dela y());
423 } 426 }
424 427
425 void NavigationScheduler::cancel() 428 void NavigationScheduler::cancel()
426 { 429 {
427 if (m_timer.isActive()) 430 if (m_navigateTaskFactory.isPending())
428 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); 431 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
429 m_timer.stop(); 432 m_navigateTaskFactory.cancel();
430 m_redirect.clear(); 433 m_redirect.clear();
431 } 434 }
432 435
433 DEFINE_TRACE(NavigationScheduler) 436 DEFINE_TRACE(NavigationScheduler)
434 { 437 {
435 visitor->trace(m_frame); 438 visitor->trace(m_frame);
436 visitor->trace(m_redirect); 439 visitor->trace(m_redirect);
437 } 440 }
438 441
439 } // namespace blink 442 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/NavigationScheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698