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

Side by Side Diff: src/inspector/V8ConsoleAgentImpl.cpp

Issue 2300823002: Revert of [inspector] Initial import of v8_inspector. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « src/inspector/V8ConsoleAgentImpl.h ('k') | src/inspector/V8ConsoleMessage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project 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 #include "src/inspector/V8ConsoleAgentImpl.h"
6
7 #include "src/inspector/V8ConsoleMessage.h"
8 #include "src/inspector/V8InspectorImpl.h"
9 #include "src/inspector/V8InspectorSessionImpl.h"
10 #include "src/inspector/V8StackTraceImpl.h"
11 #include "src/inspector/protocol/Protocol.h"
12
13 namespace v8_inspector {
14
15 namespace ConsoleAgentState {
16 static const char consoleEnabled[] = "consoleEnabled";
17 }
18
19 V8ConsoleAgentImpl::V8ConsoleAgentImpl(V8InspectorSessionImpl* session, protocol ::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
20 : m_session(session)
21 , m_state(state)
22 , m_frontend(frontendChannel)
23 , m_enabled(false)
24 {
25 }
26
27 V8ConsoleAgentImpl::~V8ConsoleAgentImpl()
28 {
29 }
30
31 void V8ConsoleAgentImpl::enable(ErrorString* errorString)
32 {
33 if (m_enabled)
34 return;
35 m_state->setBoolean(ConsoleAgentState::consoleEnabled, true);
36 m_enabled = true;
37 m_session->inspector()->enableStackCapturingIfNeeded();
38 reportAllMessages();
39 }
40
41 void V8ConsoleAgentImpl::disable(ErrorString* errorString)
42 {
43 if (!m_enabled)
44 return;
45 m_session->inspector()->disableStackCapturingIfNeeded();
46 m_state->setBoolean(ConsoleAgentState::consoleEnabled, false);
47 m_enabled = false;
48 }
49
50 void V8ConsoleAgentImpl::clearMessages(ErrorString* errorString)
51 {
52 }
53
54 void V8ConsoleAgentImpl::restore()
55 {
56 if (!m_state->booleanProperty(ConsoleAgentState::consoleEnabled, false))
57 return;
58 ErrorString ignored;
59 enable(&ignored);
60 }
61
62 void V8ConsoleAgentImpl::messageAdded(V8ConsoleMessage* message)
63 {
64 if (m_enabled)
65 reportMessage(message, true);
66 }
67
68 bool V8ConsoleAgentImpl::enabled()
69 {
70 return m_enabled;
71 }
72
73 void V8ConsoleAgentImpl::reportAllMessages()
74 {
75 V8ConsoleMessageStorage* storage = m_session->inspector()->ensureConsoleMess ageStorage(m_session->contextGroupId());
76 for (const auto& message : storage->messages()) {
77 if (message->origin() == V8MessageOrigin::kConsole)
78 reportMessage(message.get(), false);
79 }
80 }
81
82 void V8ConsoleAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP review)
83 {
84 DCHECK(message->origin() == V8MessageOrigin::kConsole);
85 message->reportToFrontend(&m_frontend);
86 m_frontend.flush();
87 }
88
89 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/V8ConsoleAgentImpl.h ('k') | src/inspector/V8ConsoleMessage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698