mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #9082 - nikkisquared:websocket_bufferedamount, r=eefriedman
Updated WebSocket buffered_amount to match change to html specification The size of WebSocket's buffered_amount was changed[1] after an issue I opened, which I found while working on WebSocket previously[2]. @jdm suggested I make a PR updating Servo reflecting this, and so I have! As always, I'd like to hear any feedback on anything I can do to improve this. [1] https://github.com/whatwg/html/issues/296 [2] https://github.com/servo/servo/pull/8218#issuecomment-152021737 point 5) <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9082) <!-- Reviewable:end -->
This commit is contained in:
commit
6844adbe2d
2 changed files with 7 additions and 14 deletions
|
@ -15,7 +15,7 @@ interface WebSocket : EventTarget {
|
|||
const unsigned short CLOSING = 2;
|
||||
const unsigned short CLOSED = 3;
|
||||
readonly attribute unsigned short readyState;
|
||||
readonly attribute unsigned long bufferedAmount;
|
||||
readonly attribute unsigned long long bufferedAmount;
|
||||
|
||||
//networking
|
||||
attribute EventHandler onopen;
|
||||
|
|
|
@ -138,7 +138,7 @@ pub struct WebSocket {
|
|||
url: Url,
|
||||
global: GlobalField,
|
||||
ready_state: Cell<WebSocketRequestState>,
|
||||
buffered_amount: Cell<u32>,
|
||||
buffered_amount: Cell<u64>,
|
||||
clearing_buffer: Cell<bool>, //Flag to tell if there is a running task to clear buffered_amount
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
sender: DOMRefCell<Option<IpcSender<WebSocketDomAction>>>,
|
||||
|
@ -299,17 +299,10 @@ impl WebSocket {
|
|||
let chan = global.r().networking_task_source();
|
||||
let address = Trusted::new(self, chan.clone());
|
||||
|
||||
let new_buffer_amount = (self.buffered_amount.get() as u64) + data_byte_len;
|
||||
if new_buffer_amount > (u32::max_value() as u64) {
|
||||
self.buffered_amount.set(u32::max_value());
|
||||
self.full.set(true);
|
||||
|
||||
let _ = self.Close(None, None);
|
||||
return Ok(false);
|
||||
|
||||
}
|
||||
|
||||
self.buffered_amount.set(new_buffer_amount as u32);
|
||||
match data_byte_len.checked_add(self.buffered_amount.get()) {
|
||||
None => panic!(),
|
||||
Some(new_amount) => self.buffered_amount.set(new_amount)
|
||||
};
|
||||
|
||||
if return_after_buffer {
|
||||
return Ok(false);
|
||||
|
@ -353,7 +346,7 @@ impl WebSocketMethods for WebSocket {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-bufferedamount
|
||||
fn BufferedAmount(&self) -> u32 {
|
||||
fn BufferedAmount(&self) -> u64 {
|
||||
self.buffered_amount.get()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue