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

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

Issue 7044092: Not allow compression when requesting multimedia (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 6 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 | « media/filters/ffmpeg_demuxer.cc ('k') | webkit/glue/media/buffered_resource_loader.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 // The transaction started synchronously, but we need to notify the 392 // The transaction started synchronously, but we need to notify the
393 // URLRequest delegate via the message loop. 393 // URLRequest delegate via the message loop.
394 MessageLoop::current()->PostTask( 394 MessageLoop::current()->PostTask(
395 FROM_HERE, 395 FROM_HERE,
396 method_factory_.NewRunnableMethod( 396 method_factory_.NewRunnableMethod(
397 &URLRequestHttpJob::OnStartCompleted, rv)); 397 &URLRequestHttpJob::OnStartCompleted, rv));
398 } 398 }
399 399
400 void URLRequestHttpJob::AddExtraHeaders() { 400 void URLRequestHttpJob::AddExtraHeaders() {
401 // TODO(jar): Consider optimizing away SDCH advertising bytes when the URL is 401 // Supply Accept-Encoding field only if it is not already provided.
402 // probably an img or such (and SDCH encoding is not likely). 402 // It should be provided IF the content is known to have restrictions on
403 bool advertise_sdch = SdchManager::Global() && 403 // potential encoding, such as streaming multi-media.
404 SdchManager::Global()->IsInSupportedDomain(request_->url()); 404 // For details see bug 47381 -- customer misconfigured server so it would
rvargas (doing something else) 2011/06/16 01:39:40 Nit: I would just mention the bug number and leave
405 std::string avail_dictionaries; 405 // compress multimedia content, and it was extremely hard to figure out
406 if (advertise_sdch) { 406 // why Chrome doesn't display the mopvie, because Safari 4 and Firefox 3.x
407 SdchManager::Global()->GetAvailDictionaryList(request_->url(), 407 // displayed it perfectly.
408 &avail_dictionaries); 408 // TODO(jar, enal): jpeg files etc. should set up a request header if
409 // possible. Right now it is done only by buffered_resource_loader and
410 // simple_data_source.
411 if (!request_info_.extra_headers.HasHeader(
412 HttpRequestHeaders::kAcceptEncoding)) {
413 bool advertise_sdch = SdchManager::Global() &&
414 SdchManager::Global()->IsInSupportedDomain(request_->url());
415 std::string avail_dictionaries;
416 if (advertise_sdch) {
417 SdchManager::Global()->GetAvailDictionaryList(request_->url(),
418 &avail_dictionaries);
409 419
410 // The AllowLatencyExperiment() is only true if we've successfully done a 420 // The AllowLatencyExperiment() is only true if we've successfully done a
411 // full SDCH compression recently in this browser session for this host. 421 // full SDCH compression recently in this browser session for this host.
412 // Note that for this path, there might be no applicable dictionaries, and 422 // Note that for this path, there might be no applicable dictionaries,
413 // hence we can't participate in the experiment. 423 // and hence we can't participate in the experiment.
414 if (!avail_dictionaries.empty() && 424 if (!avail_dictionaries.empty() &&
415 SdchManager::Global()->AllowLatencyExperiment(request_->url())) { 425 SdchManager::Global()->AllowLatencyExperiment(request_->url())) {
416 // We are participating in the test (or control), and hence we'll 426 // We are participating in the test (or control), and hence we'll
417 // eventually record statistics via either SDCH_EXPERIMENT_DECODE or 427 // eventually record statistics via either SDCH_EXPERIMENT_DECODE or
418 // SDCH_EXPERIMENT_HOLDBACK, and we'll need some packet timing data. 428 // SDCH_EXPERIMENT_HOLDBACK, and we'll need some packet timing data.
419 packet_timing_enabled_ = true; 429 packet_timing_enabled_ = true;
420 if (base::RandDouble() < .01) { 430 if (base::RandDouble() < .01) {
421 sdch_test_control_ = true; // 1% probability. 431 sdch_test_control_ = true; // 1% probability.
422 advertise_sdch = false; 432 advertise_sdch = false;
423 } else { 433 } else {
424 sdch_test_activated_ = true; 434 sdch_test_activated_ = true;
435 }
436 }
437 }
438
439 // Supply Accept-Encoding headers first so that it is more likely that they
440 // will be in the first transmitted packet. This can sometimes make it
441 // easier to filter and analyze the streams to assure that a proxy has not
442 // damaged these headers. Some proxies deliberately corrupt Accept-Encoding
443 // headers.
444 if (!advertise_sdch) {
445 // Tell the server what compression formats we support (other than SDCH).
446 request_info_.extra_headers.SetHeader(
447 HttpRequestHeaders::kAcceptEncoding, "gzip,deflate");
448 } else {
449 // Include SDCH in acceptable list.
450 request_info_.extra_headers.SetHeader(
451 HttpRequestHeaders::kAcceptEncoding, "gzip,deflate,sdch");
452 if (!avail_dictionaries.empty()) {
453 request_info_.extra_headers.SetHeader(
454 kAvailDictionaryHeader,
455 avail_dictionaries);
456 sdch_dictionary_advertised_ = true;
457 // Since we're tagging this transaction as advertising a dictionary,
458 // we'll definitely employ an SDCH filter (or tentative sdch filter)
459 // when we get a response. When done, we'll record histograms via
460 // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet
461 // arrival times.
462 packet_timing_enabled_ = true;
425 } 463 }
426 } 464 }
427 } 465 }
428 466
429 // Supply Accept-Encoding headers first so that it is more likely that they
430 // will be in the first transmitted packet. This can sometimes make it easier
431 // to filter and analyze the streams to assure that a proxy has not damaged
432 // these headers. Some proxies deliberately corrupt Accept-Encoding headers.
433 if (!advertise_sdch) {
434 // Tell the server what compression formats we support (other than SDCH).
435 request_info_.extra_headers.SetHeader(
436 HttpRequestHeaders::kAcceptEncoding, "gzip,deflate");
437 } else {
438 // Include SDCH in acceptable list.
439 request_info_.extra_headers.SetHeader(
440 HttpRequestHeaders::kAcceptEncoding, "gzip,deflate,sdch");
441 if (!avail_dictionaries.empty()) {
442 request_info_.extra_headers.SetHeader(
443 kAvailDictionaryHeader,
444 avail_dictionaries);
445 sdch_dictionary_advertised_ = true;
446 // Since we're tagging this transaction as advertising a dictionary, we'll
447 // definitely employ an SDCH filter (or tentative sdch filter) when we get
448 // a response. When done, we'll record histograms via SDCH_DECODE or
449 // SDCH_PASSTHROUGH. Hence we need to record packet arrival times.
450 packet_timing_enabled_ = true;
451 }
452 }
453
454 URLRequestContext* context = request_->context(); 467 URLRequestContext* context = request_->context();
455 if (context) { 468 if (context) {
456 // Only add default Accept-Language and Accept-Charset if the request 469 // Only add default Accept-Language and Accept-Charset if the request
457 // didn't have them specified. 470 // didn't have them specified.
458 if (!context->accept_language().empty()) { 471 if (!context->accept_language().empty()) {
459 request_info_.extra_headers.SetHeaderIfMissing( 472 request_info_.extra_headers.SetHeaderIfMissing(
460 HttpRequestHeaders::kAcceptLanguage, 473 HttpRequestHeaders::kAcceptLanguage,
461 context->accept_language()); 474 context->accept_language());
462 } 475 }
463 if (!context->accept_charset().empty()) { 476 if (!context->accept_charset().empty()) {
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 } 1422 }
1410 1423
1411 bool URLRequestHttpJob::IsCompressibleContent() const { 1424 bool URLRequestHttpJob::IsCompressibleContent() const {
1412 std::string mime_type; 1425 std::string mime_type;
1413 return GetMimeType(&mime_type) && 1426 return GetMimeType(&mime_type) &&
1414 (IsSupportedJavascriptMimeType(mime_type.c_str()) || 1427 (IsSupportedJavascriptMimeType(mime_type.c_str()) ||
1415 IsSupportedNonImageMimeType(mime_type.c_str())); 1428 IsSupportedNonImageMimeType(mime_type.c_str()));
1416 } 1429 }
1417 1430
1418 } // namespace net 1431 } // namespace net
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | webkit/glue/media/buffered_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698