OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2012 Google Inc. All Rights 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 | 253 |
254 int ScriptExecutionContext::circularSequentialID() | 254 int ScriptExecutionContext::circularSequentialID() |
255 { | 255 { |
256 ++m_circularSequentialID; | 256 ++m_circularSequentialID; |
257 if (m_circularSequentialID <= 0) | 257 if (m_circularSequentialID <= 0) |
258 m_circularSequentialID = 1; | 258 m_circularSequentialID = 1; |
259 return m_circularSequentialID; | 259 return m_circularSequentialID; |
260 } | 260 } |
261 | 261 |
262 int ScriptExecutionContext::installNewTimeout(PassOwnPtr<ScheduledAction> action
, int timeout, bool singleShot) | 262 int ScriptExecutionContext::installNewTimeout(DOMTimer::Type timerType, PassOwnP
tr<ScheduledAction> action, int timeout) |
263 { | 263 { |
264 int timeoutID; | 264 int timeoutID; |
265 while (true) { | 265 while (true) { |
266 timeoutID = circularSequentialID(); | 266 timeoutID = circularSequentialID(); |
267 if (!m_timeouts.contains(timeoutID)) | 267 if (!m_timeouts.contains(timeoutID)) |
268 break; | 268 break; |
269 } | 269 } |
270 TimeoutMap::AddResult result = m_timeouts.add(timeoutID, DOMTimer::create(th
is, action, timeout, singleShot, timeoutID)); | 270 TimeoutMap::AddResult result = m_timeouts.add(timeoutID, DOMTimer::create(th
is, timerType, action, timeout, timeoutID)); |
271 ASSERT(result.isNewEntry); | 271 ASSERT(result.isNewEntry); |
272 DOMTimer* timer = result.iterator->value.get(); | 272 DOMTimer* timer = result.iterator->value.get(); |
273 | 273 |
274 timer->suspendIfNeeded(); | 274 timer->suspendIfNeeded(); |
275 | 275 |
276 return timer->timeoutID(); | 276 return timeoutID; |
277 } | 277 } |
278 | 278 |
279 void ScriptExecutionContext::removeTimeoutByID(int timeoutID) | 279 bool ScriptExecutionContext::removeTimeoutByIDIfTypeMatches(DOMTimer::Type timer
Type, int timeoutID) |
280 { | 280 { |
281 if (timeoutID <= 0) | 281 if (timeoutID <= 0) |
282 return; | 282 return false; |
283 m_timeouts.remove(timeoutID); | 283 TimeoutMap::iterator iter = m_timeouts.find(timeoutID); |
| 284 if (iter != m_timeouts.end() && iter->value->type() == timerType) { |
| 285 m_timeouts.remove(iter); |
| 286 return true; |
| 287 } |
| 288 return false; |
284 } | 289 } |
285 | 290 |
286 PublicURLManager& ScriptExecutionContext::publicURLManager() | 291 PublicURLManager& ScriptExecutionContext::publicURLManager() |
287 { | 292 { |
288 if (!m_publicURLManager) | 293 if (!m_publicURLManager) |
289 m_publicURLManager = PublicURLManager::create(this); | 294 m_publicURLManager = PublicURLManager::create(this); |
290 return *m_publicURLManager; | 295 return *m_publicURLManager; |
291 } | 296 } |
292 | 297 |
293 void ScriptExecutionContext::didChangeTimerAlignmentInterval() | 298 void ScriptExecutionContext::didChangeTimerAlignmentInterval() |
(...skipping 20 matching lines...) Expand all Loading... |
314 ScriptExecutionContext::Task::~Task() | 319 ScriptExecutionContext::Task::~Task() |
315 { | 320 { |
316 } | 321 } |
317 | 322 |
318 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext
) | 323 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext
) |
319 { | 324 { |
320 m_databaseContext = databaseContext; | 325 m_databaseContext = databaseContext; |
321 } | 326 } |
322 | 327 |
323 } // namespace WebCore | 328 } // namespace WebCore |
OLD | NEW |