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

Unified Diff: net/websockets/websocket_job.cc

Issue 14701005: Less indentation in WebSocketJob::SaveNextCookie() for readability (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_job.cc
diff --git a/net/websockets/websocket_job.cc b/net/websockets/websocket_job.cc
index 3c71d6b774c1d6f0d88235967cf286921081106a..8abcd6bcafa22c2492e320a383658eb47dcf08d4 100644
--- a/net/websockets/websocket_job.cc
+++ b/net/websockets/websocket_job.cc
@@ -474,10 +474,11 @@ void WebSocketJob::SaveCookiesAndNotifyHeadersComplete() {
void WebSocketJob::NotifyHeadersComplete() {
// Remove cookie headers, with malformed headers preserved.
- // Actual handshake should be done in WebKit.
+ // Actual handshake should be done in Blink.
handshake_response_->RemoveHeaders(
kSetCookieHeaders, arraysize(kSetCookieHeaders));
std::string handshake_response = handshake_response_->GetResponse();
+ handshake_response_.reset();
std::vector<char> received_data(handshake_response.begin(),
handshake_response.end());
received_data.insert(received_data.end(),
@@ -508,24 +509,24 @@ void WebSocketJob::SaveNextCookie() {
return;
}
- bool allow = true;
+ if (!socket_ || !delegate_ || state_ != CONNECTING)
+ return;
+
CookieOptions options;
GURL url = GetURLForCookies();
std::string cookie = response_cookies_[response_cookies_save_index_];
- if (delegate_ && !delegate_->CanSetCookie(socket_, url, cookie, &options))
- allow = false;
-
- if (socket_ && delegate_ && state_ == CONNECTING) {
- response_cookies_save_index_++;
- if (allow && socket_->context()->cookie_store()) {
- options.set_include_httponly();
- socket_->context()->cookie_store()->SetCookieWithOptionsAsync(
- url, cookie, options,
- base::Bind(&WebSocketJob::SaveCookieCallback,
- weak_ptr_factory_.GetWeakPtr()));
- } else {
- SaveNextCookie();
- }
+ response_cookies_save_index_++;
+
+ // TODO(tyoshino): Use loop. See URLRequestHttpJob::SaveNextCookie().
+ if (delegate_->CanSetCookie(socket_, url, cookie, &options) &&
+ socket_->context()->cookie_store()) {
+ options.set_include_httponly();
+ socket_->context()->cookie_store()->SetCookieWithOptionsAsync(
+ url, cookie, options,
+ base::Bind(&WebSocketJob::SaveCookieCallback,
+ weak_ptr_factory_.GetWeakPtr()));
+ } else {
+ SaveNextCookie();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698