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 ConsoleMessageStorage_h 6 #define ConsoleMessageStorage_h 7 8 #include "core/inspector/ConsoleMessage.h" 9 #include "platform/heap/Handle.h" 10 #include "wtf/Forward.h" 11 12 namespace blink { 13 14 class LocalDOMWindow; 15 class WorkerGlobalScopeProxy; 16 17 class ConsoleMessageStorage FINAL : public NoBaseWillBeGarbageCollected<ConsoleMessageStorage> { 18 WTF_MAKE_NONCOPYABLE(ConsoleMessageStorage); 19 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; 20 public: 21 static PassOwnPtrWillBeRawPtr<ConsoleMessageStorage> createForWorker(ExecutionContext* context) 22 { 23 return adoptPtrWillBeNoop(new ConsoleMessageStorage(context)); 24 } 25 26 static PassOwnPtrWillBeRawPtr<ConsoleMessageStorage> createForFrame(LocalFrame* frame) 27 { 28 return adoptPtrWillBeNoop(new ConsoleMessageStorage(frame)); 29 } 30 31 void reportMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>); 32 void clear(); 33 34 Vector<unsigned> argumentCounts() const; 35 36 void adoptWorkerMessagesAfterTermination(WorkerGlobalScopeProxy*); 37 void frameWindowDiscarded(LocalDOMWindow*); 38 39 size_t size() const; 40 ConsoleMessage* at(size_t index) const; 41 42 int expiredCount() const; 43 44 void trace(Visitor*); 45 46 private: 47 explicit ConsoleMessageStorage(ExecutionContext*); 48 explicit ConsoleMessageStorage(LocalFrame*); 49 50 ExecutionContext* executionContext() const; 51 52 int m_expiredCount; 53 WillBeHeapDeque<RefPtrWillBeMember<ConsoleMessage> > m_messages; 54 RawPtrWillBeMember<ExecutionContext> m_context; 55 RawPtrWillBeMember<LocalFrame> m_frame; 56 }; 57 58 } // namespace blink 59 60 #endif // ConsoleMessageStorage_h 61