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

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

Issue 1777153002: Improve retry support for media network loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 17 matching lines...) Expand all
28 using blink::WebURLLoader; 28 using blink::WebURLLoader;
29 using blink::WebURLLoaderOptions; 29 using blink::WebURLLoaderOptions;
30 using blink::WebURLRequest; 30 using blink::WebURLRequest;
31 using blink::WebURLResponse; 31 using blink::WebURLResponse;
32 32
33 namespace media { 33 namespace media {
34 34
35 // The number of milliseconds to wait before retrying a failed load. 35 // The number of milliseconds to wait before retrying a failed load.
36 const int kLoaderFailedRetryDelayMs = 250; 36 const int kLoaderFailedRetryDelayMs = 250;
37 37
38 // Each retry, add this many MS to the delay.
39 const int kAdditionalDelayPerRetryMs = 50;
40
38 // The number of milliseconds to wait before retrying when the server 41 // The number of milliseconds to wait before retrying when the server
39 // decides to not give us all the data at once. 42 // decides to not give us all the data at once.
40 const int kLoaderPartialRetryDelayMs = 25; 43 const int kLoaderPartialRetryDelayMs = 25;
41 44
42 const int kHttpOK = 200; 45 const int kHttpOK = 200;
43 const int kHttpPartialContent = 206; 46 const int kHttpPartialContent = 206;
44 const int kHttpRangeNotSatisfiable = 416; 47 const int kHttpRangeNotSatisfiable = 416;
45 const int kMaxRetries = 3; 48 // total delay is:
49 // (kLoaderPartialRetryDelayMs +
50 // kAdditionalDelayPerRetryMs * (kMaxRetries - 1) / 2) * kMaxretries = 29250 ms
51 const int kMaxRetries = 30;
46 52
47 ResourceMultiBufferDataProvider::ResourceMultiBufferDataProvider( 53 ResourceMultiBufferDataProvider::ResourceMultiBufferDataProvider(
48 UrlData* url_data, 54 UrlData* url_data,
49 MultiBufferBlockId pos) 55 MultiBufferBlockId pos)
50 : pos_(pos), 56 : pos_(pos),
51 url_data_(url_data), 57 url_data_(url_data),
52 retries_(0), 58 retries_(0),
53 cors_mode_(url_data->cors_mode()), 59 cors_mode_(url_data->cors_mode()),
54 origin_(url_data->url().GetOrigin()), 60 origin_(url_data->url().GetOrigin()),
55 weak_factory_(this) { 61 weak_factory_(this) {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 << ", domain=" << error.domain.utf8().data() 410 << ", domain=" << error.domain.utf8().data()
405 << ", localizedDescription=" 411 << ", localizedDescription="
406 << error.localizedDescription.utf8().data(); 412 << error.localizedDescription.utf8().data();
407 DCHECK(active_loader_.get()); 413 DCHECK(active_loader_.get());
408 414
409 if (retries_ < kMaxRetries && pos_ != 0) { 415 if (retries_ < kMaxRetries && pos_ != 0) {
410 retries_++; 416 retries_++;
411 base::MessageLoop::current()->PostDelayedTask( 417 base::MessageLoop::current()->PostDelayedTask(
412 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Start, 418 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Start,
413 weak_factory_.GetWeakPtr()), 419 weak_factory_.GetWeakPtr()),
414 base::TimeDelta::FromMilliseconds(kLoaderFailedRetryDelayMs)); 420 base::TimeDelta::FromMilliseconds(
421 kLoaderFailedRetryDelayMs + kAdditionalDelayPerRetryMs * retries_));
DaleCurtis 2016/03/10 01:23:32 IIRC we reuse the BufferedDataSource unittest for
hubbe 2016/03/11 03:18:53 No, we do not. Also, the tests we have weren't rea
415 } else { 422 } else {
416 // We don't need to continue loading after failure. 423 // We don't need to continue loading after failure.
417 // 424 //
418 // Keep it alive until we exit this method so that |error| remains valid. 425 // Keep it alive until we exit this method so that |error| remains valid.
419 scoped_ptr<ActiveLoader> active_loader = std::move(active_loader_); 426 scoped_ptr<ActiveLoader> active_loader = std::move(active_loader_);
420 url_data_->Fail(); 427 url_data_->Fail();
421 } 428 }
422 } 429 }
423 430
424 bool ResourceMultiBufferDataProvider::ParseContentRange( 431 bool ResourceMultiBufferDataProvider::ParseContentRange(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 499 }
493 500
494 if (byte_pos() != first_byte_position) { 501 if (byte_pos() != first_byte_position) {
495 return false; 502 return false;
496 } 503 }
497 504
498 return true; 505 return true;
499 } 506 }
500 507
501 } // namespace media 508 } // namespace media
OLDNEW
« media/blink/buffered_data_source_unittest.cc ('K') | « media/blink/buffered_data_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698