本文整理汇总了C++中XMLHttpRequest类的典型用法代码示例。如果您正苦于以下问题:C++ XMLHttpRequest类的具体用法?C++ XMLHttpRequest怎么用?C++ XMLHttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLHttpRequest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: exceptionState
void V8XMLHttpRequest::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
// Four cases:
// open(method, url)
// open(method, url, async)
// open(method, url, async, user)
// open(method, url, async, user, passwd)
ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "XMLHttpRequest", info.Holder(), info.GetIsolate());
if (info.Length() < 2) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
exceptionState.throwIfNeeded();
return;
}
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
TOSTRING_VOID(V8StringResource<>, method, info[0]);
TOSTRING_VOID(V8StringResource<>, urlstring, info[1]);
ExecutionContext* context = currentExecutionContext(info.GetIsolate());
KURL url = context->completeURL(urlstring);
if (info.Length() >= 3) {
bool async = info[2]->BooleanValue();
if (info.Length() >= 4 && !info[3]->IsUndefined()) {
TOSTRING_VOID(V8StringResource<TreatNullAsNullString>, user, info[3]);
if (info.Length() >= 5 && !info[4]->IsUndefined()) {
TOSTRING_VOID(V8StringResource<TreatNullAsNullString>, password, info[4]);
xmlHttpRequest->open(method, url, async, user, password, exceptionState);
} else {
xmlHttpRequest->open(method, url, async, user, exceptionState);
}
} else {
xmlHttpRequest->open(method, url, async, exceptionState);
}
} else {
xmlHttpRequest->open(method, url, exceptionState);
}
exceptionState.throwIfNeeded();
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_WebKit,代码行数:45,代码来源:V8XMLHttpRequestCustom.cpp
示例2: INC_STATS
v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args)
{
INC_STATS("DOM.XMLHttpRequest.open()");
// Four cases:
// open(method, url)
// open(method, url, async)
// open(method, url, async, user)
// open(method, url, async, user, passwd)
if (args.Length() < 2)
return throwError("Not enough arguments", V8Proxy::SyntaxError);
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());
String method = toWebCoreString(args[0]);
String urlstring = toWebCoreString(args[1]);
ScriptExecutionContext* context = getScriptExecutionContext();
if (!context)
return v8::Undefined();
KURL url = context->completeURL(urlstring);
ExceptionCode ec = 0;
if (args.Length() >= 3) {
bool async = args[2]->BooleanValue();
if (args.Length() >= 4 && !args[3]->IsUndefined()) {
String user = toWebCoreStringWithNullCheck(args[3]);
if (args.Length() >= 5 && !args[4]->IsUndefined()) {
String passwd = toWebCoreStringWithNullCheck(args[4]);
xmlHttpRequest->open(method, url, async, user, passwd, ec);
} else
xmlHttpRequest->open(method, url, async, user, ec);
} else
xmlHttpRequest->open(method, url, async, ec);
} else
xmlHttpRequest->open(method, url, ec);
if (ec)
return throwError(ec);
return v8::Undefined();
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:45,代码来源:V8XMLHttpRequestCustom.cpp
示例3: INC_STATS
v8::Handle<v8::Value> V8XMLHttpRequest::responseAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.XMLHttpRequest.response._get");
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
switch (xmlHttpRequest->responseTypeCode()) {
case XMLHttpRequest::ResponseTypeDefault:
case XMLHttpRequest::ResponseTypeText:
return responseTextAccessorGetter(name, info);
case XMLHttpRequest::ResponseTypeDocument:
{
ExceptionCode ec = 0;
Document* document = xmlHttpRequest->responseXML(ec);
if (ec)
return V8Proxy::setDOMException(ec, info.GetIsolate());
return toV8(document, info.GetIsolate());
}
case XMLHttpRequest::ResponseTypeBlob:
#if ENABLE(XHR_RESPONSE_BLOB)
{
ExceptionCode ec = 0;
Blob* blob = xmlHttpRequest->responseBlob(ec);
if (ec)
return V8Proxy::setDOMException(ec, info.GetIsolate());
return toV8(blob, info.GetIsolate());
}
#else
return v8::Undefined();
#endif
case XMLHttpRequest::ResponseTypeArrayBuffer:
{
ExceptionCode ec = 0;
ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(ec);
if (ec)
return V8Proxy::setDOMException(ec, info.GetIsolate());
return toV8(arrayBuffer, info.GetIsolate());
}
}
return v8::Undefined();
}
开发者ID:Spencerx,项目名称:webkit,代码行数:44,代码来源:V8XMLHttpRequestCustom.cpp
示例4: throwNotEnoughArgumentsError
v8::Handle<v8::Value> V8XMLHttpRequest::openMethodCustom(const v8::Arguments& args)
{
// Four cases:
// open(method, url)
// open(method, url, async)
// open(method, url, async, user)
// open(method, url, async, user, passwd)
if (args.Length() < 2)
return throwNotEnoughArgumentsError(args.GetIsolate());
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());
String method = toWebCoreString(args[0]);
String urlstring = toWebCoreString(args[1]);
ScriptExecutionContext* context = getScriptExecutionContext();
KURL url = context->completeURL(urlstring);
ExceptionCode ec = 0;
if (args.Length() >= 3) {
bool async = args[2]->BooleanValue();
if (args.Length() >= 4 && !args[3]->IsUndefined()) {
String user = toWebCoreStringWithNullCheck(args[3]);
if (args.Length() >= 5 && !args[4]->IsUndefined()) {
String passwd = toWebCoreStringWithNullCheck(args[4]);
xmlHttpRequest->open(method, url, async, user, passwd, ec);
} else
xmlHttpRequest->open(method, url, async, user, ec);
} else
xmlHttpRequest->open(method, url, async, ec);
} else
xmlHttpRequest->open(method, url, ec);
if (ec)
return setDOMException(ec, args.GetIsolate());
return v8::Undefined();
}
开发者ID:fmalita,项目名称:webkit,代码行数:42,代码来源:V8XMLHttpRequestCustom.cpp
示例5: switch
v8::Handle<v8::Value> V8XMLHttpRequest::responseAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
switch (xmlHttpRequest->responseTypeCode()) {
case XMLHttpRequest::ResponseTypeDefault:
case XMLHttpRequest::ResponseTypeText:
return responseTextAttrGetterCustom(name, info);
case XMLHttpRequest::ResponseTypeDocument:
{
ExceptionCode ec = 0;
Document* document = xmlHttpRequest->responseXML(ec);
if (ec)
return setDOMException(ec, info.GetIsolate());
return toV8Fast(document, info, xmlHttpRequest);
}
case XMLHttpRequest::ResponseTypeBlob:
{
ExceptionCode ec = 0;
Blob* blob = xmlHttpRequest->responseBlob(ec);
if (ec)
return setDOMException(ec, info.GetIsolate());
return toV8Fast(blob, info, xmlHttpRequest);
}
case XMLHttpRequest::ResponseTypeArrayBuffer:
{
ExceptionCode ec = 0;
ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(ec);
if (ec)
return setDOMException(ec, info.GetIsolate());
return toV8Fast(arrayBuffer, info, xmlHttpRequest);
}
}
return v8::Undefined();
}
开发者ID:fmalita,项目名称:webkit,代码行数:39,代码来源:V8XMLHttpRequestCustom.cpp
示例6: exceptionState
void V8XMLHttpRequest::responseAttributeGetterCustom(
const v8::FunctionCallbackInfo<v8::Value>& info) {
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder());
ExceptionState exceptionState(info.GetIsolate(),
ExceptionState::GetterContext, "XMLHttpRequest",
"response");
switch (xmlHttpRequest->getResponseTypeCode()) {
case XMLHttpRequest::ResponseTypeDefault:
case XMLHttpRequest::ResponseTypeText:
responseTextAttributeGetterCustom(info);
return;
case XMLHttpRequest::ResponseTypeJSON: {
v8::Isolate* isolate = info.GetIsolate();
ScriptString jsonSource = xmlHttpRequest->responseJSONSource();
if (jsonSource.isEmpty()) {
v8SetReturnValue(info, v8::Null(isolate));
return;
}
// Catch syntax error. Swallows an exception (when thrown) as the
// spec says. https://xhr.spec.whatwg.org/#response-body
v8::Local<v8::Value> json = fromJSONString(
isolate, toCoreString(jsonSource.v8Value()), exceptionState);
if (exceptionState.hadException()) {
exceptionState.clearException();
v8SetReturnValue(info, v8::Null(isolate));
} else {
v8SetReturnValue(info, json);
}
return;
}
case XMLHttpRequest::ResponseTypeDocument: {
Document* document = xmlHttpRequest->responseXML(exceptionState);
v8SetReturnValueFast(info, document, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeBlob: {
Blob* blob = xmlHttpRequest->responseBlob();
v8SetReturnValueFast(info, blob, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeArrayBuffer: {
DOMArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer();
v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest);
return;
}
}
}
开发者ID:,项目名称:,代码行数:54,代码来源:
示例7: switch
void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
switch (xmlHttpRequest->responseTypeCode()) {
case XMLHttpRequest::ResponseTypeDefault:
case XMLHttpRequest::ResponseTypeText:
responseTextAttributeGetterCustom(info);
return;
case XMLHttpRequest::ResponseTypeJSON:
{
v8::Isolate* isolate = info.GetIsolate();
ScriptString jsonSource = xmlHttpRequest->responseJSONSource();
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());
if (exceptionCatcher.HasCaught() || json.IsEmpty())
v8SetReturnValue(info, v8::Null(isolate));
else
v8SetReturnValue(info, json);
return;
}
case XMLHttpRequest::ResponseTypeDocument:
{
ExceptionState exceptionState(ExceptionState::GetterContext, "response", "XMLHttpRequest", info.Holder(), info.GetIsolate());
Document* document = xmlHttpRequest->responseXML(exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValueFast(info, document, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeBlob:
{
Blob* blob = xmlHttpRequest->responseBlob();
v8SetReturnValueFast(info, blob, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeLegacyStream:
{
Stream* stream = xmlHttpRequest->responseLegacyStream();
v8SetReturnValueFast(info, stream, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeStream:
{
ReadableStream* stream = xmlHttpRequest->responseStream();
v8SetReturnValueFast(info, stream, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeArrayBuffer:
{
ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer();
if (arrayBuffer) {
arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanceTemplate());
}
v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest);
return;
}
}
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_WebKit,代码行数:72,代码来源:V8XMLHttpRequestCustom.cpp
示例8: switch
void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder());
switch (xmlHttpRequest->responseTypeCode()) {
case XMLHttpRequest::ResponseTypeDefault:
case XMLHttpRequest::ResponseTypeText:
responseTextAttributeGetterCustom(info);
return;
case XMLHttpRequest::ResponseTypeJSON:
{
v8::Isolate* isolate = info.GetIsolate();
ScriptString jsonSource = xmlHttpRequest->responseJSONSource();
if (jsonSource.isEmpty()) {
v8SetReturnValue(info, v8::Null(isolate));
return;
}
// Catch syntax error. Swallows an exception (when thrown) as the
// spec says. https://xhr.spec.whatwg.org/#response-body
v8::TryCatch exceptionCatcher;
v8::Local<v8::Value> json;
if (v8Call(v8::JSON::Parse(isolate, jsonSource.v8Value()), json, exceptionCatcher))
v8SetReturnValue(info, json);
else
v8SetReturnValue(info, v8::Null(isolate));
return;
}
case XMLHttpRequest::ResponseTypeDocument:
{
ExceptionState exceptionState(ExceptionState::GetterContext, "response", "XMLHttpRequest", info.Holder(), info.GetIsolate());
Document* document = xmlHttpRequest->responseXML(exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValueFast(info, document, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeBlob:
{
Blob* blob = xmlHttpRequest->responseBlob();
v8SetReturnValueFast(info, blob, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeLegacyStream:
{
Stream* stream = xmlHttpRequest->responseLegacyStream();
v8SetReturnValueFast(info, stream, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeStream:
{
ReadableStream* stream = xmlHttpRequest->responseStream();
v8SetReturnValueFast(info, stream, xmlHttpRequest);
return;
}
case XMLHttpRequest::ResponseTypeArrayBuffer:
{
DOMArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer();
v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest);
return;
}
}
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:70,代码来源:V8XMLHttpRequestCustom.cpp
示例9: INC_STATS
v8::Handle<v8::Value> V8XMLHttpRequest::responseTextAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.XMLHttpRequest.responsetext._get");
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
return xmlHttpRequest->responseText().v8StringOrNull();
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:6,代码来源:V8XMLHttpRequestCustom.cpp
注:本文中的XMLHttpRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论