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

Unified Diff: Source/bindings/dart/DartScriptValue.cpp

Issue 289083003: [dartium] Dart half of ScriptValue refactoring. (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1916
Patch Set: Created 6 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
« no previous file with comments | « Source/bindings/dart/DartScriptValue.h ('k') | Source/bindings/dart/DartUtilities.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartScriptValue.cpp
diff --git a/Source/bindings/dart/DartScriptValue.cpp b/Source/bindings/dart/DartScriptValue.cpp
index 8ca68007886ca34e69c277861bfcb166b8bae37d..bca059d7345416065a5523be437197f9a0587126 100644
--- a/Source/bindings/dart/DartScriptValue.cpp
+++ b/Source/bindings/dart/DartScriptValue.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -27,26 +27,54 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include "config.h"
#include "bindings/dart/DartScriptValue.h"
-#include "bindings/dart/DartDOMData.h"
#include "bindings/dart/DartUtilities.h"
+#include "bindings/dart/V8Converter.h"
+#include "platform/JSONValues.h"
namespace WebCore {
-DartScriptValue::DartScriptValue(Dart_Handle value)
+DartScriptValue::~DartScriptValue()
{
- m_value = Dart_NewPersistentHandle(value);
}
-DartScriptValue::~DartScriptValue()
+// FIXMEDART: Renamed toString in M36.
+bool DartScriptValue::getString(String& result) const
{
- if (!isIsolateAlive())
- return;
+ if (hasNoValue())
+ return false;
+
+ Dart_Handle exception = 0;
+ DartStringAdapter string = DartUtilities::dartToString(m_value, exception);
+ if (exception)
+ return false;
+ result = string;
+ return true;
+}
- DartIsolateScope scope(isolate());
- Dart_DeletePersistentHandle(m_value);
+// FIXMEDART: Removed in M36.
+String DartScriptValue::toString() const
+{
+ String result;
+ if (!getString(result))
+ return String();
+ return result;
}
+// FIXMEDART: Implement without conversion to v8.
+PassRefPtr<JSONValue> DartScriptValue::toJSONValue(ScriptState* scriptState) const
+{
+ Dart_Handle exception = 0;
+ v8::Handle<v8::Value> v8Value = V8Converter::toV8(m_value, exception);
+ if (exception) {
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ }
+ ScriptValue v8ScriptValue(v8Value, scriptState->isolate());
+ return v8ScriptValue.toJSONValue(scriptState);
}
+
+} // namespace WebCore
« no previous file with comments | « Source/bindings/dart/DartScriptValue.h ('k') | Source/bindings/dart/DartUtilities.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698