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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2390073003: Use per-frame WebTaskRunner on HTMLMediaElement (Closed)
Patch Set: Microtask -> MediaElementEvent Created 4 years, 2 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 | « no previous file | 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) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 #include "bindings/core/v8/ScriptController.h" 31 #include "bindings/core/v8/ScriptController.h"
32 #include "bindings/core/v8/ScriptEventListener.h" 32 #include "bindings/core/v8/ScriptEventListener.h"
33 #include "bindings/core/v8/ScriptPromiseResolver.h" 33 #include "bindings/core/v8/ScriptPromiseResolver.h"
34 #include "core/HTMLNames.h" 34 #include "core/HTMLNames.h"
35 #include "core/css/MediaList.h" 35 #include "core/css/MediaList.h"
36 #include "core/dom/Attribute.h" 36 #include "core/dom/Attribute.h"
37 #include "core/dom/DOMException.h" 37 #include "core/dom/DOMException.h"
38 #include "core/dom/ElementTraversal.h" 38 #include "core/dom/ElementTraversal.h"
39 #include "core/dom/ElementVisibilityObserver.h" 39 #include "core/dom/ElementVisibilityObserver.h"
40 #include "core/dom/Fullscreen.h" 40 #include "core/dom/Fullscreen.h"
41 #include "core/dom/TaskRunnerHelper.h"
41 #include "core/dom/shadow/ShadowRoot.h" 42 #include "core/dom/shadow/ShadowRoot.h"
42 #include "core/events/Event.h" 43 #include "core/events/Event.h"
43 #include "core/frame/FrameView.h" 44 #include "core/frame/FrameView.h"
44 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
45 #include "core/frame/Settings.h" 46 #include "core/frame/Settings.h"
46 #include "core/frame/UseCounter.h" 47 #include "core/frame/UseCounter.h"
47 #include "core/frame/csp/ContentSecurityPolicy.h" 48 #include "core/frame/csp/ContentSecurityPolicy.h"
48 #include "core/html/AutoplayUmaHelper.h" 49 #include "core/html/AutoplayUmaHelper.h"
49 #include "core/html/HTMLMediaSource.h" 50 #include "core/html/HTMLMediaSource.h"
50 #include "core/html/HTMLSourceElement.h" 51 #include "core/html/HTMLSourceElement.h"
(...skipping 3822 matching lines...) Expand 10 before | Expand all | Expand 10 after
3873 m_playPromiseResolveTask->isPending()); 3874 m_playPromiseResolveTask->isPending());
3874 if (m_playPromiseResolvers.isEmpty()) 3875 if (m_playPromiseResolvers.isEmpty())
3875 return; 3876 return;
3876 3877
3877 m_playPromiseResolveList.appendVector(m_playPromiseResolvers); 3878 m_playPromiseResolveList.appendVector(m_playPromiseResolvers);
3878 m_playPromiseResolvers.clear(); 3879 m_playPromiseResolvers.clear();
3879 3880
3880 if (m_playPromiseResolveTask->isPending()) 3881 if (m_playPromiseResolveTask->isPending())
3881 return; 3882 return;
3882 3883
3883 Platform::current()->currentThread()->getWebTaskRunner()->postTask( 3884 TaskRunnerHelper::get(TaskType::MediaElementEvent, getExecutionContext())
haraken 2016/10/13 13:19:38 Nit: document() is better than getExecutionContext
tzik 2016/10/14 04:15:22 Done.
3884 BLINK_FROM_HERE, m_playPromiseResolveTask->cancelAndCreate()); 3885 ->postTask(BLINK_FROM_HERE, m_playPromiseResolveTask->cancelAndCreate());
3885 } 3886 }
3886 3887
3887 void HTMLMediaElement::scheduleRejectPlayPromises(ExceptionCode code) { 3888 void HTMLMediaElement::scheduleRejectPlayPromises(ExceptionCode code) {
3888 // TODO(mlamouri): per spec, we should create a new task but we can't create 3889 // TODO(mlamouri): per spec, we should create a new task but we can't create
3889 // a new cancellable task without cancelling the previous one. There are two 3890 // a new cancellable task without cancelling the previous one. There are two
3890 // approaches then: cancel the previous task and create a new one with the 3891 // approaches then: cancel the previous task and create a new one with the
3891 // appended promise list or append the new promise to the current list. The 3892 // appended promise list or append the new promise to the current list. The
3892 // latter approach is preferred because it might be the less observable 3893 // latter approach is preferred because it might be the less observable
3893 // change. 3894 // change.
3894 DCHECK(m_playPromiseRejectList.isEmpty() || 3895 DCHECK(m_playPromiseRejectList.isEmpty() ||
3895 m_playPromiseRejectTask->isPending()); 3896 m_playPromiseRejectTask->isPending());
3896 if (m_playPromiseResolvers.isEmpty()) 3897 if (m_playPromiseResolvers.isEmpty())
3897 return; 3898 return;
3898 3899
3899 m_playPromiseRejectList.appendVector(m_playPromiseResolvers); 3900 m_playPromiseRejectList.appendVector(m_playPromiseResolvers);
3900 m_playPromiseResolvers.clear(); 3901 m_playPromiseResolvers.clear();
3901 3902
3902 if (m_playPromiseRejectTask->isPending()) 3903 if (m_playPromiseRejectTask->isPending())
3903 return; 3904 return;
3904 3905
3905 // TODO(mlamouri): because cancellable tasks can't take parameters, the 3906 // TODO(mlamouri): because cancellable tasks can't take parameters, the
3906 // error code needs to be saved. 3907 // error code needs to be saved.
3907 m_playPromiseErrorCode = code; 3908 m_playPromiseErrorCode = code;
3908 Platform::current()->currentThread()->getWebTaskRunner()->postTask( 3909 TaskRunnerHelper::get(TaskType::MediaElementEvent, getExecutionContext())
haraken 2016/10/13 13:19:38 Ditto.
tzik 2016/10/14 04:15:22 Done.
3909 BLINK_FROM_HERE, m_playPromiseRejectTask->cancelAndCreate()); 3910 ->postTask(BLINK_FROM_HERE, m_playPromiseRejectTask->cancelAndCreate());
3910 } 3911 }
3911 3912
3912 void HTMLMediaElement::scheduleNotifyPlaying() { 3913 void HTMLMediaElement::scheduleNotifyPlaying() {
3913 scheduleEvent(EventTypeNames::playing); 3914 scheduleEvent(EventTypeNames::playing);
3914 scheduleResolvePlayPromises(); 3915 scheduleResolvePlayPromises();
3915 } 3916 }
3916 3917
3917 void HTMLMediaElement::resolveScheduledPlayPromises() { 3918 void HTMLMediaElement::resolveScheduledPlayPromises() {
3918 for (auto& resolver : m_playPromiseResolveList) 3919 for (auto& resolver : m_playPromiseResolveList)
3919 resolver->resolve(); 3920 resolver->resolve();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 4090
4090 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() 4091 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect()
4091 const { 4092 const {
4092 IntRect result; 4093 IntRect result;
4093 if (LayoutObject* object = m_element->layoutObject()) 4094 if (LayoutObject* object = m_element->layoutObject())
4094 result = object->absoluteBoundingBoxRect(); 4095 result = object->absoluteBoundingBoxRect();
4095 return result; 4096 return result;
4096 } 4097 }
4097 4098
4098 } // namespace blink 4099 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698