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

Side by Side Diff: Source/core/html/MediaController.cpp

Issue 258563005: Use GenericEventQueue class in MediaController (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/MediaController.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) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/html/MediaController.h" 27 #include "core/html/MediaController.h"
28 28
29 #include "bindings/v8/ExceptionMessages.h" 29 #include "bindings/v8/ExceptionMessages.h"
30 #include "bindings/v8/ExceptionState.h" 30 #include "bindings/v8/ExceptionState.h"
31 #include "bindings/v8/ExceptionStatePlaceholder.h" 31 #include "bindings/v8/ExceptionStatePlaceholder.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/events/GenericEventQueue.h"
33 #include "core/html/HTMLMediaElement.h" 34 #include "core/html/HTMLMediaElement.h"
34 #include "core/html/TimeRanges.h" 35 #include "core/html/TimeRanges.h"
35 #include "platform/Clock.h" 36 #include "platform/Clock.h"
36 #include "wtf/CurrentTime.h" 37 #include "wtf/CurrentTime.h"
37 #include "wtf/StdLibExtras.h" 38 #include "wtf/StdLibExtras.h"
38 #include "wtf/text/AtomicString.h" 39 #include "wtf/text/AtomicString.h"
39 40
40 using namespace WebCore; 41 using namespace WebCore;
41 using namespace std; 42 using namespace std;
42 43
43 PassRefPtr<MediaController> MediaController::create(ExecutionContext* context) 44 PassRefPtr<MediaController> MediaController::create(ExecutionContext* context)
44 { 45 {
45 return adoptRef(new MediaController(context)); 46 return adoptRef(new MediaController(context));
46 } 47 }
47 48
48 MediaController::MediaController(ExecutionContext* context) 49 MediaController::MediaController(ExecutionContext* context)
49 : m_paused(false) 50 : m_paused(false)
50 , m_defaultPlaybackRate(1) 51 , m_defaultPlaybackRate(1)
51 , m_volume(1) 52 , m_volume(1)
52 , m_position(MediaPlayer::invalidTime()) 53 , m_position(MediaPlayer::invalidTime())
53 , m_muted(false) 54 , m_muted(false)
54 , m_readyState(HTMLMediaElement::HAVE_NOTHING) 55 , m_readyState(HTMLMediaElement::HAVE_NOTHING)
55 , m_playbackState(WAITING) 56 , m_playbackState(WAITING)
56 , m_asyncEventTimer(this, &MediaController::asyncEventTimerFired) 57 , m_pendingEventsQueue(GenericEventQueue::create(this))
57 , m_clearPositionTimer(this, &MediaController::clearPositionTimerFired) 58 , m_clearPositionTimer(this, &MediaController::clearPositionTimerFired)
58 , m_clock(Clock::create()) 59 , m_clock(Clock::create())
59 , m_executionContext(context) 60 , m_executionContext(context)
60 , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired) 61 , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired)
61 , m_previousTimeupdateTime(0) 62 , m_previousTimeupdateTime(0)
62 { 63 {
63 ScriptWrappable::init(this); 64 ScriptWrappable::init(this);
64 } 65 }
65 66
66 MediaController::~MediaController() 67 MediaController::~MediaController()
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 bool allHaveEnded = true; 581 bool allHaveEnded = true;
581 for (size_t index = 0; index < m_mediaElements.size(); ++index) { 582 for (size_t index = 0; index < m_mediaElements.size(); ++index) {
582 if (!m_mediaElements[index]->ended()) 583 if (!m_mediaElements[index]->ended())
583 allHaveEnded = false; 584 allHaveEnded = false;
584 } 585 }
585 return allHaveEnded; 586 return allHaveEnded;
586 } 587 }
587 588
588 void MediaController::scheduleEvent(const AtomicString& eventName) 589 void MediaController::scheduleEvent(const AtomicString& eventName)
589 { 590 {
590 m_pendingEvents.append(Event::createCancelable(eventName)); 591 m_pendingEventsQueue->enqueueEvent(Event::createCancelable(eventName));
591 if (!m_asyncEventTimer.isActive())
592 m_asyncEventTimer.startOneShot(0, FROM_HERE);
593 }
594
595 void MediaController::asyncEventTimerFired(Timer<MediaController>*)
596 {
597 WillBeHeapVector<RefPtrWillBeMember<Event> > pendingEvents;
598
599 m_pendingEvents.swap(pendingEvents);
600 size_t count = pendingEvents.size();
601 for (size_t index = 0; index < count; ++index)
602 dispatchEvent(pendingEvents[index].release(), IGNORE_EXCEPTION);
603 } 592 }
604 593
605 void MediaController::clearPositionTimerFired(Timer<MediaController>*) 594 void MediaController::clearPositionTimerFired(Timer<MediaController>*)
606 { 595 {
607 m_position = MediaPlayer::invalidTime(); 596 m_position = MediaPlayer::invalidTime();
608 } 597 }
609 598
610 const AtomicString& MediaController::interfaceName() const 599 const AtomicString& MediaController::interfaceName() const
611 { 600 {
612 return EventTargetNames::MediaController; 601 return EventTargetNames::MediaController;
(...skipping 20 matching lines...) Expand all
633 { 622 {
634 double now = WTF::currentTime(); 623 double now = WTF::currentTime();
635 double timedelta = now - m_previousTimeupdateTime; 624 double timedelta = now - m_previousTimeupdateTime;
636 625
637 if (timedelta < maxTimeupdateEventFrequency) 626 if (timedelta < maxTimeupdateEventFrequency)
638 return; 627 return;
639 628
640 scheduleEvent(EventTypeNames::timeupdate); 629 scheduleEvent(EventTypeNames::timeupdate);
641 m_previousTimeupdateTime = now; 630 m_previousTimeupdateTime = now;
642 } 631 }
OLDNEW
« no previous file with comments | « Source/core/html/MediaController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698