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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptSourceCode.cpp

Issue 1667843003: Make Resource RefCountedWillBeGarbageCollectedFinalized, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + address review comments Created 4 years, 10 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "bindings/core/v8/ScriptSourceCode.h" 5 #include "bindings/core/v8/ScriptSourceCode.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 ScriptSourceCode::ScriptSourceCode() 9 ScriptSourceCode::ScriptSourceCode()
10 : m_resource(0) 10 : m_startPosition(TextPosition::minimumPosition())
11 , m_startPosition(TextPosition::minimumPosition())
12 { 11 {
13 } 12 }
14 13
15 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const TextPosition& startPosition) 14 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const TextPosition& startPosition)
16 : ScriptSourceCode(CompressibleString(source.impl()), url, startPosition) 15 : ScriptSourceCode(CompressibleString(source.impl()), url, startPosition)
17 { 16 {
18 } 17 }
19 18
20 ScriptSourceCode::ScriptSourceCode(const CompressibleString& source, const KURL& url, const TextPosition& startPosition) 19 ScriptSourceCode::ScriptSourceCode(const CompressibleString& source, const KURL& url, const TextPosition& startPosition)
21 : m_source(source) 20 : m_source(source)
22 , m_resource(0)
23 , m_url(url) 21 , m_url(url)
24 , m_startPosition(startPosition) 22 , m_startPosition(startPosition)
25 { 23 {
26 treatNullSourceAsEmpty(); 24 treatNullSourceAsEmpty();
27 if (!m_url.isEmpty()) 25 if (!m_url.isEmpty())
28 m_url.removeFragmentIdentifier(); 26 m_url.removeFragmentIdentifier();
29 } 27 }
30 28
31 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) 29 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource)
32 : m_source(resource->script()) 30 : m_source(resource->script())
(...skipping 11 matching lines...) Expand all
44 { 42 {
45 treatNullSourceAsEmpty(); 43 treatNullSourceAsEmpty();
46 } 44 }
47 45
48 ScriptSourceCode::~ScriptSourceCode() 46 ScriptSourceCode::~ScriptSourceCode()
49 { 47 {
50 } 48 }
51 49
52 DEFINE_TRACE(ScriptSourceCode) 50 DEFINE_TRACE(ScriptSourceCode)
53 { 51 {
52 visitor->trace(m_resource);
54 visitor->trace(m_streamer); 53 visitor->trace(m_streamer);
55 } 54 }
56 55
57 const KURL& ScriptSourceCode::url() const 56 const KURL& ScriptSourceCode::url() const
58 { 57 {
59 if (m_url.isEmpty() && m_resource) { 58 if (m_url.isEmpty() && m_resource) {
60 m_url = m_resource->response().url(); 59 m_url = m_resource->response().url();
61 if (!m_url.isEmpty()) 60 if (!m_url.isEmpty())
62 m_url.removeFragmentIdentifier(); 61 m_url.removeFragmentIdentifier();
63 } 62 }
(...skipping 20 matching lines...) Expand all
84 // construct such a value. 83 // construct such a value.
85 // 84 //
86 // Should the other constructors be passed a null string, that is interprete d as representing 85 // Should the other constructors be passed a null string, that is interprete d as representing
87 // the empty script. Consequently, we need to disambiguate between such null string occurrences. 86 // the empty script. Consequently, we need to disambiguate between such null string occurrences.
88 // Do that by converting the latter case's null strings into empty ones. 87 // Do that by converting the latter case's null strings into empty ones.
89 if (m_source.isNull()) 88 if (m_source.isNull())
90 m_source = CompressibleString(); 89 m_source = CompressibleString();
91 } 90 }
92 91
93 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698