Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / v8 / custom / V8XMLHttpRequestCustom.cpp
index 9fab4af..8659b65 100644 (file)
  */
 
 #include "config.h"
-#include "V8XMLHttpRequest.h"
+#include "bindings/core/v8/V8XMLHttpRequest.h"
 
-#include "V8Blob.h"
-#include "V8Document.h"
-#include "V8FormData.h"
-#include "V8HTMLDocument.h"
-#include "V8Stream.h"
+#include "bindings/core/v8/V8Blob.h"
+#include "bindings/core/v8/V8Document.h"
+#include "bindings/core/v8/V8FormData.h"
+#include "bindings/core/v8/V8HTMLDocument.h"
+#include "bindings/core/v8/V8Stream.h"
 #include "bindings/v8/ExceptionMessages.h"
 #include "bindings/v8/ExceptionState.h"
 #include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
 #include "bindings/v8/custom/V8ArrayBufferCustom.h"
 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
 #include "core/dom/Document.h"
@@ -58,12 +57,12 @@ void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Valu
 
     RefPtr<SecurityOrigin> securityOrigin;
     if (context->isDocument()) {
-        DOMWrapperWorld* world = DOMWrapperWorld::current(info.GetIsolate());
-        if (world->isIsolatedWorld())
-            securityOrigin = world->isolatedWorldSecurityOrigin();
+        DOMWrapperWorld& world = DOMWrapperWorld::current(info.GetIsolate());
+        if (world.isIsolatedWorld())
+            securityOrigin = world.isolatedWorldSecurityOrigin();
     }
 
-    RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
+    RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
 
     v8::Handle<v8::Object> wrapper = info.Holder();
     V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.release(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
@@ -74,10 +73,10 @@ void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallb
 {
     XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
     ExceptionState exceptionState(ExceptionState::GetterContext, "responseText", "XMLHttpRequest", info.Holder(), info.GetIsolate());
-    ScriptValue text = xmlHttpRequest->responseText(exceptionState);
+    ScriptString text = xmlHttpRequest->responseText(exceptionState);
     if (exceptionState.throwIfNeeded())
         return;
-    if (text.hasNoValue()) {
+    if (text.isEmpty()) {
         v8SetReturnValueString(info, emptyString(), info.GetIsolate());
         return;
     }
@@ -99,21 +98,18 @@ void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackI
             v8::Isolate* isolate = info.GetIsolate();
 
             ScriptString jsonSource = xmlHttpRequest->responseJSONSource();
-            if (jsonSource.hasNoValue() || !jsonSource.v8Value()->IsString()) {
+            if (jsonSource.isEmpty()) {
                 v8SetReturnValue(info, v8::Null(isolate));
                 return;
             }
 
             // Catch syntax error.
             v8::TryCatch exceptionCatcher;
-
-            v8::Handle<v8::Value> json = v8::JSON::Parse(jsonSource.v8Value().As<v8::String>());
-
+            v8::Handle<v8::Value> json = v8::JSON::Parse(jsonSource.v8Value());
             if (exceptionCatcher.HasCaught() || json.IsEmpty())
                 v8SetReturnValue(info, v8::Null(isolate));
             else
                 v8SetReturnValue(info, json);
-
             return;
         }
 
@@ -171,8 +167,8 @@ void V8XMLHttpRequest::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value
 
     XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
 
-    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, info[0]);
-    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, info[1]);
+    TOSTRING_VOID(V8StringResource<>, method, info[0]);
+    TOSTRING_VOID(V8StringResource<>, urlstring, info[1]);
 
     ExecutionContext* context = currentExecutionContext(info.GetIsolate());
     KURL url = context->completeURL(urlstring);
@@ -181,10 +177,10 @@ void V8XMLHttpRequest::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value
         bool async = info[2]->BooleanValue();
 
         if (info.Length() >= 4 && !info[3]->IsUndefined()) {
-            V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, user, info[3]);
+            TOSTRING_VOID(V8StringResource<WithNullCheck>, user, info[3]);
 
             if (info.Length() >= 5 && !info[4]->IsUndefined()) {
-                V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, password, info[4]);
+                TOSTRING_VOID(V8StringResource<WithNullCheck>, password, info[4]);
                 xmlHttpRequest->open(method, url, async, user, password, exceptionState);
             } else {
                 xmlHttpRequest->open(method, url, async, user, exceptionState);
@@ -244,7 +240,7 @@ void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value
             ASSERT(arrayBufferView);
             xmlHttpRequest->send(arrayBufferView, exceptionState);
         } else {
-            V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, argString, arg);
+            TOSTRING_VOID(V8StringResource<WithNullCheck>, argString, arg);
             xmlHttpRequest->send(argString, exceptionState);
         }
     }