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

Unified Diff: third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp

Issue 2004243002: Migrate websockets from url+lineNumber to SourceLocation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@more-source-location-1
Patch Set: rebased Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp
diff --git a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp
index 80ef3fb80676318b61fce8fb9e29ee83a423d974..66273a0c03e95e5c69d6674a4b0636536853b89d 100644
--- a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp
+++ b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp
@@ -104,12 +104,11 @@ private:
bool m_connectRequestResult;
};
-WorkerWebSocketChannel::WorkerWebSocketChannel(WorkerGlobalScope& workerGlobalScope, WebSocketChannelClient* client, const String& sourceURL, unsigned lineNumber)
+WorkerWebSocketChannel::WorkerWebSocketChannel(WorkerGlobalScope& workerGlobalScope, WebSocketChannelClient* client, PassOwnPtr<SourceLocation> location)
: m_bridge(new Bridge(client, workerGlobalScope))
- , m_sourceURLAtConnection(sourceURL)
- , m_lineNumberAtConnection(lineNumber)
+ , m_locationAtConnection(std::move(location))
{
- m_bridge->initialize(sourceURL, lineNumber);
+ m_bridge->initialize(m_locationAtConnection->clone());
}
WorkerWebSocketChannel::~WorkerWebSocketChannel()
@@ -147,24 +146,21 @@ void WorkerWebSocketChannel::close(int code, const String& reason)
m_bridge->close(code, reason);
}
-void WorkerWebSocketChannel::fail(const String& reason, MessageLevel level, const String& sourceURL, unsigned lineNumber)
+void WorkerWebSocketChannel::fail(const String& reason, MessageLevel level, PassOwnPtr<SourceLocation> location)
{
if (!m_bridge)
return;
- RefPtr<ScriptCallStack> callStack = ScriptCallStack::capture(1);
- if (callStack && !callStack->isEmpty()) {
- // In order to emulate the ConsoleMessage behavior,
- // we should ignore the specified url and line number if
- // we can get the JavaScript context.
- m_bridge->fail(reason, level, callStack->topSourceURL(), callStack->topLineNumber());
- } else if (sourceURL.isEmpty() && !lineNumber) {
+ OwnPtr<SourceLocation> capturedLocation = SourceLocation::capture();
+ if (!capturedLocation->isEmpty()) {
yhirano 2016/05/24 11:30:18 Can you leave some comments saying we ignore the p
dgozman 2016/05/24 22:12:50 Done.
+ m_bridge->fail(reason, level, std::move(capturedLocation));
+ } else if (!location || location->isEmpty()) {
// No information is specified by the caller - use the url
// and the line number at the connection.
- m_bridge->fail(reason, level, m_sourceURLAtConnection, m_lineNumberAtConnection);
+ m_bridge->fail(reason, level, m_locationAtConnection->clone());
} else {
// Use the specified information.
- m_bridge->fail(reason, level, sourceURL, lineNumber);
+ m_bridge->fail(reason, level, std::move(location));
}
}
@@ -194,11 +190,11 @@ Peer::~Peer()
ASSERT(!isMainThread());
}
-void Peer::initialize(const String& sourceURL, unsigned lineNumber, ExecutionContext* context)
+void Peer::initialize(PassOwnPtr<SourceLocation> location, ExecutionContext* context)
{
ASSERT(isMainThread());
Document* document = toDocument(context);
- m_mainWebSocketChannel = DocumentWebSocketChannel::create(document, this, sourceURL, lineNumber);
+ m_mainWebSocketChannel = DocumentWebSocketChannel::create(document, this, std::move(location));
m_syncHelper->signalWorkerThread();
}
@@ -245,13 +241,13 @@ void Peer::close(int code, const String& reason)
m_mainWebSocketChannel->close(code, reason);
}
-void Peer::fail(const String& reason, MessageLevel level, const String& sourceURL, unsigned lineNumber)
+void Peer::fail(const String& reason, MessageLevel level, PassOwnPtr<SourceLocation> location)
{
ASSERT(isMainThread());
ASSERT(m_syncHelper);
if (!m_mainWebSocketChannel)
return;
- m_mainWebSocketChannel->fail(reason, level, sourceURL, lineNumber);
+ m_mainWebSocketChannel->fail(reason, level, std::move(location));
}
void Peer::disconnect()
@@ -382,9 +378,9 @@ Bridge::~Bridge()
ASSERT(!m_peer);
}
-void Bridge::initialize(const String& sourceURL, unsigned lineNumber)
+void Bridge::initialize(PassOwnPtr<SourceLocation> location)
{
- if (!waitForMethodCompletion(createCrossThreadTask(&Peer::initialize, wrapCrossThreadPersistent(m_peer.get()), sourceURL, lineNumber))) {
+ if (!waitForMethodCompletion(createCrossThreadTask(&Peer::initialize, wrapCrossThreadPersistent(m_peer.get()), passed(std::move(location))))) {
// The worker thread has been signalled to shutdown before method completion.
disconnect();
}
@@ -434,10 +430,10 @@ void Bridge::close(int code, const String& reason)
m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, wrapCrossThreadPersistent(m_peer.get()), code, reason));
}
-void Bridge::fail(const String& reason, MessageLevel level, const String& sourceURL, unsigned lineNumber)
+void Bridge::fail(const String& reason, MessageLevel level, PassOwnPtr<SourceLocation> location)
{
ASSERT(m_peer);
- m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, wrapCrossThreadPersistent(m_peer.get()), reason, level, sourceURL, lineNumber));
+ m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, wrapCrossThreadPersistent(m_peer.get()), reason, level, passed(std::move(location))));
}
void Bridge::disconnect()

Powered by Google App Engine
This is Rietveld 408576698