<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[166261] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166261">166261</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2014-03-25 15:26:34 -0700 (Tue, 25 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] Pause the media element during system sleep.
https://bugs.webkit.org/show_bug.cgi?id=130718

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/video-system-sleep.html

Relying on the platform media system to pause and restart playback during
system sleep can cause problems on some platforms, especially where hardware
decoders are concerned. Rather than implicitly pausing the media during
system sleep, explicitly pause the media before sleeping and resume (if
appropriate) upon waking.

Add a new class to be used for system sleep notifications:
* platform/SystemSleepListener.cpp: Added.
(WebCore::SystemSleepListener::create):
(WebCore::SystemSleepListener::SystemSleepListener):
* platform/SystemSleepListener.h: Added.
(WebCore::SystemSleepListener::Client::~Client):
(WebCore::SystemSleepListener::~SystemSleepListener):
(WebCore::SystemSleepListener::client):

Add a Mac-specific implementation:
* platform/mac/SystemSleepListenerMac.h: Added.
* platform/mac/SystemSleepListenerMac.mm: Added.
(WebCore::SystemSleepListener::create):
(WebCore::SystemSleepListenerMac::SystemSleepListenerMac):
(WebCore::SystemSleepListenerMac::~SystemSleepListenerMac):

Listen for system sleep notifications in MediaSessionManager:
* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::MediaSessionManager):
(WebCore::MediaSessionManager::systemWillSleep):
(WebCore::MediaSessionManager::systemDidWake):
* platform/audio/MediaSessionManager.h:

Drive-by fix; notify the MediaSession that playback will begin
due to autoplay, but do not begin autoplaying if the session
is already interrupted:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):

Add new files to project:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:
* GNUmakefile.list.am:

LayoutTests:

