| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // scheduled. If it's suspended, remember to schedule to run the method when | 57 // scheduled. If it's suspended, remember to schedule to run the method when |
| 58 // resume() is called. | 58 // resume() is called. |
| 59 void runAsync() | 59 void runAsync() |
| 60 { | 60 { |
| 61 if (m_suspended) { | 61 if (m_suspended) { |
| 62 ASSERT(!m_timer.isActive()); | 62 ASSERT(!m_timer.isActive()); |
| 63 m_runWhenResumed = true; | 63 m_runWhenResumed = true; |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // FIXME: runAsync should take a TraceLocation and pass it to timer here
. |
| 67 if (!m_timer.isActive()) | 68 if (!m_timer.isActive()) |
| 68 m_timer.startOneShot(0); | 69 m_timer.startOneShot(0, FROM_HERE); |
| 69 } | 70 } |
| 70 | 71 |
| 71 // 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 |
| 72 // it again when resume() is called. Mainly for implementing | 73 // it again when resume() is called. Mainly for implementing |
| 73 // ActiveDOMObject::suspend(). | 74 // ActiveDOMObject::suspend(). |
| 74 void suspend() | 75 void suspend() |
| 75 { | 76 { |
| 76 ASSERT(!m_suspended); | 77 ASSERT(!m_suspended); |
| 77 m_suspended = true; | 78 m_suspended = true; |
| 78 | 79 |
| 79 if (!m_timer.isActive()) | 80 if (!m_timer.isActive()) |
| 80 return; | 81 return; |
| 81 | 82 |
| 82 m_timer.stop(); | 83 m_timer.stop(); |
| 83 m_runWhenResumed = true; | 84 m_runWhenResumed = true; |
| 84 } | 85 } |
| 85 | 86 |
| 86 // Resumes pending method run. | 87 // Resumes pending method run. |
| 87 void resume() | 88 void resume() |
| 88 { | 89 { |
| 89 ASSERT(m_suspended); | 90 ASSERT(m_suspended); |
| 90 m_suspended = false; | 91 m_suspended = false; |
| 91 | 92 |
| 92 if (!m_runWhenResumed) | 93 if (!m_runWhenResumed) |
| 93 return; | 94 return; |
| 94 | 95 |
| 95 m_runWhenResumed = false; | 96 m_runWhenResumed = false; |
| 96 m_timer.startOneShot(0); | 97 // FIXME: resume should take a TraceLocation and pass it to timer here. |
| 98 m_timer.startOneShot(0, FROM_HERE); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void stop() | 101 void stop() |
| 100 { | 102 { |
| 101 if (m_suspended) { | 103 if (m_suspended) { |
| 102 ASSERT(!m_timer.isActive()); | 104 ASSERT(!m_timer.isActive()); |
| 103 m_runWhenResumed = false; | 105 m_runWhenResumed = false; |
| 104 m_suspended = false; | 106 m_suspended = false; |
| 105 return; | 107 return; |
| 106 } | 108 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 123 TargetClass* m_object; | 125 TargetClass* m_object; |
| 124 TargetMethod m_method; | 126 TargetMethod m_method; |
| 125 | 127 |
| 126 bool m_suspended; | 128 bool m_suspended; |
| 127 bool m_runWhenResumed; | 129 bool m_runWhenResumed; |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 } | 132 } |
| 131 | 133 |
| 132 #endif | 134 #endif |
| OLD | NEW |