Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2434)

Unified Diff: net/websockets/websocket_job.cc

Issue 18932005: Reduce the complexity of WebSocketThrottle's wakeup code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/websockets/websocket_job.cc
diff --git a/net/websockets/websocket_job.cc b/net/websockets/websocket_job.cc
index 34d4a25f6d02d5ad8d71289adeb8359e957e4264..150e879d854428349a786538a5fe53f8928faa85 100644
--- a/net/websockets/websocket_job.cc
+++ b/net/websockets/websocket_job.cc
@@ -148,7 +148,6 @@ void WebSocketJob::RestartWithAuth(const AuthCredentials& credentials) {
void WebSocketJob::DetachDelegate() {
state_ = CLOSED;
WebSocketThrottle::GetInstance()->RemoveFromQueue(this);
- WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary();
scoped_refptr<WebSocketJob> protect(this);
weak_ptr_factory_.InvalidateWeakPtrs();
@@ -169,8 +168,12 @@ int WebSocketJob::OnStartOpenConnection(
SocketStream* socket, const CompletionCallback& callback) {
DCHECK(callback_.is_null());
state_ = CONNECTING;
+
addresses_ = socket->address_list();
- WebSocketThrottle::GetInstance()->PutInQueue(this);
+ if (!WebSocketThrottle::GetInstance()->PutInQueue(this)) {
+ return ERR_WS_THROTTLE_QUEUE_TOO_LARGE;
+ }
+
if (delegate_) {
int result = delegate_->OnStartOpenConnection(socket, callback);
DCHECK_EQ(OK, result);
@@ -246,7 +249,6 @@ void WebSocketJob::OnReceivedData(
void WebSocketJob::OnClose(SocketStream* socket) {
state_ = CLOSED;
WebSocketThrottle::GetInstance()->RemoveFromQueue(this);
- WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary();
scoped_refptr<WebSocketJob> protect(this);
weak_ptr_factory_.InvalidateWeakPtrs();
@@ -497,7 +499,6 @@ void WebSocketJob::NotifyHeadersComplete() {
socket_.get(), &received_data.front(), received_data.size());
WebSocketThrottle::GetInstance()->RemoveFromQueue(this);
- WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary();
}
void WebSocketJob::SaveNextCookie() {

Powered by Google App Engine
This is Rietveld 408576698