* media/video-system-sleep-expected.txt: Added.
* media/video-system-sleep.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefilelistam">trunk/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagercpp">trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagerh">trunk/Source/WebCore/platform/audio/MediaSessionManager.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediavideosystemsleepexpectedtxt">trunk/LayoutTests/media/video-system-sleep-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediavideosystemsleephtml">trunk/LayoutTests/media/video-system-sleep.html</a></li>
<li><a href="#trunkSourceWebCoreplatformSystemSleepListenercpp">trunk/Source/WebCore/platform/SystemSleepListener.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformSystemSleepListenerh">trunk/Source/WebCore/platform/SystemSleepListener.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacSystemSleepListenerMach">trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacSystemSleepListenerMacmm">trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/LayoutTests/ChangeLog        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-03-25  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [Mac] Pause the media element during system sleep.
+        https://bugs.webkit.org/show_bug.cgi?id=130718
+
+        Reviewed by Eric Carlson.
+
+        * media/video-system-sleep-expected.txt: Added.
+        * media/video-system-sleep.html: Added.
+
</ins><span class="cx"> 2014-03-25  Radu Stavila  &lt;stavila@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Regions] The background of children of scrollable elements flowed into regions is not properly scrolled
</span></span></pre></div>
<a id="trunkLayoutTestsmediavideosystemsleepexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-system-sleep-expected.txt (0 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-system-sleep-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/video-system-sleep-expected.txt        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+
+Test that video elements pause during system sleep.
+
+EVENT(playing)
+RUN(internals.simulateSystemSleep())
+EVENT(pause)
+RUN(internals.simulateSystemWake())
+EVENT(playing)
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediavideosystemsleephtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-system-sleep.html (0 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-system-sleep.html                                (rev 0)
+++ trunk/LayoutTests/media/video-system-sleep.html        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=media-file.js&gt;&lt;/script&gt;
+        &lt;script src=video-test.js&gt;&lt;/script&gt;
+        &lt;script&gt;
+            function start()
+            {
+                if (!window.internals)
+                    consoleWrite('To run this test manually, cause the machine to sleep then wake up.');
+
+                findMediaElement();
+                waitForEventOnce('playing', playing);
+                video.src = findMediaFile(&quot;video&quot;, &quot;content/test&quot;);
+            }
+
+            function playing()
+            {
+                waitForEventOnce('pause', paused);
+                run('internals.simulateSystemSleep()');
+            }
+
+            function paused()
+            {
+                waitForEventOnce('playing', resumed);
+                run('internals.simulateSystemWake()');
+            }
+
+            function resumed()
+            {
+                endTest();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+
+    &lt;body onload=&quot;start()&quot;&gt;
+        &lt;video controls autoplay&gt;&lt;/video&gt;
+        &lt;p&gt;Test that video elements pause during system sleep.&lt;/p&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -1808,6 +1808,7 @@
</span><span class="cx">     platform/PlatformEvent.cpp
</span><span class="cx">     platform/PlatformStrategies.cpp
</span><span class="cx">     platform/RemoteCommandListener.cpp
</span><ins>+    platform/SystemSleepListener.cpp
</ins><span class="cx">     platform/RuntimeApplicationChecks.cpp
</span><span class="cx">     platform/SchemeRegistry.cpp
</span><span class="cx">     platform/ScrollAnimator.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/ChangeLog        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2014-03-25  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [Mac] Pause the media element during system sleep.
+        https://bugs.webkit.org/show_bug.cgi?id=130718
+
+        Reviewed by Eric Carlson.
+
+        Test: media/video-system-sleep.html
+
+        Relying on the platform media system to pause and restart playback during
+        system sleep can cause problems on some platforms, especially where hardware
+        decoders are concerned. Rather than implicitly pausing the media during
+        system sleep, explicitly pause the media before sleeping and resume (if
+        appropriate) upon waking.
+
+        Add a new class to be used for system sleep notifications:
+        * platform/SystemSleepListener.cpp: Added.
+        (WebCore::SystemSleepListener::create):
+        (WebCore::SystemSleepListener::SystemSleepListener):
+        * platform/SystemSleepListener.h: Added.
+        (WebCore::SystemSleepListener::Client::~Client):
+        (WebCore::SystemSleepListener::~SystemSleepListener):
+        (WebCore::SystemSleepListener::client):
+
+        Add a Mac-specific implementation:
+        * platform/mac/SystemSleepListenerMac.h: Added.
+        * platform/mac/SystemSleepListenerMac.mm: Added.
+        (WebCore::SystemSleepListener::create):
+        (WebCore::SystemSleepListenerMac::SystemSleepListenerMac):
+        (WebCore::SystemSleepListenerMac::~SystemSleepListenerMac):
+
+        Listen for system sleep notifications in MediaSessionManager:
+        * platform/audio/MediaSessionManager.cpp:
+        (WebCore::MediaSessionManager::MediaSessionManager):
+        (WebCore::MediaSessionManager::systemWillSleep):
+        (WebCore::MediaSessionManager::systemDidWake):
+        * platform/audio/MediaSessionManager.h:
+
+        Drive-by fix; notify the MediaSession that playback will begin
+        due to autoplay, but do not begin autoplaying if the session
+        is already interrupted:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+
+        Add new files to project:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+
</ins><span class="cx"> 2014-03-25  Radu Stavila  &lt;stavila@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Regions] The background of children of scrollable elements flowed into regions is not properly scrolled
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.list.am (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.list.am        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/GNUmakefile.list.am        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -5514,6 +5514,8 @@
</span><span class="cx">         Source/WebCore/platform/ScrollAnimator.h \
</span><span class="cx">         Source/WebCore/platform/ScrollAnimatorNone.cpp \
</span><span class="cx">         Source/WebCore/platform/ScrollAnimatorNone.h \
</span><ins>+        Source/WebCore/platform/SystemSleepListener.cpp \
+        Source/WebCore/platform/SystemSleepListener.h \
</ins><span class="cx">         Source/WebCore/platform/ThreadGlobalData.cpp \
</span><span class="cx">         Source/WebCore/platform/ThreadGlobalData.h \
</span><span class="cx">         Source/WebCore/platform/UserActivity.cpp \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -7622,6 +7622,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\ScrollView.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\SharedBuffer.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\SharedBufferChunkReader.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\platform\SystemSleepListener.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\platform\ThreadGlobalData.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\ThreadTimers.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\Timer.cpp&quot; /&gt;
</span><span class="lines">@@ -19253,6 +19254,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\Sound.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\SSLKeyGenerator.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\SuddenTermination.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\SystemSleepListener.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\ThemeTypes.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\ThreadGlobalData.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\ThreadTimers.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -5559,6 +5559,10 @@
</span><span class="cx">                 CD9DE17D17AAC75B00EA386D /* JSSourceBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = CD9DE17917AAC75B00EA386D /* JSSourceBufferList.h */; };
</span><span class="cx">                 CD9DE18117AAD6A400EA386D /* DOMURLMediaSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD9DE17E17AAD64E00EA386D /* DOMURLMediaSource.cpp */; };
</span><span class="cx">                 CD9DE18217AAD6A400EA386D /* DOMURLMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CD9DE17F17AAD64E00EA386D /* DOMURLMediaSource.h */; };
</span><ins>+                CDA07FBD18E0A16A004699FA /* SystemSleepListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA07FBB18E0A16A004699FA /* SystemSleepListener.cpp */; };
+                CDA07FBE18E0A16A004699FA /* SystemSleepListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA07FBC18E0A16A004699FA /* SystemSleepListener.h */; };
+                CDA07FC118E0A22B004699FA /* SystemSleepListenerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA07FBF18E0A22B004699FA /* SystemSleepListenerMac.mm */; };
+                CDA07FC218E0A22B004699FA /* SystemSleepListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA07FC018E0A22B004699FA /* SystemSleepListenerMac.h */; };
</ins><span class="cx">                 CDA79824170A258300D45C55 /* AudioSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA79823170A258300D45C55 /* AudioSession.cpp */; };
</span><span class="cx">                 CDA79827170A279100D45C55 /* AudioSessionIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA79825170A279000D45C55 /* AudioSessionIOS.mm */; };
</span><span class="cx">                 CDA7982A170A3D0000D45C55 /* AudioSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA79821170A22DC00D45C55 /* AudioSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -12870,6 +12874,10 @@
</span><span class="cx">                 CD9DE17E17AAD64E00EA386D /* DOMURLMediaSource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMURLMediaSource.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD9DE17F17AAD64E00EA386D /* DOMURLMediaSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMURLMediaSource.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD9DE18017AAD64E00EA386D /* DOMURLMediaSource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMURLMediaSource.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CDA07FBB18E0A16A004699FA /* SystemSleepListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemSleepListener.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA07FBC18E0A16A004699FA /* SystemSleepListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemSleepListener.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA07FBF18E0A22B004699FA /* SystemSleepListenerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemSleepListenerMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA07FC018E0A22B004699FA /* SystemSleepListenerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemSleepListenerMac.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CDA79821170A22DC00D45C55 /* AudioSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioSession.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA79822170A24F400D45C55 /* AudioSessionListener.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioSessionListener.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA79823170A258300D45C55 /* AudioSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSession.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16118,6 +16126,8 @@
</span><span class="cx">                                 4B3043C80AE0371D00A82647 /* SoundMac.mm */,
</span><span class="cx">                                 84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.cpp */,
</span><span class="cx">                                 93B2D8170F9920EE006AE6B2 /* SuddenTermination.mm */,
</span><ins>+                                CDA07FBF18E0A22B004699FA /* SystemSleepListenerMac.mm */,
+                                CDA07FC018E0A22B004699FA /* SystemSleepListenerMac.h */,
</ins><span class="cx">                                 5DA97ECB168E787B000E3676 /* SystemVersionMac.h */,
</span><span class="cx">                                 5DA97ECC168E787B000E3676 /* SystemVersionMac.mm */,
</span><span class="cx">                                 BCE659E50EA92FB2007E4533 /* ThemeMac.h */,
</span><span class="lines">@@ -21045,6 +21055,8 @@
</span><span class="cx">                                 E1E1BEFF115FF6FB006F52CA /* WindowsKeyboardCodes.h */,
</span><span class="cx">                                 CDFC360318CA61C20026E56F /* RemoteCommandListener.cpp */,
</span><span class="cx">                                 CDFC360418CA61C20026E56F /* RemoteCommandListener.h */,
</span><ins>+                                CDA07FBB18E0A16A004699FA /* SystemSleepListener.cpp */,
+                                CDA07FBC18E0A16A004699FA /* SystemSleepListener.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = platform;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -23508,6 +23520,7 @@
</span><span class="cx">                                 85E711B90AC5D5350053270F /* DOMHTMLMapElementInternal.h in Headers */,
</span><span class="cx">                                 BC51579F0C03BBD3008BB0EE /* DOMHTMLMarqueeElement.h in Headers */,
</span><span class="cx">                                 BC5156EA0C03B741008BB0EE /* DOMHTMLMarqueeElementInternal.h in Headers */,
</span><ins>+                                CDA07FBE18E0A16A004699FA /* SystemSleepListener.h in Headers */,
</ins><span class="cx">                                 85BA4D130AA688680088052D /* DOMHTMLMenuElement.h in Headers */,
</span><span class="cx">                                 85E711BA0AC5D5350053270F /* DOMHTMLMenuElementInternal.h in Headers */,
</span><span class="cx">                                 859A9C4D0AA5E3BD00B694B2 /* DOMHTMLMetaElement.h in Headers */,
</span><span class="lines">@@ -25902,6 +25915,7 @@
</span><span class="cx">                                 1C18DA59181AF6A500C4EF22 /* TextPainter.h in Headers */,
</span><span class="cx">                                 E4C91A0E1802343100A17F6D /* TextPaintStyle.h in Headers */,
</span><span class="cx">                                 930FC68A1072B9280045293E /* TextRenderingMode.h in Headers */,
</span><ins>+                                CDA07FC218E0A22B004699FA /* SystemSleepListenerMac.h in Headers */,
</ins><span class="cx">                                 93F198F608245E59001E9ABC /* TextResourceDecoder.h in Headers */,
</span><span class="cx">                                 A824B4650E2EF2EA0081A7B7 /* TextRun.h in Headers */,
</span><span class="cx">                                 448B1B7A0F3A2F9B0047A9E2 /* TextSizeAdjustment.h in Headers */,
</span><span class="lines">@@ -28224,6 +28238,7 @@
</span><span class="cx">                                 31611E5A0E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp in Sources */,
</span><span class="cx">                                 3F2B33EE165AF15600E3987C /* JSWebKitCSSViewportRule.cpp in Sources */,
</span><span class="cx">                                 D7613AC414753E5600DB8606 /* JSWebKitNamedFlow.cpp in Sources */,
</span><ins>+                                CDA07FC118E0A22B004699FA /* SystemSleepListenerMac.mm in Sources */,
</ins><span class="cx">                                 0FDA7C261883333200C954B5 /* JSWebKitPlaybackTargetAvailabilityEvent.cpp in Sources */,
</span><span class="cx">                                 494BD79D0F55C94C00747828 /* JSWebKitPoint.cpp in Sources */,
</span><span class="cx">                                 BC275B7911C5D1C300C9206C /* JSWebKitPointCustom.cpp in Sources */,
</span><span class="lines">@@ -29050,6 +29065,7 @@
</span><span class="cx">                                 B2227A320D00BF220071B782 /* SVGLength.cpp in Sources */,
</span><span class="cx">                                 7134496D146941B300720312 /* SVGLengthContext.cpp in Sources */,
</span><span class="cx">                                 B2227A350D00BF220071B782 /* SVGLengthList.cpp in Sources */,
</span><ins>+                                CDA07FBD18E0A16A004699FA /* SystemSleepListener.cpp in Sources */,
</ins><span class="cx">                                 B2227A380D00BF220071B782 /* SVGLinearGradientElement.cpp in Sources */,
</span><span class="cx">                                 B2227A3B0D00BF220071B782 /* SVGLineElement.cpp in Sources */,
</span><span class="cx">                                 B2227A400D00BF220071B782 /* SVGLocatable.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -4429,6 +4429,8 @@
</span><span class="cx">         invalidateCachedTime();
</span><span class="cx"> 
</span><span class="cx">         if (playerPaused) {
</span><ins>+            m_mediaSession-&gt;clientWillBeginPlayback();
+
</ins><span class="cx">             if (m_mediaSession-&gt;requiresFullscreenForVideoPlayback(*this) &amp;&amp; !isFullscreen())
</span><span class="cx">                 enterFullscreen();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformSystemSleepListenercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/SystemSleepListener.cpp (0 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SystemSleepListener.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/SystemSleepListener.cpp        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;SystemSleepListener.h&quot;
+
+namespace WebCore {
+
+#if !PLATFORM(MAC)
+std::unique_ptr&lt;SystemSleepListener&gt; SystemSleepListener::create(Client&amp; client)
+{
+    return std::unique_ptr&lt;SystemSleepListener&gt;(new SystemSleepListener(client));
+}
+#endif
+
+SystemSleepListener::SystemSleepListener(Client&amp; client)
+    : m_client(client)
+{
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformSystemSleepListenerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/SystemSleepListener.h (0 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SystemSleepListener.h                                (rev 0)
+++ trunk/Source/WebCore/platform/SystemSleepListener.h        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SystemSleepListener_h
+#define SystemSleepListener_h
+
+namespace WebCore {
+
+class SystemSleepListener {
+public:
+    class Client {
+    public:
+        virtual ~Client() { }
+        virtual void systemWillSleep() = 0;
+        virtual void systemDidWake() = 0;
+    };
+
+    static std::unique_ptr&lt;SystemSleepListener&gt; create(Client&amp;);
+    virtual ~SystemSleepListener() { }
+
+    Client&amp; client() { return m_client; }
+
+protected:
+    SystemSleepListener(Client&amp;);
+    
+    Client&amp; m_client;
+};
+
+}
+
+
+#endif // SystemSleepListener_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -42,7 +42,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> MediaSessionManager::MediaSessionManager()
</span><del>-    : m_interrupted(false)
</del><ins>+    : m_systemSleepListener(SystemSleepListener::create(*this))
+    , m_interrupted(false)
</ins><span class="cx"> {
</span><span class="cx">     resetRestrictions();
</span><span class="cx"> }
</span><span class="lines">@@ -301,6 +302,24 @@
</span><span class="cx">     m_clients.remove(m_clients.find(client));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaSessionManager::systemWillSleep()
+{
+    if (m_interrupted)
+        return;
+
+    for (auto session : m_sessions)
+        session-&gt;beginInterruption();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaSessionManager::systemDidWake()
+{
+    if (m_interrupted)
+        return;
+
+    for (auto session : m_sessions)
+        session-&gt;endInterruption(MediaSession::MayResumePlaying);
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.h (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;MediaSession.h&quot;
</span><span class="cx"> #include &quot;RemoteCommandListener.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &quot;SystemSleepListener.h&quot;
</ins><span class="cx"> #include &lt;map&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -51,7 +52,7 @@
</span><span class="cx">     MediaSessionManagerClient() { }
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class MediaSessionManager : RemoteCommandListenerClient {
</del><ins>+class MediaSessionManager : RemoteCommandListenerClient, SystemSleepListener::Client {
</ins><span class="cx"> public:
</span><span class="cx">     static MediaSessionManager&amp; sharedManager();
</span><span class="cx">     virtual ~MediaSessionManager() { }
</span><span class="lines">@@ -105,13 +106,19 @@
</span><span class="cx">     MediaSession* currentSession();
</span><span class="cx">     
</span><span class="cx"> private:
</span><ins>+    friend class Internals;
+
</ins><span class="cx">     void updateSessionState();
</span><span class="cx"> 
</span><ins>+    virtual void systemWillSleep();
+    virtual void systemDidWake();
+
</ins><span class="cx">     SessionRestrictions m_restrictions[MediaSession::WebAudio + 1];
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;MediaSession*&gt; m_sessions;
</span><span class="cx">     Vector&lt;MediaSessionManagerClient*&gt; m_clients;
</span><span class="cx">     std::unique_ptr&lt;RemoteCommandListener&gt; m_remoteCommandListener;
</span><ins>+    std::unique_ptr&lt;SystemSleepListener&gt; m_systemSleepListener;
</ins><span class="cx">     bool m_interrupted;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacSystemSleepListenerMach"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.h (0 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.h                                (rev 0)
+++ trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.h        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SystemSleepListenerMac_h
+#define SystemSleepListenerMac_h
+
+#if PLATFORM(MAC)
+
+#include &quot;SystemSleepListener.h&quot;
+
+#include &lt;wtf/WeakPtr.h&gt;
+
+namespace WebCore {
+
+class SystemSleepListenerMac : public SystemSleepListener {
+protected:
+    SystemSleepListenerMac(Client&amp;);
+    virtual ~SystemSleepListenerMac();
+
+    friend std::unique_ptr&lt;SystemSleepListener&gt; SystemSleepListener::create(Client&amp;);
+
+    WeakPtrFactory&lt;SystemSleepListenerMac&gt; m_weakPtrFactory;
+    id m_sleepObserver;
+    id m_wakeObserver;
+};
+
+}
+
+#endif // PLATFORM(MAC)
+
+#endif // SystemSleepListenerMac_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacSystemSleepListenerMacmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.mm (0 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/mac/SystemSleepListenerMac.mm        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -0,0 +1,75 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;SystemSleepListenerMac.h&quot;
+
+#if PLATFORM(MAC)
+
+#import &lt;wtf/MainThread.h&gt;
+
+namespace WebCore {
+
+std::unique_ptr&lt;SystemSleepListener&gt; SystemSleepListener::create(Client&amp; client)
+{
+    return std::unique_ptr&lt;SystemSleepListener&gt;(new SystemSleepListenerMac(client));
+}
+
+SystemSleepListenerMac::SystemSleepListenerMac(Client&amp; client)
+    : SystemSleepListener(client)
+    , m_weakPtrFactory(this)
+    , m_sleepObserver(nil)
+    , m_wakeObserver(nil)
+{
+    NSNotificationCenter *center = [[NSWorkspace sharedWorkspace] notificationCenter];
+    NSOperationQueue *queue = [NSOperationQueue mainQueue];
+
+    auto weakThis = m_weakPtrFactory.createWeakPtr();
+
+    m_sleepObserver = [center addObserverForName:NSWorkspaceWillSleepNotification object:nil queue:queue usingBlock:^(NSNotification *) {
+        callOnMainThread([weakThis] {
+            if (weakThis)
+                weakThis-&gt;m_client.systemWillSleep();
+        });
+    }];
+
+    m_wakeObserver = [center addObserverForName:NSWorkspaceDidWakeNotification object:nil queue:queue usingBlock:^(NSNotification *) {
+        callOnMainThread([weakThis] {
+            if (weakThis)
+                weakThis-&gt;m_client.systemDidWake();
+        });
+    }];
+}
+
+SystemSleepListenerMac::~SystemSleepListenerMac()
+{
+    NSNotificationCenter* center = [[NSWorkspace sharedWorkspace] notificationCenter];
+    [center removeObserver:m_sleepObserver];
+    [center removeObserver:m_wakeObserver];
+}
+
+}
+
+#endif // PLATFORM(MAC)
</ins></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/testing/Internals.cpp        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -2333,4 +2333,14 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(VIDEO)
</span><span class="cx"> 
</span><ins>+void Internals::simulateSystemSleep() const
+{
+    MediaSessionManager::sharedManager().systemWillSleep();
</ins><span class="cx"> }
</span><ins>+
+void Internals::simulateSystemWake() const
+{
+    MediaSessionManager::sharedManager().systemDidWake();
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/testing/Internals.h        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -340,6 +340,9 @@
</span><span class="cx">     void postRemoteControlCommand(const String&amp;, ExceptionCode&amp;);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    void simulateSystemSleep() const;
+    void simulateSystemWake() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit Internals(Document*);
</span><span class="cx">     Document* contextDocument() const;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (166260 => 166261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2014-03-25 22:20:02 UTC (rev 166260)
+++ trunk/Source/WebCore/testing/Internals.idl        2014-03-25 22:26:34 UTC (rev 166261)
</span><span class="lines">@@ -286,4 +286,7 @@
</span><span class="cx">     [Conditional=VIDEO] void applicationWillEnterBackground();
</span><span class="cx">     [Conditional=VIDEO, RaisesException] void setMediaSessionRestrictions(DOMString mediaType, DOMString restrictions);
</span><span class="cx">     [Conditional=VIDEO, RaisesException] void postRemoteControlCommand(DOMString command);
</span><ins>+    
+    [Conditional=VIDEO] void simulateSystemSleep();
+    [Conditional=VIDEO] void simulateSystemWake();
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>