Home | History | Annotate | Download | only in custom
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CustomElementMicrotaskRunQueue_h
      6 #define CustomElementMicrotaskRunQueue_h
      7 
      8 #include "platform/heap/Handle.h"
      9 #include "wtf/RefCounted.h"
     10 #include "wtf/WeakPtr.h"
     11 
     12 namespace blink {
     13 
     14 class CustomElementSyncMicrotaskQueue;
     15 class CustomElementAsyncImportMicrotaskQueue;
     16 class CustomElementMicrotaskStep;
     17 class HTMLImportLoader;
     18 
     19 class CustomElementMicrotaskRunQueue : public RefCountedWillBeGarbageCollectedFinalized<CustomElementMicrotaskRunQueue> {
     20     DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementMicrotaskRunQueue)
     21 public:
     22     static PassRefPtrWillBeRawPtr<CustomElementMicrotaskRunQueue> create() { return adoptRefWillBeNoop(new CustomElementMicrotaskRunQueue()); }
     23 
     24     void enqueue(HTMLImportLoader* parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskStep>, bool importIsSync);
     25     void requestDispatchIfNeeded();
     26     bool isEmpty() const;
     27 
     28     void trace(Visitor*);
     29 
     30 #if !defined(NDEBUG)
     31     void show(unsigned indent);
     32 #endif
     33 
     34 private:
     35     static void dispatchIfAlive(WeakPtr<CustomElementMicrotaskRunQueue> self);
     36 
     37     CustomElementMicrotaskRunQueue();
     38 
     39     void dispatch();
     40 
     41     WeakPtrFactory<CustomElementMicrotaskRunQueue> m_weakFactory;
     42     RefPtrWillBeMember<CustomElementSyncMicrotaskQueue> m_syncQueue;
     43     RefPtrWillBeMember<CustomElementAsyncImportMicrotaskQueue> m_asyncQueue;
     44     bool m_dispatchIsPending;
     45 };
     46 
     47 }
     48 
     49 #endif
     50