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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.h

Issue 1989363005: Graceful idle callback cancellation with invalid IDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ScriptedIdleTaskController_h 5 #ifndef ScriptedIdleTaskController_h
6 #define ScriptedIdleTaskController_h 6 #define ScriptedIdleTaskController_h
7 7
8 #include "core/dom/ActiveDOMObject.h" 8 #include "core/dom/ActiveDOMObject.h"
9 #include "core/dom/IdleDeadline.h" 9 #include "core/dom/IdleDeadline.h"
10 #include "platform/Timer.h" 10 #include "platform/Timer.h"
(...skipping 25 matching lines...) Expand all
36 // ActiveDOMObject interface. 36 // ActiveDOMObject interface.
37 void stop() override; 37 void stop() override;
38 void suspend() override; 38 void suspend() override;
39 void resume() override; 39 void resume() override;
40 40
41 void callbackFired(CallbackId, double deadlineSeconds, IdleDeadline::Callbac kType); 41 void callbackFired(CallbackId, double deadlineSeconds, IdleDeadline::Callbac kType);
42 42
43 private: 43 private:
44 explicit ScriptedIdleTaskController(ExecutionContext*); 44 explicit ScriptedIdleTaskController(ExecutionContext*);
45 45
46 int nextCallbackId();
47
48 bool isValidCallbackId(int id)
49 {
50 using Traits = HashTraits<CallbackId>;
51 return !Traits::isDeletedValue(id) && !WTF::isHashTraitsEmptyValue<Trait s, CallbackId>(id);
52 }
53
46 void runCallback(CallbackId, double deadlineSeconds, IdleDeadline::CallbackT ype); 54 void runCallback(CallbackId, double deadlineSeconds, IdleDeadline::CallbackT ype);
47 55
48 WebScheduler* m_scheduler; // Not owned. 56 WebScheduler* m_scheduler; // Not owned.
49 HeapHashMap<CallbackId, Member<IdleRequestCallback>> m_callbacks; 57 HeapHashMap<CallbackId, Member<IdleRequestCallback>> m_callbacks;
50 Vector<CallbackId> m_pendingTimeouts; 58 Vector<CallbackId> m_pendingTimeouts;
51 CallbackId m_nextCallbackId; 59 CallbackId m_nextCallbackId;
52 bool m_suspended; 60 bool m_suspended;
53 }; 61 };
54 62
55 } // namespace blink 63 } // namespace blink
56 64
57 #endif // ScriptedIdleTaskController_h 65 #endif // ScriptedIdleTaskController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698