 Chromium Code Reviews
 Chromium Code Reviews Issue 346273008:
  Gamepad: make gamepad events play well with page visibility  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@gamepad-vis
    
  
    Issue 346273008:
  Gamepad: make gamepad events play well with page visibility  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@gamepad-vis| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are | 
| 6 * met: | 6 * met: | 
| 7 * | 7 * | 
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 // FIXME: runAsync should take a TraceLocation and pass it to timer here . | 67 // FIXME: runAsync should take a TraceLocation and pass it to timer here . | 
| 68 if (!m_timer.isActive()) | 68 if (!m_timer.isActive()) | 
| 69 m_timer.startOneShot(0, FROM_HERE); | 69 m_timer.startOneShot(0, FROM_HERE); | 
| 70 } | 70 } | 
| 71 | 71 | 
| 72 // If it's scheduled to run the method, cancel it and remember to schedule | 72 // If it's scheduled to run the method, cancel it and remember to schedule | 
| 73 // it again when resume() is called. Mainly for implementing | 73 // it again when resume() is called. Mainly for implementing | 
| 74 // ActiveDOMObject::suspend(). | 74 // ActiveDOMObject::suspend(). | 
| 75 void suspend() | 75 void suspend() | 
| 76 { | 76 { | 
| 77 ASSERT(!m_suspended); | 77 if (m_suspended) | 
| 78 return; | |
| 
kbalazs
2014/07/08 21:01:20
FYI I have added this to avoid special casing the
 | |
| 78 m_suspended = true; | 79 m_suspended = true; | 
| 79 | 80 | 
| 80 if (!m_timer.isActive()) | 81 if (!m_timer.isActive()) | 
| 81 return; | 82 return; | 
| 82 | 83 | 
| 83 m_timer.stop(); | 84 m_timer.stop(); | 
| 84 m_runWhenResumed = true; | 85 m_runWhenResumed = true; | 
| 85 } | 86 } | 
| 86 | 87 | 
| 87 // Resumes pending method run. | 88 // Resumes pending method run. | 
| 88 void resume() | 89 void resume() | 
| 89 { | 90 { | 
| 90 ASSERT(m_suspended); | 91 if (!m_suspended) | 
| 92 return; | |
| 91 m_suspended = false; | 93 m_suspended = false; | 
| 92 | 94 | 
| 93 if (!m_runWhenResumed) | 95 if (!m_runWhenResumed) | 
| 94 return; | 96 return; | 
| 95 | 97 | 
| 96 m_runWhenResumed = false; | 98 m_runWhenResumed = false; | 
| 97 // FIXME: resume should take a TraceLocation and pass it to timer here. | 99 // FIXME: resume should take a TraceLocation and pass it to timer here. | 
| 98 m_timer.startOneShot(0, FROM_HERE); | 100 m_timer.startOneShot(0, FROM_HERE); | 
| 99 } | 101 } | 
| 100 | 102 | 
| (...skipping 28 matching lines...) Expand all Loading... | |
| 129 TargetClass* m_object; | 131 TargetClass* m_object; | 
| 130 TargetMethod m_method; | 132 TargetMethod m_method; | 
| 131 | 133 | 
| 132 bool m_suspended; | 134 bool m_suspended; | 
| 133 bool m_runWhenResumed; | 135 bool m_runWhenResumed; | 
| 134 }; | 136 }; | 
| 135 | 137 | 
| 136 } | 138 } | 
| 137 | 139 | 
| 138 #endif | 140 #endif | 
| OLD | NEW |