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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/WebSocketChannel.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, 6 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) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/websockets/WebSocketChannel.h" 31 #include "modules/websockets/WebSocketChannel.h"
32 32
33 #include "bindings/core/v8/ScriptCallStack.h" 33 #include "bindings/core/v8/SourceLocation.h"
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/ExecutionContext.h" 35 #include "core/dom/ExecutionContext.h"
36 #include "core/workers/WorkerGlobalScope.h" 36 #include "core/workers/WorkerGlobalScope.h"
37 #include "core/workers/WorkerThread.h" 37 #include "core/workers/WorkerThread.h"
38 #include "modules/websockets/DocumentWebSocketChannel.h" 38 #include "modules/websockets/DocumentWebSocketChannel.h"
39 #include "modules/websockets/WebSocketChannelClient.h" 39 #include "modules/websockets/WebSocketChannelClient.h"
40 #include "modules/websockets/WorkerWebSocketChannel.h" 40 #include "modules/websockets/WorkerWebSocketChannel.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 WebSocketChannel* WebSocketChannel::create(ExecutionContext* context, WebSocketC hannelClient* client) 44 WebSocketChannel* WebSocketChannel::create(ExecutionContext* context, WebSocketC hannelClient* client)
45 { 45 {
46 ASSERT(context); 46 ASSERT(context);
47 ASSERT(client); 47 ASSERT(client);
48 48
49 String sourceURL; 49 OwnPtr<SourceLocation> location = SourceLocation::capture(context);
50 unsigned lineNumber = 0;
51 RefPtr<ScriptCallStack> callStack = ScriptCallStack::capture(1);
52 if (callStack && !callStack->isEmpty()) {
53 sourceURL = callStack->topSourceURL();
54 lineNumber = callStack->topLineNumber();
55 }
56 50
57 if (context->isWorkerGlobalScope()) { 51 if (context->isWorkerGlobalScope()) {
58 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); 52 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
59 return WorkerWebSocketChannel::create(*workerGlobalScope, client, source URL, lineNumber); 53 return WorkerWebSocketChannel::create(*workerGlobalScope, client, std::m ove(location));
60 } 54 }
61 55
62 Document* document = toDocument(context); 56 Document* document = toDocument(context);
63 return DocumentWebSocketChannel::create(document, client, sourceURL, lineNum ber); 57 return DocumentWebSocketChannel::create(document, client, std::move(location ));
64 } 58 }
65 59
66 } // namespace blink 60 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698