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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 20254: Fetch SDCH dictionary as soon as current URL fetch completes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 server_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), 57 server_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH),
58 ALLOW_THIS_IN_INITIALIZER_LIST( 58 ALLOW_THIS_IN_INITIALIZER_LIST(
59 start_callback_(this, &URLRequestHttpJob::OnStartCompleted)), 59 start_callback_(this, &URLRequestHttpJob::OnStartCompleted)),
60 ALLOW_THIS_IN_INITIALIZER_LIST( 60 ALLOW_THIS_IN_INITIALIZER_LIST(
61 read_callback_(this, &URLRequestHttpJob::OnReadCompleted)), 61 read_callback_(this, &URLRequestHttpJob::OnReadCompleted)),
62 read_in_progress_(false), 62 read_in_progress_(false),
63 context_(request->context()) { 63 context_(request->context()) {
64 } 64 }
65 65
66 URLRequestHttpJob::~URLRequestHttpJob() { 66 URLRequestHttpJob::~URLRequestHttpJob() {
67 if (sdch_dictionary_url_.is_valid()) {
68 SdchManager::Global()->FetchDictionary(sdch_dictionary_url_);
Lincoln 2009/02/17 21:43:50 Could this cause a crash if, when the browser is s
69 }
67 } 70 }
68 71
69 void URLRequestHttpJob::SetUpload(net::UploadData* upload) { 72 void URLRequestHttpJob::SetUpload(net::UploadData* upload) {
70 DCHECK(!transaction_.get()) << "cannot change once started"; 73 DCHECK(!transaction_.get()) << "cannot change once started";
71 request_info_.upload_data = upload; 74 request_info_.upload_data = upload;
72 } 75 }
73 76
74 void URLRequestHttpJob::SetExtraRequestHeaders( 77 void URLRequestHttpJob::SetExtraRequestHeaders(
75 const std::string& headers) { 78 const std::string& headers) {
76 DCHECK(!transaction_.get()) << "cannot change once started"; 79 DCHECK(!transaction_.get()) << "cannot change once started";
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 request_->policy_url())) { 441 request_->policy_url())) {
439 FetchResponseCookies(); 442 FetchResponseCookies();
440 net::CookieMonster::CookieOptions options; 443 net::CookieMonster::CookieOptions options;
441 options.set_include_httponly(); 444 options.set_include_httponly();
442 ctx->cookie_store()->SetCookiesWithOptions(request_->url(), 445 ctx->cookie_store()->SetCookiesWithOptions(request_->url(),
443 response_cookies_, 446 response_cookies_,
444 options); 447 options);
445 } 448 }
446 } 449 }
447 450
448 // Get list of SDCH dictionary requests, and schedule them to be loaded.
449 if (SdchManager::Global() && 451 if (SdchManager::Global() &&
450 SdchManager::Global()->IsInSupportedDomain(request_->url())) { 452 SdchManager::Global()->IsInSupportedDomain(request_->url())) {
451 static const std::string name = "Get-Dictionary"; 453 static const std::string name = "Get-Dictionary";
452 std::string url_text; 454 std::string url_text;
453 void* iter = NULL; 455 void* iter = NULL;
454 // TODO(jar): We need to not fetch dictionaries the first time they are 456 // TODO(jar): We need to not fetch dictionaries the first time they are
455 // seen, but rather wait until we can justify their usefulness. 457 // seen, but rather wait until we can justify their usefulness.
456 // For now, we will only fetch the first dictionary, which will at least 458 // For now, we will only fetch the first dictionary, which will at least
457 // require multiple suggestions before we get additional ones for this site. 459 // require multiple suggestions before we get additional ones for this site.
458 // Eventually we should wait until a dictionary is requested several times 460 // Eventually we should wait until a dictionary is requested several times
459 // before we even download it (so that we don't waste memory or bandwidth). 461 // before we even download it (so that we don't waste memory or bandwidth).
460 if (response_info_->headers->EnumerateHeader(&iter, name, &url_text)) { 462 if (response_info_->headers->EnumerateHeader(&iter, name, &url_text)) {
461 GURL dictionary_url = request_->url().Resolve(url_text); 463 GURL dictionary_url = request_->url().Resolve(url_text);
462 SdchManager::Global()->FetchDictionary(request_->url(), dictionary_url); 464 if (SdchManager::Global()->CanFetchDictionary(request_->url(),
465 dictionary_url))
466 sdch_dictionary_url_ = dictionary_url;
463 } 467 }
464 } 468 }
465 469
466 URLRequestJob::NotifyHeadersComplete(); 470 URLRequestJob::NotifyHeadersComplete();
467 } 471 }
468 472
469 void URLRequestHttpJob::DestroyTransaction() { 473 void URLRequestHttpJob::DestroyTransaction() {
470 DCHECK(transaction_.get()); 474 DCHECK(transaction_.get());
471 475
472 transaction_.reset(); 476 transaction_.reset();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 DCHECK(response_cookies_.empty()); 562 DCHECK(response_cookies_.empty());
559 563
560 std::string name = "Set-Cookie"; 564 std::string name = "Set-Cookie";
561 std::string value; 565 std::string value;
562 566
563 void* iter = NULL; 567 void* iter = NULL;
564 while (response_info_->headers->EnumerateHeader(&iter, name, &value)) 568 while (response_info_->headers->EnumerateHeader(&iter, name, &value))
565 response_cookies_.push_back(value); 569 response_cookies_.push_back(value);
566 } 570 }
567 571
OLDNEW
« net/url_request/url_request_http_job.h ('K') | « net/url_request/url_request_http_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698