OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 ConsoleMessage_h | 5 #ifndef ConsoleMessage_h |
6 #define ConsoleMessage_h | 6 #define ConsoleMessage_h |
7 | 7 |
| 8 #include "bindings/core/v8/ScriptCallStack.h" |
8 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
10 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
11 #include "platform/v8_inspector/public/ConsoleAPITypes.h" | 12 #include "platform/v8_inspector/public/ConsoleAPITypes.h" |
12 #include "platform/v8_inspector/public/ConsoleTypes.h" | 13 #include "platform/v8_inspector/public/ConsoleTypes.h" |
13 #include "wtf/Forward.h" | 14 #include "wtf/Forward.h" |
14 #include "wtf/PassRefPtr.h" | 15 #include "wtf/PassRefPtr.h" |
15 #include "wtf/RefCounted.h" | 16 #include "wtf/RefCounted.h" |
16 #include "wtf/text/WTFString.h" | 17 #include "wtf/text/WTFString.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 | 20 |
20 class ScriptArguments; | 21 class ScriptArguments; |
21 class ScriptCallStack; | |
22 class ScriptState; | 22 class ScriptState; |
23 class WorkerInspectorProxy; | 23 class WorkerInspectorProxy; |
24 | 24 |
25 class CORE_EXPORT ConsoleMessage final: public GarbageCollectedFinalized<Console
Message> { | 25 class CORE_EXPORT ConsoleMessage final: public GarbageCollectedFinalized<Console
Message> { |
26 public: | 26 public: |
27 static ConsoleMessage* create(MessageSource source, MessageLevel level, cons
t String& message, const String& url, unsigned lineNumber, unsigned columnNumber
= 0) | 27 // Callstack may be empty. Zero lineNumber or columnNumber means unknown. |
28 { | 28 static ConsoleMessage* create(MessageSource, MessageLevel, const String& mes
sage, const String& url, unsigned lineNumber, unsigned columnNumber, PassRefPtr<
ScriptCallStack>, int scriptId = 0); |
29 return new ConsoleMessage(source, level, message, url, lineNumber, colum
nNumber); | |
30 } | |
31 | 29 |
32 static ConsoleMessage* create(MessageSource source, MessageLevel level, cons
t String& message) | 30 // Shortcut when callstack is unavailable. |
33 { | 31 static ConsoleMessage* create(MessageSource, MessageLevel, const String& mes
sage, const String& url, unsigned lineNumber, unsigned columnNumber); |
34 ConsoleMessage* consoleMessage = new ConsoleMessage(source, level, messa
ge, String(), 0, 0); | 32 |
35 consoleMessage->collectCallStack(); | 33 // This method tries to capture callstack if possible and falls back to prov
ided location. |
36 return consoleMessage; | 34 static ConsoleMessage* createWithCallStack(MessageSource, MessageLevel, cons
t String& message, const String& url, unsigned lineNumber, unsigned columnNumber
); |
37 } | 35 |
| 36 // Shortcut when location is unavailable. This method captures callstack. |
| 37 static ConsoleMessage* create(MessageSource, MessageLevel, const String& mes
sage); |
38 | 38 |
39 ~ConsoleMessage(); | 39 ~ConsoleMessage(); |
40 | 40 |
41 MessageType type() const; | 41 MessageType type() const; |
42 void setType(MessageType); | 42 void setType(MessageType); |
43 int scriptId() const; | 43 int scriptId() const; |
44 void setScriptId(int); | |
45 const String& url() const; | 44 const String& url() const; |
46 void setURL(const String&); | 45 void setURL(const String&); |
47 unsigned lineNumber() const; | 46 unsigned lineNumber() const; |
48 void setLineNumber(unsigned); | 47 void setLineNumber(unsigned); |
49 unsigned columnNumber() const; | 48 unsigned columnNumber() const; |
50 void setColumnNumber(unsigned); | 49 void setColumnNumber(unsigned); |
51 PassRefPtr<ScriptCallStack> callStack() const; | 50 PassRefPtr<ScriptCallStack> callStack() const; |
52 void setCallStack(PassRefPtr<ScriptCallStack>); | |
53 ScriptState* getScriptState() const; | 51 ScriptState* getScriptState() const; |
54 void setScriptState(ScriptState*); | 52 void setScriptState(ScriptState*); |
55 ScriptArguments* scriptArguments() const; | 53 ScriptArguments* scriptArguments() const; |
56 void setScriptArguments(ScriptArguments*); | 54 void setScriptArguments(ScriptArguments*); |
57 unsigned long requestIdentifier() const; | 55 unsigned long requestIdentifier() const; |
58 void setRequestIdentifier(unsigned long); | 56 void setRequestIdentifier(unsigned long); |
59 double timestamp() const; | 57 double timestamp() const; |
60 void setTimestamp(double); | 58 void setTimestamp(double); |
61 WorkerInspectorProxy* workerInspectorProxy() { return m_workerProxy; } | 59 WorkerInspectorProxy* workerInspectorProxy() { return m_workerProxy; } |
62 void setWorkerInspectorProxy(WorkerInspectorProxy* proxy) { m_workerProxy =
proxy; } | 60 void setWorkerInspectorProxy(WorkerInspectorProxy* proxy) { m_workerProxy =
proxy; } |
63 unsigned assignMessageId(); | 61 unsigned assignMessageId(); |
64 unsigned messageId() const { return m_messageId; } | 62 unsigned messageId() const { return m_messageId; } |
65 unsigned relatedMessageId() const { return m_relatedMessageId; } | 63 unsigned relatedMessageId() const { return m_relatedMessageId; } |
66 void setRelatedMessageId(unsigned relatedMessageId) { m_relatedMessageId = r
elatedMessageId; } | 64 void setRelatedMessageId(unsigned relatedMessageId) { m_relatedMessageId = r
elatedMessageId; } |
67 | 65 |
68 MessageSource source() const; | 66 MessageSource source() const; |
69 MessageLevel level() const; | 67 MessageLevel level() const; |
70 const String& message() const; | 68 const String& message() const; |
71 | 69 |
72 void frameWindowDiscarded(LocalDOMWindow*); | 70 void frameWindowDiscarded(LocalDOMWindow*); |
73 unsigned argumentCount(); | 71 unsigned argumentCount(); |
74 | 72 |
75 void collectCallStack(); | |
76 | |
77 DECLARE_TRACE(); | 73 DECLARE_TRACE(); |
78 | 74 |
79 private: | 75 private: |
80 ConsoleMessage(MessageSource, MessageLevel, const String& message, const Str
ing& url = String(), unsigned lineNumber = 0, unsigned columnNumber = 0); | 76 ConsoleMessage(MessageSource, MessageLevel, const String& message, const Str
ing& url, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack
>, int scriptId); |
81 | 77 |
82 MessageSource m_source; | 78 MessageSource m_source; |
83 MessageLevel m_level; | 79 MessageLevel m_level; |
84 MessageType m_type; | 80 MessageType m_type; |
85 String m_message; | 81 String m_message; |
86 int m_scriptId; | 82 int m_scriptId; |
87 String m_url; | 83 String m_url; |
88 unsigned m_lineNumber; | 84 unsigned m_lineNumber; |
89 unsigned m_columnNumber; | 85 unsigned m_columnNumber; |
90 RefPtr<ScriptCallStack> m_callStack; | 86 RefPtr<ScriptCallStack> m_callStack; |
91 OwnPtr<ScriptStateProtectingContext> m_scriptState; | 87 OwnPtr<ScriptStateProtectingContext> m_scriptState; |
92 Member<ScriptArguments> m_scriptArguments; | 88 Member<ScriptArguments> m_scriptArguments; |
93 unsigned long m_requestIdentifier; | 89 unsigned long m_requestIdentifier; |
94 double m_timestamp; | 90 double m_timestamp; |
95 Member<WorkerInspectorProxy> m_workerProxy; | 91 Member<WorkerInspectorProxy> m_workerProxy; |
96 unsigned m_messageId; | 92 unsigned m_messageId; |
97 unsigned m_relatedMessageId; | 93 unsigned m_relatedMessageId; |
98 }; | 94 }; |
99 | 95 |
100 } // namespace blink | 96 } // namespace blink |
101 | 97 |
102 #endif // ConsoleMessage_h | 98 #endif // ConsoleMessage_h |
OLD | NEW |