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

Side by Side Diff: media/blink/resource_multibuffer_data_provider.cc

Issue 2338963002: Store, use and send etags. (Closed)
Patch Set: comments addressed Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "media/blink/resource_multibuffer_data_provider.h" 5 #include "media/blink/resource_multibuffer_data_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Terminate, 77 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Terminate,
78 weak_factory_.GetWeakPtr())); 78 weak_factory_.GetWeakPtr()));
79 return; 79 return;
80 } 80 }
81 81
82 request.setHTTPHeaderField( 82 request.setHTTPHeaderField(
83 WebString::fromUTF8(net::HttpRequestHeaders::kRange), 83 WebString::fromUTF8(net::HttpRequestHeaders::kRange),
84 WebString::fromUTF8( 84 WebString::fromUTF8(
85 net::HttpByteRange::RightUnbounded(byte_pos()).GetHeaderValue())); 85 net::HttpByteRange::RightUnbounded(byte_pos()).GetHeaderValue()));
86 86
87 if (!url_data_->etag().empty()) {
88 request.setHTTPHeaderField(WebString::fromUTF8("If-Match"),
89 WebString::fromUTF8(url_data_->etag()));
90 }
91
87 url_data_->frame()->setReferrerForRequest(request, blink::WebURL()); 92 url_data_->frame()->setReferrerForRequest(request, blink::WebURL());
88 93
89 // Disable compression, compression for audio/video doesn't make sense... 94 // Disable compression, compression for audio/video doesn't make sense...
90 request.setHTTPHeaderField( 95 request.setHTTPHeaderField(
91 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), 96 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding),
92 WebString::fromUTF8("identity;q=1, *;q=0")); 97 WebString::fromUTF8("identity;q=1, *;q=0"));
93 98
94 // Check for our test WebURLLoader. 99 // Check for our test WebURLLoader.
95 std::unique_ptr<WebURLLoader> loader; 100 std::unique_ptr<WebURLLoader> loader;
96 if (test_loader_) { 101 if (test_loader_) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 redirects_to_ = GURL(); 239 redirects_to_ = GURL();
235 } 240 }
236 241
237 base::Time last_modified; 242 base::Time last_modified;
238 if (base::Time::FromString( 243 if (base::Time::FromString(
239 response.httpHeaderField("Last-Modified").utf8().data(), 244 response.httpHeaderField("Last-Modified").utf8().data(),
240 &last_modified)) { 245 &last_modified)) {
241 destination_url_data->set_last_modified(last_modified); 246 destination_url_data->set_last_modified(last_modified);
242 } 247 }
243 248
249 destination_url_data->set_etag(
250 response.httpHeaderField("ETag").utf8().data());
251
244 destination_url_data->set_valid_until(base::Time::Now() + 252 destination_url_data->set_valid_until(base::Time::Now() +
245 GetCacheValidUntil(response)); 253 GetCacheValidUntil(response));
246 254
247 uint32_t reasons = GetReasonsForUncacheability(response); 255 uint32_t reasons = GetReasonsForUncacheability(response);
248 destination_url_data->set_cacheable(reasons == 0); 256 destination_url_data->set_cacheable(reasons == 0);
249 UMA_HISTOGRAM_BOOLEAN("Media.CacheUseful", reasons == 0); 257 UMA_HISTOGRAM_BOOLEAN("Media.CacheUseful", reasons == 0);
250 int shift = 0; 258 int shift = 0;
251 int max_enum = base::bits::Log2Ceiling(kMaxReason); 259 int max_enum = base::bits::Log2Ceiling(kMaxReason);
252 while (reasons) { 260 while (reasons) {
253 DCHECK_LT(shift, max_enum); // Sanity check. 261 DCHECK_LT(shift, max_enum); // Sanity check.
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 547 }
540 548
541 if (byte_pos() != first_byte_position) { 549 if (byte_pos() != first_byte_position) {
542 return false; 550 return false;
543 } 551 }
544 552
545 return true; 553 return true;
546 } 554 }
547 555
548 } // namespace media 556 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698