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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameConsole.cpp

Issue 2151273003: [DevTools] Move browser logging from Console domain to Log domain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@internals-method
Patch Set: protocol improvements Created 4 years, 5 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 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "core/frame/FrameConsole.h" 29 #include "core/frame/FrameConsole.h"
30 30
31 #include "bindings/core/v8/SourceLocation.h" 31 #include "bindings/core/v8/SourceLocation.h"
32 #include "core/frame/FrameHost.h" 32 #include "core/frame/FrameHost.h"
33 #include "core/inspector/ConsoleMessage.h" 33 #include "core/inspector/ConsoleMessage.h"
34 #include "core/inspector/ConsoleMessageStorage.h"
34 #include "core/inspector/MainThreadDebugger.h" 35 #include "core/inspector/MainThreadDebugger.h"
35 #include "core/page/ChromeClient.h" 36 #include "core/page/ChromeClient.h"
36 #include "core/page/Page.h" 37 #include "core/page/Page.h"
37 #include "platform/network/ResourceError.h" 38 #include "platform/network/ResourceError.h"
38 #include "platform/network/ResourceResponse.h" 39 #include "platform/network/ResourceResponse.h"
39 #include "wtf/text/StringBuilder.h" 40 #include "wtf/text/StringBuilder.h"
40 #include <memory> 41 #include <memory>
41 42
42 namespace blink { 43 namespace blink {
43 44
44 FrameConsole::FrameConsole(LocalFrame& frame) 45 FrameConsole::FrameConsole(LocalFrame& frame)
45 : m_frame(&frame) 46 : m_frame(&frame)
46 { 47 {
47 } 48 }
48 49
49 void FrameConsole::addMessage(ConsoleMessage* consoleMessage) 50 void FrameConsole::addMessage(ConsoleMessage* consoleMessage)
50 { 51 {
51 if (addMessageToStorage(consoleMessage)) 52 if (addMessageToStorage(consoleMessage))
52 reportMessageToClient(consoleMessage); 53 reportMessageToClient(consoleMessage);
53 } 54 }
54 55
55 bool FrameConsole::addMessageToStorage(ConsoleMessage* consoleMessage) 56 bool FrameConsole::addMessageToStorage(ConsoleMessage* consoleMessage)
56 { 57 {
57 // TODO(dgozman): drop this check, it's left here to preserve tests output. 58 if (!m_frame->document() || !m_frame->host())
58 if (!m_frame->document())
59 return false; 59 return false;
60 return MainThreadDebugger::instance()->addConsoleMessage(m_frame, consoleMes sage); 60 return m_frame->host()->consoleMessageStorage().addConsoleMessage(m_frame->d ocument(), consoleMessage);
61 } 61 }
62 62
63 void FrameConsole::reportMessageToClient(ConsoleMessage* consoleMessage) 63 void FrameConsole::reportMessageToClient(ConsoleMessage* consoleMessage)
64 { 64 {
65 if (consoleMessage->source() == NetworkMessageSource) 65 if (consoleMessage->source() == NetworkMessageSource)
66 return; 66 return;
67 67
68 String url = consoleMessage->location()->url(); 68 String url = consoleMessage->location()->url();
69 String stackTrace; 69 String stackTrace;
70 if (consoleMessage->source() == ConsoleAPIMessageSource) { 70 if (consoleMessage->source() == ConsoleAPIMessageSource) {
71 if (!frame().host()) 71 if (!m_frame->host())
72 return; 72 return;
73 if (frame().chromeClient().shouldReportDetailedMessageForSource(frame(), url)) { 73 if (m_frame->chromeClient().shouldReportDetailedMessageForSource(*m_fram e, url)) {
74 std::unique_ptr<SourceLocation> location = SourceLocation::captureWi thFullStackTrace(); 74 std::unique_ptr<SourceLocation> location = SourceLocation::captureWi thFullStackTrace();
75 if (!location->isUnknown()) 75 if (!location->isUnknown())
76 stackTrace = location->toString(); 76 stackTrace = location->toString();
77 } 77 }
78 } else { 78 } else {
79 if (!consoleMessage->location()->isUnknown() && frame().chromeClient().s houldReportDetailedMessageForSource(frame(), url)) 79 if (!consoleMessage->location()->isUnknown() && m_frame->chromeClient(). shouldReportDetailedMessageForSource(*m_frame, url))
80 stackTrace = consoleMessage->location()->toString(); 80 stackTrace = consoleMessage->location()->toString();
81 } 81 }
82 82
83 frame().chromeClient().addMessageToConsole(m_frame, consoleMessage->source() , consoleMessage->level(), consoleMessage->message(), consoleMessage->location() ->lineNumber(), url, stackTrace); 83 m_frame->chromeClient().addMessageToConsole(m_frame, consoleMessage->source( ), consoleMessage->level(), consoleMessage->message(), consoleMessage->location( )->lineNumber(), url, stackTrace);
84 } 84 }
85 85
86 void FrameConsole::addMessageFromWorker(ConsoleMessage* consoleMessage, const St ring& workerId) 86 void FrameConsole::addMessageFromWorker(ConsoleMessage* consoleMessage, const St ring& workerId)
87 { 87 {
88 reportMessageToClient(consoleMessage); 88 reportMessageToClient(consoleMessage);
89 addMessageToStorage(ConsoleMessage::createFromWorker(consoleMessage->level() , consoleMessage->message(), consoleMessage->location() ? consoleMessage->locati on()->clone() : nullptr, workerId)); 89 addMessageToStorage(ConsoleMessage::createFromWorker(consoleMessage->level() , consoleMessage->message(), consoleMessage->location() ? consoleMessage->locati on()->clone() : nullptr, workerId));
90 } 90 }
91 91
92 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign ed long requestIdentifier, const ResourceResponse& response) 92 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign ed long requestIdentifier, const ResourceResponse& response)
93 { 93 {
(...skipping 20 matching lines...) Expand all
114 } 114 }
115 addMessageToStorage(ConsoleMessage::createForRequest(NetworkMessageSource, E rrorMessageLevel, message.toString(), error.failingURL(), requestIdentifier)); 115 addMessageToStorage(ConsoleMessage::createForRequest(NetworkMessageSource, E rrorMessageLevel, message.toString(), error.failingURL(), requestIdentifier));
116 } 116 }
117 117
118 DEFINE_TRACE(FrameConsole) 118 DEFINE_TRACE(FrameConsole)
119 { 119 {
120 visitor->trace(m_frame); 120 visitor->trace(m_frame);
121 } 121 }
122 122
123 } // namespace blink 123 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698