OLD | NEW |
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 Loading... |
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" | |
52 #include "wtf/CurrentTime.h" | 51 #include "wtf/CurrentTime.h" |
53 | 52 |
54 namespace blink { | 53 namespace blink { |
55 | 54 |
56 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; | 55 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; |
57 | 56 |
58 FrameNavigationDisabler::FrameNavigationDisabler(LocalFrame* frame) | 57 FrameNavigationDisabler::FrameNavigationDisabler(LocalFrame* frame) |
59 : m_navigationScheduler(frame->navigationScheduler()) | 58 : m_navigationScheduler(frame->navigationScheduler()) |
60 { | 59 { |
61 m_navigationScheduler.disableFrameNavigation(); | 60 m_navigationScheduler.disableFrameNavigation(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 , m_submission(submission) | 259 , m_submission(submission) |
261 { | 260 { |
262 ASSERT(m_submission->form()); | 261 ASSERT(m_submission->form()); |
263 } | 262 } |
264 | 263 |
265 RefPtrWillBeMember<FormSubmission> m_submission; | 264 RefPtrWillBeMember<FormSubmission> m_submission; |
266 }; | 265 }; |
267 | 266 |
268 NavigationScheduler::NavigationScheduler(LocalFrame* frame) | 267 NavigationScheduler::NavigationScheduler(LocalFrame* frame) |
269 : m_frame(frame) | 268 : m_frame(frame) |
270 , m_navigateTaskFactory(WTF::bind(&NavigationScheduler::navigateTask, this)) | 269 , m_timer(this, &NavigationScheduler::timerFired) |
271 , m_navigationDisableCount(0) | 270 , m_navigationDisableCount(0) |
272 { | 271 { |
273 } | 272 } |
274 | 273 |
275 NavigationScheduler::~NavigationScheduler() | 274 NavigationScheduler::~NavigationScheduler() |
276 { | 275 { |
277 } | 276 } |
278 | 277 |
279 bool NavigationScheduler::locationChangePending() | 278 bool NavigationScheduler::locationChangePending() |
280 { | 279 { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 364 |
366 void NavigationScheduler::scheduleReload() | 365 void NavigationScheduler::scheduleReload() |
367 { | 366 { |
368 if (!shouldScheduleReload()) | 367 if (!shouldScheduleReload()) |
369 return; | 368 return; |
370 if (m_frame->document()->url().isEmpty()) | 369 if (m_frame->document()->url().isEmpty()) |
371 return; | 370 return; |
372 schedule(ScheduledReload::create()); | 371 schedule(ScheduledReload::create()); |
373 } | 372 } |
374 | 373 |
375 void NavigationScheduler::navigateTask() | 374 void NavigationScheduler::timerFired(Timer<NavigationScheduler>*) |
376 { | 375 { |
377 if (!m_frame->page()) | 376 if (!m_frame->page()) |
378 return; | 377 return; |
379 if (m_frame->page()->defersLoading()) { | 378 if (m_frame->page()->defersLoading()) { |
380 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); | 379 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); |
381 return; | 380 return; |
382 } | 381 } |
383 | 382 |
384 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 383 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
385 | 384 |
(...skipping 21 matching lines...) Expand all Loading... |
407 m_redirect = redirect; | 406 m_redirect = redirect; |
408 startTimer(); | 407 startTimer(); |
409 } | 408 } |
410 | 409 |
411 void NavigationScheduler::startTimer() | 410 void NavigationScheduler::startTimer() |
412 { | 411 { |
413 if (!m_redirect) | 412 if (!m_redirect) |
414 return; | 413 return; |
415 | 414 |
416 ASSERT(m_frame->page()); | 415 ASSERT(m_frame->page()); |
417 if (m_navigateTaskFactory.isPending()) | 416 if (m_timer.isActive()) |
418 return; | 417 return; |
419 if (!m_redirect->shouldStartTimer(m_frame)) | 418 if (!m_redirect->shouldStartTimer(m_frame)) |
420 return; | 419 return; |
421 | 420 |
422 Platform::current()->currentThread()->scheduler()->loadingTaskRunner()->post
DelayedTask( | 421 m_timer.startOneShot(m_redirect->delay(), FROM_HERE); |
423 FROM_HERE, m_navigateTaskFactory.cancelAndCreate(), m_redirect->delay())
; | |
424 | |
425 InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->dela
y()); | 422 InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->dela
y()); |
426 } | 423 } |
427 | 424 |
428 void NavigationScheduler::cancel() | 425 void NavigationScheduler::cancel() |
429 { | 426 { |
430 if (m_navigateTaskFactory.isPending()) | 427 if (m_timer.isActive()) |
431 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); | 428 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); |
432 m_navigateTaskFactory.cancel(); | 429 m_timer.stop(); |
433 m_redirect.clear(); | 430 m_redirect.clear(); |
434 } | 431 } |
435 | 432 |
436 DEFINE_TRACE(NavigationScheduler) | 433 DEFINE_TRACE(NavigationScheduler) |
437 { | 434 { |
438 visitor->trace(m_frame); | 435 visitor->trace(m_frame); |
439 visitor->trace(m_redirect); | 436 visitor->trace(m_redirect); |
440 } | 437 } |
441 | 438 |
442 } // namespace blink | 439 } // namespace blink |
OLD | NEW |