Skip to content

Commit

Permalink
updated websocket buffered_amount to be u64 instead of u32
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkisquared committed Dec 29, 2015
1 parent b26cd49 commit 20edf21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/webidls/WebSocket.webidl
Expand Up @@ -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;
Expand Down
16 changes: 3 additions & 13 deletions components/script/dom/websocket.rs
Expand Up @@ -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>>>,
Expand Down Expand Up @@ -299,17 +299,7 @@ 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);
self.buffered_amount.set(self.buffered_amount.get() + data_byte_len);

if return_after_buffer {
return Ok(false);
Expand Down Expand Up @@ -353,7 +343,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()
}

Expand Down

0 comments on commit 20edf21

Please sign in to comment.