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

Unified Diff: Source/bindings/core/v8/ScriptSourceCode.cpp

Issue 847803002: Make ScriptStreamer and dependents Oilpan friendly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add ScriptSourceCode::isNull() comment Created 5 years, 11 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
« no previous file with comments | « Source/bindings/core/v8/ScriptSourceCode.h ('k') | Source/bindings/core/v8/ScriptStreamer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/ScriptSourceCode.cpp
diff --git a/Source/bindings/core/v8/ScriptSourceCode.cpp b/Source/bindings/core/v8/ScriptSourceCode.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2cd1249ad062f67dace93abb098e4012e9c39ef5
--- /dev/null
+++ b/Source/bindings/core/v8/ScriptSourceCode.cpp
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "bindings/core/v8/ScriptSourceCode.h"
+
+namespace blink {
+
+ScriptSourceCode::ScriptSourceCode()
+ : m_resource(0)
+ , m_startPosition(TextPosition::minimumPosition())
+{
+}
+
+ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const TextPosition& startPosition)
+ : m_source(source)
+ , m_resource(0)
+ , m_url(url)
+ , m_startPosition(startPosition)
+{
+ treatNullSourceAsEmpty();
+ if (!m_url.isEmpty())
+ m_url.removeFragmentIdentifier();
+}
+
+ScriptSourceCode::ScriptSourceCode(ScriptResource* resource)
+ : m_source(resource->script())
+ , m_resource(resource)
+ , m_startPosition(TextPosition::minimumPosition())
+{
+ treatNullSourceAsEmpty();
+}
+
+ScriptSourceCode::ScriptSourceCode(PassRefPtrWillBeRawPtr<ScriptStreamer> streamer, ScriptResource* resource)
+ : m_source(resource->script())
+ , m_resource(resource)
+ , m_streamer(streamer)
+ , m_startPosition(TextPosition::minimumPosition())
+{
+ treatNullSourceAsEmpty();
+}
+
+ScriptSourceCode::~ScriptSourceCode()
+{
+}
+
+void ScriptSourceCode::trace(Visitor* visitor)
+{
+ visitor->trace(m_streamer);
+}
+
+const KURL& ScriptSourceCode::url() const
+{
+ if (m_url.isEmpty() && m_resource) {
+ m_url = m_resource->response().url();
+ if (!m_url.isEmpty())
+ m_url.removeFragmentIdentifier();
+ }
+ return m_url;
+}
+
+void ScriptSourceCode::treatNullSourceAsEmpty()
+{
+ // ScriptSourceCode allows for the representation of the null/not-there-really ScriptSourceCode value.
+ // Encoded by way of a m_source.isNull() being true, with the nullary constructor to be used to
+ // construct such a value.
+ //
+ // Should the other constructors be passed a null string, that is interpreted as representing
+ // the empty script. Consequently, we need to disambiguate between such null string occurrences.
+ // Do that by converting the latter case's null strings into empty ones.
+ if (m_source.isNull())
+ m_source = "";
+}
+
+} // namespace blink
« no previous file with comments | « Source/bindings/core/v8/ScriptSourceCode.h ('k') | Source/bindings/core/v8/ScriptStreamer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698