Shaka Player Embedded
|
#include <xml_http_request.h>
Public Types | |
enum | ReadyState { ReadyState::Unsent = 0, ReadyState::Opened = 1, ReadyState::HeadersReceived = 2, ReadyState::Loading = 3, ReadyState::Done = 4 } |
![]() | |
using | Listener = optional< Callback > |
Public Member Functions | |
XMLHttpRequest () | |
void | Trace (memory::HeapTracer *tracer) const override |
bool | IsShortLived () const override |
void | Abort () |
std::string | GetAllResponseHeaders () const |
optional< std::string > | GetResponseHeader (const std::string &name) const |
ExceptionOr< void > | Open (const std::string &method, const std::string &url, optional< bool > async, optional< std::string > user, optional< std::string > password) |
ExceptionOr< void > | Send (optional< variant< ByteBuffer, ByteString >> maybe_data) |
ExceptionOr< void > | SetRequestHeader (const std::string &key, const std::string &value) |
bool | WithCredentials () const |
ExceptionOr< void > | SetWithCredentials (bool with_credentials) |
void | OnDataReceived (uint8_t *buffer, size_t length) |
void | OnHeaderReceived (const uint8_t *buffer, size_t length) |
size_t | OnUpload (uint8_t *buffer, size_t length) |
![]() | |
EventTarget () | |
void | AddEventListener (const std::string &type, Listener callback) |
void | SetCppEventListener (EventType type, std::function< void()> callback) |
void | RemoveEventListener (const std::string &type, Listener callback) |
void | UnsetCppEventListener (EventType type) |
ExceptionOr< bool > | DispatchEvent (RefPtr< Event > event) |
ExceptionOr< bool > | DispatchEventInternal (RefPtr< Event > event, bool *did_listeners_throw) |
template<typename EventType , typename... Args> | |
std::shared_ptr< ThreadEvent< bool > > | ScheduleEvent (Args &&... args) |
template<typename EventType , typename... Args> | |
ExceptionOr< bool > | RaiseEvent (Args... args) |
![]() | |
BackingObject () | |
void | Trace (memory::HeapTracer *tracer) const override |
bool | IsRootedAlive () const override |
std::string | name () const |
virtual BackingObjectFactoryBase * | factory () const =0 |
bool | DerivedFrom (const std::string &base) |
ReturnVal< JsValue > | JsThis () const |
void | SetJsThis (Handle< JsObject > this_) |
![]() | |
virtual | ~Traceable () |
Static Public Member Functions | |
static XMLHttpRequest * | Create () |
![]() | |
static void * | operator new[] (size_t size)=delete |
static void | operator delete[] (void *)=delete |
Public Attributes | |
Listener | on_abort |
Listener | on_error |
Listener | on_load |
Listener | on_load_start |
Listener | on_progress |
Listener | on_ready_state_change |
Listener | on_timeout |
Listener | on_load_end |
ReadyState | ready_state |
ByteBuffer | response |
std::string | response_text |
std::string | response_type |
std::string | response_url |
int | status |
std::string | status_text |
uint64_t | timeout_ms |
Additional Inherited Members | |
![]() | |
static constexpr const size_t | kInternalFieldCount = 2 |
![]() | |
static constexpr const uint64_t | kShortLiveDurationMs = 5000 |
![]() | |
void | AddListenerField (EventType type, Listener *on_field) |
![]() | |
~BackingObject () override | |
An implementation of JavaScript XMLHttpRequest. This handles network requests using CURL.
Notes:
IMPORTANT:
Definition at line 58 of file xml_http_request.h.
|
strong |
Enumerator | |
---|---|
Unsent | |
Opened | |
HeadersReceived | |
Loading | |
Done |
Definition at line 62 of file xml_http_request.h.
shaka::js::XMLHttpRequest::XMLHttpRequest | ( | ) |
Definition at line 128 of file xml_http_request.cc.
void shaka::js::XMLHttpRequest::Abort | ( | ) |
Definition at line 171 of file xml_http_request.cc.
|
inlinestatic |
Definition at line 71 of file xml_http_request.h.
std::string shaka::js::XMLHttpRequest::GetAllResponseHeaders | ( | ) | const |
Definition at line 197 of file xml_http_request.cc.
shaka::optional< std::string > shaka::js::XMLHttpRequest::GetResponseHeader | ( | const std::string & | name | ) | const |
Definition at line 206 of file xml_http_request.cc.
|
overridevirtual |
Gets whether the object is considered short-lived. This means that once the C++ ref-count is zero, the object won't remain alive for long. It is important to only set this if the JavaScript object won't be used for long.
This exists for JSC which doesn't offer a way for us to track whether a JavaScript object is still alive. If the JavaScript object is used after the backing object is destroyed, then a JavaScript exception will be thrown.
Reimplemented from shaka::memory::Traceable.
Definition at line 167 of file xml_http_request.cc.
void shaka::js::XMLHttpRequest::OnDataReceived | ( | uint8_t * | buffer, |
size_t | length | ||
) |
Called from a CURL callback when (part of) the body data is received.
Definition at line 343 of file xml_http_request.cc.
void shaka::js::XMLHttpRequest::OnHeaderReceived | ( | const uint8_t * | buffer, |
size_t | length | ||
) |
Called from a CURL callback for each header that is received.
buffer | A buffer containing exactly one header. |
length | The length of |buffer|. |
Definition at line 361 of file xml_http_request.cc.
size_t shaka::js::XMLHttpRequest::OnUpload | ( | uint8_t * | buffer, |
size_t | length | ||
) |
Called from a CURL callback when uploading data.
Definition at line 419 of file xml_http_request.cc.
ExceptionOr< void > shaka::js::XMLHttpRequest::Open | ( | const std::string & | method, |
const std::string & | url, | ||
optional< bool > | async, | ||
optional< std::string > | user, | ||
optional< std::string > | password | ||
) |
Definition at line 215 of file xml_http_request.cc.
ExceptionOr< void > shaka::js::XMLHttpRequest::Send | ( | optional< variant< ByteBuffer, ByteString >> | maybe_data | ) |
Definition at line 246 of file xml_http_request.cc.
ExceptionOr< void > shaka::js::XMLHttpRequest::SetRequestHeader | ( | const std::string & | key, |
const std::string & | value | ||
) |
Definition at line 293 of file xml_http_request.cc.
ExceptionOr< void > shaka::js::XMLHttpRequest::SetWithCredentials | ( | bool | with_credentials | ) |
Definition at line 309 of file xml_http_request.cc.
|
overridevirtual |
Called during a GC run. This should call HeapTracer::Trace on all Traceable members. Be sure to call the base method when overriding.
Reimplemented from shaka::js::events::EventTarget.
Definition at line 159 of file xml_http_request.cc.
bool shaka::js::XMLHttpRequest::WithCredentials | ( | ) | const |
Definition at line 305 of file xml_http_request.cc.
Listener shaka::js::XMLHttpRequest::on_abort |
Definition at line 105 of file xml_http_request.h.
Listener shaka::js::XMLHttpRequest::on_error |
Definition at line 106 of file xml_http_request.h.
Listener shaka::js::XMLHttpRequest::on_load |
Definition at line 107 of file xml_http_request.h.
Listener shaka::js::XMLHttpRequest::on_load_end |
Definition at line 112 of file xml_http_request.h.
Listener shaka::js::XMLHttpRequest::on_load_start |
Definition at line 108 of file xml_http_request.h.
Listener shaka::js::XMLHttpRequest::on_progress |
Definition at line 109 of file xml_http_request.h.
Listener shaka::js::XMLHttpRequest::on_ready_state_change |
Definition at line 110 of file xml_http_request.h.
Listener shaka::js::XMLHttpRequest::on_timeout |
Definition at line 111 of file xml_http_request.h.
ReadyState shaka::js::XMLHttpRequest::ready_state |
Definition at line 114 of file xml_http_request.h.
ByteBuffer shaka::js::XMLHttpRequest::response |
Definition at line 115 of file xml_http_request.h.
std::string shaka::js::XMLHttpRequest::response_text |
Definition at line 116 of file xml_http_request.h.
std::string shaka::js::XMLHttpRequest::response_type |
Definition at line 117 of file xml_http_request.h.
std::string shaka::js::XMLHttpRequest::response_url |
Definition at line 118 of file xml_http_request.h.
int shaka::js::XMLHttpRequest::status |
Definition at line 119 of file xml_http_request.h.
std::string shaka::js::XMLHttpRequest::status_text |
Definition at line 120 of file xml_http_request.h.
uint64_t shaka::js::XMLHttpRequest::timeout_ms |
Definition at line 121 of file xml_http_request.h.