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

Side by Side Diff: trunk/src/net/websockets/websocket_job.cc

Issue 24251011: Revert 224269 "Don't persist HPKP if PrivacyMode is enabled." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/net/websockets/websocket_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/websockets/websocket_job.h" 5 #include "net/websockets/websocket_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 // handshake message is completed. 361 // handshake message is completed.
362 handshake_response_->set_protocol_version( 362 handshake_response_->set_protocol_version(
363 handshake_request_->protocol_version()); 363 handshake_request_->protocol_version());
364 AddCookieHeaderAndSend(); 364 AddCookieHeaderAndSend();
365 return true; 365 return true;
366 } 366 }
367 367
368 void WebSocketJob::AddCookieHeaderAndSend() { 368 void WebSocketJob::AddCookieHeaderAndSend() {
369 bool allow = true; 369 bool allow = true;
370 GURL url_for_cookies(socket_->url_for_cookies()); 370 if (delegate_ && !delegate_->CanGetCookies(socket_.get(), GetURLForCookies()))
371 if (delegate_ && !delegate_->CanGetCookies(socket_.get(), url_for_cookies))
372 allow = false; 371 allow = false;
373 372
374 if (socket_.get() && delegate_ && state_ == CONNECTING) { 373 if (socket_.get() && delegate_ && state_ == CONNECTING) {
375 handshake_request_->RemoveHeaders(kCookieHeaders, 374 handshake_request_->RemoveHeaders(kCookieHeaders,
376 arraysize(kCookieHeaders)); 375 arraysize(kCookieHeaders));
377 if (allow && socket_->context()->cookie_store()) { 376 if (allow && socket_->context()->cookie_store()) {
378 // Add cookies, including HttpOnly cookies. 377 // Add cookies, including HttpOnly cookies.
379 CookieOptions cookie_options; 378 CookieOptions cookie_options;
380 cookie_options.set_include_httponly(); 379 cookie_options.set_include_httponly();
381 socket_->context()->cookie_store()->GetCookiesWithOptionsAsync( 380 socket_->context()->cookie_store()->GetCookiesWithOptionsAsync(
382 url_for_cookies, 381 GetURLForCookies(), cookie_options,
383 cookie_options,
384 base::Bind(&WebSocketJob::LoadCookieCallback, 382 base::Bind(&WebSocketJob::LoadCookieCallback,
385 weak_ptr_factory_.GetWeakPtr())); 383 weak_ptr_factory_.GetWeakPtr()));
386 } else { 384 } else {
387 DoSendData(); 385 DoSendData();
388 } 386 }
389 } 387 }
390 } 388 }
391 389
392 void WebSocketJob::LoadCookieCallback(const std::string& cookie) { 390 void WebSocketJob::LoadCookieCallback(const std::string& cookie) {
393 if (!cookie.empty()) 391 if (!cookie.empty())
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 502 }
505 503
506 void WebSocketJob::SaveNextCookie() { 504 void WebSocketJob::SaveNextCookie() {
507 if (!socket_.get() || !delegate_ || state_ != CONNECTING) 505 if (!socket_.get() || !delegate_ || state_ != CONNECTING)
508 return; 506 return;
509 507
510 callback_pending_ = false; 508 callback_pending_ = false;
511 save_next_cookie_running_ = true; 509 save_next_cookie_running_ = true;
512 510
513 if (socket_->context()->cookie_store()) { 511 if (socket_->context()->cookie_store()) {
514 GURL url_for_cookies(socket_->url_for_cookies()); 512 GURL url_for_cookies = GetURLForCookies();
515 513
516 CookieOptions options; 514 CookieOptions options;
517 options.set_include_httponly(); 515 options.set_include_httponly();
518 516
519 // Loop as long as SetCookieWithOptionsAsync completes synchronously. Since 517 // Loop as long as SetCookieWithOptionsAsync completes synchronously. Since
520 // CookieMonster's asynchronous operation APIs queue the callback to run it 518 // CookieMonster's asynchronous operation APIs queue the callback to run it
521 // on the thread where the API was called, there won't be race. I.e. unless 519 // on the thread where the API was called, there won't be race. I.e. unless
522 // the callback is run synchronously, it won't be run in parallel with this 520 // the callback is run synchronously, it won't be run in parallel with this
523 // method. 521 // method.
524 while (!callback_pending_ && 522 while (!callback_pending_ &&
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 callback_pending_ = false; 556 callback_pending_ = false;
559 557
560 // Resume SaveNextCookie if the caller of SetCookieWithOptionsAsync() exited 558 // Resume SaveNextCookie if the caller of SetCookieWithOptionsAsync() exited
561 // the loop. Otherwise, return. 559 // the loop. Otherwise, return.
562 if (save_next_cookie_running_) 560 if (save_next_cookie_running_)
563 return; 561 return;
564 562
565 SaveNextCookie(); 563 SaveNextCookie();
566 } 564 }
567 565
566 GURL WebSocketJob::GetURLForCookies() const {
567 GURL url = socket_->url();
568 std::string scheme = socket_->is_secure() ? "https" : "http";
569 url_canon::Replacements<char> replacements;
570 replacements.SetScheme(scheme.c_str(),
571 url_parse::Component(0, scheme.length()));
572 return url.ReplaceComponents(replacements);
573 }
574
568 const AddressList& WebSocketJob::address_list() const { 575 const AddressList& WebSocketJob::address_list() const {
569 return addresses_; 576 return addresses_;
570 } 577 }
571 578
572 int WebSocketJob::TrySpdyStream() { 579 int WebSocketJob::TrySpdyStream() {
573 if (!socket_.get()) 580 if (!socket_.get())
574 return ERR_FAILED; 581 return ERR_FAILED;
575 582
576 if (!websocket_over_spdy_enabled_) 583 if (!websocket_over_spdy_enabled_)
577 return OK; 584 return OK;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 695
689 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front(); 696 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front();
690 send_buffer_queue_.pop_front(); 697 send_buffer_queue_.pop_front();
691 current_send_buffer_ = 698 current_send_buffer_ =
692 new DrainableIOBuffer(next_buffer.get(), next_buffer->size()); 699 new DrainableIOBuffer(next_buffer.get(), next_buffer->size());
693 SendDataInternal(current_send_buffer_->data(), 700 SendDataInternal(current_send_buffer_->data(),
694 current_send_buffer_->BytesRemaining()); 701 current_send_buffer_->BytesRemaining());
695 } 702 }
696 703
697 } // namespace net 704 } // namespace net
OLDNEW
« no previous file with comments | « trunk/src/net/websockets/websocket_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698