Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/net/net_error_helper_core.h" | 5 #include "chrome/renderer/net/net_error_helper_core.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/common/localized_error.h" | 19 #include "chrome/common/localized_error.h" |
| 20 #include "content/public/common/url_constants.h" | |
| 20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 21 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
| 22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 23 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
| 24 #include "third_party/WebKit/public/platform/WebString.h" | 25 #include "third_party/WebKit/public/platform/WebString.h" |
| 25 #include "third_party/WebKit/public/platform/WebURLError.h" | 26 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 } | 241 } |
| 241 } | 242 } |
| 242 | 243 |
| 243 if (params->override_suggestions->empty() && | 244 if (params->override_suggestions->empty() && |
| 244 !params->search_url.is_valid()) { | 245 !params->search_url.is_valid()) { |
| 245 return NULL; | 246 return NULL; |
| 246 } | 247 } |
| 247 return params.release(); | 248 return params.release(); |
| 248 } | 249 } |
| 249 | 250 |
| 251 void ReportAutoReloadSuccess(const blink::WebURLError& error, size_t count) { | |
| 252 if (error.domain.utf8() != net::kErrorDomain) | |
| 253 return; | |
| 254 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtSuccess", | |
| 255 -error.reason, | |
| 256 net::GetAllErrorCodesForUma()); | |
| 257 UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtSuccess", count); | |
| 258 if (count == 1) { | |
| 259 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtFirstSuccess", | |
| 260 -error.reason, | |
| 261 net::GetAllErrorCodesForUma()); | |
| 262 } | |
| 263 } | |
| 264 | |
| 265 void ReportAutoReloadFailure(const blink::WebURLError& error, size_t count) { | |
| 266 if (error.domain.utf8() != net::kErrorDomain) | |
| 267 return; | |
| 268 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtStop", | |
| 269 -error.reason, | |
| 270 net::GetAllErrorCodesForUma()); | |
| 271 UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtStop", count); | |
| 272 } | |
| 273 | |
| 250 } // namespace | 274 } // namespace |
| 251 | 275 |
| 252 struct NetErrorHelperCore::ErrorPageInfo { | 276 struct NetErrorHelperCore::ErrorPageInfo { |
| 253 ErrorPageInfo(blink::WebURLError error, bool was_failed_post) | 277 ErrorPageInfo(blink::WebURLError error, bool was_failed_post) |
| 254 : error(error), | 278 : error(error), |
| 255 was_failed_post(was_failed_post), | 279 was_failed_post(was_failed_post), |
| 256 needs_dns_updates(false), | 280 needs_dns_updates(false), |
| 257 reload_button_in_page(false), | 281 reload_button_in_page(false), |
| 258 load_stale_button_in_page(false), | 282 load_stale_button_in_page(false), |
| 259 is_finished_loading(false) { | 283 is_finished_loading(false), |
| 284 auto_reload_triggered(false) { | |
| 260 } | 285 } |
| 261 | 286 |
| 262 // Information about the failed page load. | 287 // Information about the failed page load. |
| 263 blink::WebURLError error; | 288 blink::WebURLError error; |
| 264 bool was_failed_post; | 289 bool was_failed_post; |
| 265 | 290 |
| 266 // Information about the status of the error page. | 291 // Information about the status of the error page. |
| 267 | 292 |
| 268 // True if a page is a DNS error page and has not yet received a final DNS | 293 // True if a page is a DNS error page and has not yet received a final DNS |
| 269 // probe status. | 294 // probe status. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 281 // the blank page is loading, to get rid of these. | 306 // the blank page is loading, to get rid of these. |
| 282 std::string navigation_correction_request_body; | 307 std::string navigation_correction_request_body; |
| 283 | 308 |
| 284 // Track if specific buttons are included in an error page, for statistics. | 309 // Track if specific buttons are included in an error page, for statistics. |
| 285 bool reload_button_in_page; | 310 bool reload_button_in_page; |
| 286 bool load_stale_button_in_page; | 311 bool load_stale_button_in_page; |
| 287 | 312 |
| 288 // True if a page has completed loading, at which point it can receive | 313 // True if a page has completed loading, at which point it can receive |
| 289 // updates. | 314 // updates. |
| 290 bool is_finished_loading; | 315 bool is_finished_loading; |
| 316 | |
| 317 // True if the auto-reload timer has fired and a reload is or has been in | |
| 318 // flight. | |
| 319 bool auto_reload_triggered; | |
| 291 }; | 320 }; |
| 292 | 321 |
| 293 bool NetErrorHelperCore::IsReloadableError( | 322 bool NetErrorHelperCore::IsReloadableError( |
| 294 const NetErrorHelperCore::ErrorPageInfo& info) { | 323 const NetErrorHelperCore::ErrorPageInfo& info) { |
| 295 return info.error.domain.utf8() == net::kErrorDomain && | 324 return info.error.domain.utf8() == net::kErrorDomain && |
| 296 info.error.reason != net::ERR_ABORTED && | 325 info.error.reason != net::ERR_ABORTED && |
| 297 !info.was_failed_post; | 326 !info.was_failed_post; |
| 298 } | 327 } |
| 299 | 328 |
| 300 NetErrorHelperCore::NetErrorHelperCore(Delegate* delegate) | 329 NetErrorHelperCore::NetErrorHelperCore(Delegate* delegate) |
| 301 : delegate_(delegate), | 330 : delegate_(delegate), |
| 302 last_probe_status_(chrome_common_net::DNS_PROBE_POSSIBLE), | 331 last_probe_status_(chrome_common_net::DNS_PROBE_POSSIBLE), |
| 303 auto_reload_enabled_(false), | 332 auto_reload_enabled_(false), |
| 304 auto_reload_timer_(new base::Timer(false, false)), | 333 auto_reload_timer_(new base::Timer(false, false)), |
| 334 auto_reload_timer_paused_(false), | |
| 335 uncommitted_load_started_(false), | |
| 305 // TODO(ellyjones): Make online_ accurate at object creation. | 336 // TODO(ellyjones): Make online_ accurate at object creation. |
|
Randy Smith (Not in Mondays)
2014/04/30 18:22:16
Right, I had forgotten about this. Doesn't this m
Elly Fong-Jones
2014/05/01 18:33:03
http://crbug.com/368796 tracks this.
| |
| 306 online_(true), | 337 online_(true), |
| 307 auto_reload_count_(0), | 338 auto_reload_count_(0), |
| 308 can_auto_reload_page_(false), | |
| 309 navigation_from_button_(NO_BUTTON) { | 339 navigation_from_button_(NO_BUTTON) { |
| 310 } | 340 } |
| 311 | 341 |
| 312 NetErrorHelperCore::~NetErrorHelperCore() { | 342 NetErrorHelperCore::~NetErrorHelperCore() { |
| 313 if (committed_error_page_info_ && can_auto_reload_page_) { | 343 if (committed_error_page_info_ && |
| 314 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtStop", | 344 committed_error_page_info_->auto_reload_triggered) { |
| 315 -committed_error_page_info_->error.reason, | 345 ReportAutoReloadFailure(committed_error_page_info_->error, |
| 316 net::GetAllErrorCodesForUma()); | 346 auto_reload_count_); |
| 317 UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtStop", auto_reload_count_); | |
| 318 } | 347 } |
| 319 } | 348 } |
| 320 | 349 |
| 321 void NetErrorHelperCore::CancelPendingFetches() { | 350 void NetErrorHelperCore::CancelPendingFetches() { |
| 322 // Cancel loading the alternate error page, and prevent any pending error page | 351 // Cancel loading the alternate error page, and prevent any pending error page |
| 323 // load from starting a new error page load. Swapping in the error page when | 352 // load from starting a new error page load. Swapping in the error page when |
| 324 // it's finished loading could abort the navigation, otherwise. | 353 // it's finished loading could abort the navigation, otherwise. |
| 325 if (committed_error_page_info_ && can_auto_reload_page_) { | |
| 326 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtStop", | |
| 327 -committed_error_page_info_->error.reason, | |
| 328 net::GetAllErrorCodesForUma()); | |
| 329 UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtStop", auto_reload_count_); | |
| 330 } | |
| 331 if (committed_error_page_info_) { | 354 if (committed_error_page_info_) { |
| 332 committed_error_page_info_->navigation_correction_url = GURL(); | 355 committed_error_page_info_->navigation_correction_url = GURL(); |
| 333 committed_error_page_info_->navigation_correction_request_body.clear(); | 356 committed_error_page_info_->navigation_correction_request_body.clear(); |
| 334 } | 357 } |
| 335 if (pending_error_page_info_) { | 358 if (pending_error_page_info_) { |
| 336 pending_error_page_info_->navigation_correction_url = GURL(); | 359 pending_error_page_info_->navigation_correction_url = GURL(); |
| 337 pending_error_page_info_->navigation_correction_request_body.clear(); | 360 pending_error_page_info_->navigation_correction_request_body.clear(); |
| 338 } | 361 } |
| 339 delegate_->CancelFetchNavigationCorrections(); | 362 delegate_->CancelFetchNavigationCorrections(); |
| 340 auto_reload_timer_->Stop(); | 363 if (auto_reload_timer_->IsRunning()) |
| 341 can_auto_reload_page_ = false; | 364 auto_reload_timer_->Stop(); |
| 365 if (auto_reload_timer_paused_) | |
|
mmenke
2014/04/30 18:06:58
I don't think either of these if's are needed. Ju
Elly Fong-Jones
2014/05/01 18:33:03
Done.
| |
| 366 auto_reload_timer_paused_ = false; | |
| 342 } | 367 } |
| 343 | 368 |
| 344 void NetErrorHelperCore::OnStop() { | 369 void NetErrorHelperCore::OnStop() { |
| 370 if (committed_error_page_info_ && | |
| 371 committed_error_page_info_->auto_reload_triggered) { | |
| 372 ReportAutoReloadFailure(committed_error_page_info_->error, | |
| 373 auto_reload_count_); | |
| 374 } | |
| 345 CancelPendingFetches(); | 375 CancelPendingFetches(); |
| 376 uncommitted_load_started_ = false; | |
| 346 auto_reload_count_ = 0; | 377 auto_reload_count_ = 0; |
| 347 } | 378 } |
| 348 | 379 |
| 349 void NetErrorHelperCore::OnStartLoad(FrameType frame_type, PageType page_type) { | 380 void NetErrorHelperCore::OnStartLoad(FrameType frame_type, PageType page_type) { |
| 350 if (frame_type != MAIN_FRAME) | 381 if (frame_type != MAIN_FRAME) |
| 351 return; | 382 return; |
| 352 | 383 |
| 384 uncommitted_load_started_ = true; | |
| 385 | |
| 353 // If there's no pending error page information associated with the page load, | 386 // If there's no pending error page information associated with the page load, |
| 354 // or the new page is not an error page, then reset pending error page state. | 387 // or the new page is not an error page, then reset pending error page state. |
| 355 if (!pending_error_page_info_ || page_type != ERROR_PAGE) { | 388 if (!pending_error_page_info_ || page_type != ERROR_PAGE) |
| 356 CancelPendingFetches(); | 389 CancelPendingFetches(); |
| 357 } else if (auto_reload_enabled_) { | |
| 358 // If an error load is starting, the resulting error page is autoreloadable. | |
| 359 can_auto_reload_page_ = IsReloadableError(*pending_error_page_info_); | |
| 360 } | |
| 361 } | 390 } |
| 362 | 391 |
| 363 void NetErrorHelperCore::OnCommitLoad(FrameType frame_type) { | 392 void NetErrorHelperCore::OnCommitLoad(FrameType frame_type, const GURL& url) { |
| 364 if (frame_type != MAIN_FRAME) | 393 if (frame_type != MAIN_FRAME) |
| 365 return; | 394 return; |
| 366 | 395 |
| 396 DCHECK(uncommitted_load_started_); | |
| 397 uncommitted_load_started_ = false; | |
| 398 | |
| 367 // Track if an error occurred due to a page button press. | 399 // Track if an error occurred due to a page button press. |
| 368 // This isn't perfect; if (for instance), the server is slow responding | 400 // This isn't perfect; if (for instance), the server is slow responding |
| 369 // to a request generated from the page reload button, and the user hits | 401 // to a request generated from the page reload button, and the user hits |
| 370 // the browser reload button, this code will still believe the | 402 // the browser reload button, this code will still believe the |
| 371 // result is from the page reload button. | 403 // result is from the page reload button. |
| 372 if (committed_error_page_info_ && pending_error_page_info_ && | 404 if (committed_error_page_info_ && pending_error_page_info_ && |
| 373 navigation_from_button_ != NO_BUTTON && | 405 navigation_from_button_ != NO_BUTTON && |
| 374 committed_error_page_info_->error.unreachableURL == | 406 committed_error_page_info_->error.unreachableURL == |
| 375 pending_error_page_info_->error.unreachableURL) { | 407 pending_error_page_info_->error.unreachableURL) { |
| 376 DCHECK(navigation_from_button_ == RELOAD_BUTTON || | 408 DCHECK(navigation_from_button_ == RELOAD_BUTTON || |
| 377 navigation_from_button_ == LOAD_STALE_BUTTON); | 409 navigation_from_button_ == LOAD_STALE_BUTTON); |
| 378 chrome_common_net::RecordEvent( | 410 chrome_common_net::RecordEvent( |
| 379 navigation_from_button_ == RELOAD_BUTTON ? | 411 navigation_from_button_ == RELOAD_BUTTON ? |
| 380 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_ERROR : | 412 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_ERROR : |
| 381 chrome_common_net::NETWORK_ERROR_PAGE_LOAD_STALE_BUTTON_ERROR); | 413 chrome_common_net::NETWORK_ERROR_PAGE_LOAD_STALE_BUTTON_ERROR); |
| 382 } | 414 } |
| 383 navigation_from_button_ = NO_BUTTON; | 415 navigation_from_button_ = NO_BUTTON; |
| 384 | 416 |
| 385 if (committed_error_page_info_ && !pending_error_page_info_ && | 417 if (committed_error_page_info_ && !pending_error_page_info_ && |
| 386 can_auto_reload_page_) { | 418 committed_error_page_info_->auto_reload_triggered) { |
| 387 int reason = committed_error_page_info_->error.reason; | 419 const blink::WebURLError& error = committed_error_page_info_->error; |
| 388 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtSuccess", | 420 const GURL& error_url = error.unreachableURL; |
| 389 -reason, | 421 if (url == error_url) |
| 390 net::GetAllErrorCodesForUma()); | 422 ReportAutoReloadSuccess(error, auto_reload_count_); |
| 391 UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtSuccess", auto_reload_count_); | 423 else if (url != GURL(content::kUnreachableWebDataURL)) |
|
Randy Smith (Not in Mondays)
2014/04/30 18:22:16
Just confirming: This will *not* trip if the user
Elly Fong-Jones
2014/05/01 18:33:03
In that case, committed_error_page_info_->auto_rel
| |
| 392 if (auto_reload_count_ == 1) { | 424 ReportAutoReloadFailure(error, auto_reload_count_); |
| 393 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtFirstSuccess", | |
| 394 -reason, | |
| 395 net::GetAllErrorCodesForUma()); | |
| 396 } | |
| 397 } | 425 } |
| 398 | 426 |
| 399 committed_error_page_info_.reset(pending_error_page_info_.release()); | 427 committed_error_page_info_.reset(pending_error_page_info_.release()); |
| 400 } | 428 } |
| 401 | 429 |
| 402 void NetErrorHelperCore::OnFinishLoad(FrameType frame_type) { | 430 void NetErrorHelperCore::OnFinishLoad(FrameType frame_type) { |
| 403 if (frame_type != MAIN_FRAME) | 431 if (frame_type != MAIN_FRAME) |
| 404 return; | 432 return; |
| 405 | 433 |
| 406 if (!committed_error_page_info_) { | 434 if (!committed_error_page_info_) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 void NetErrorHelperCore::Reload() { | 649 void NetErrorHelperCore::Reload() { |
| 622 if (!committed_error_page_info_) { | 650 if (!committed_error_page_info_) { |
| 623 return; | 651 return; |
| 624 } | 652 } |
| 625 delegate_->ReloadPage(); | 653 delegate_->ReloadPage(); |
| 626 } | 654 } |
| 627 | 655 |
| 628 bool NetErrorHelperCore::MaybeStartAutoReloadTimer() { | 656 bool NetErrorHelperCore::MaybeStartAutoReloadTimer() { |
| 629 if (!committed_error_page_info_ || | 657 if (!committed_error_page_info_ || |
| 630 !committed_error_page_info_->is_finished_loading || | 658 !committed_error_page_info_->is_finished_loading || |
| 631 !can_auto_reload_page_ || | 659 pending_error_page_info_ || |
| 632 pending_error_page_info_) { | 660 uncommitted_load_started_) { |
| 633 return false; | 661 return false; |
| 634 } | 662 } |
| 635 | 663 |
| 636 DCHECK(IsReloadableError(*committed_error_page_info_)); | 664 DCHECK(IsReloadableError(*committed_error_page_info_)); |
|
mmenke
2014/04/30 18:06:58
Suggest moving this into StartAutoReloadTimer.
Elly Fong-Jones
2014/05/01 18:33:03
Done.
| |
| 637 | 665 |
| 638 if (!online_) | 666 committed_error_page_info_->auto_reload_triggered = true; |
|
mmenke
2014/04/30 18:06:58
Suggest either DCHECKING this is true in STartAuto
Elly Fong-Jones
2014/05/01 18:33:03
Done.
| |
| 639 return false; | |
| 640 | 667 |
| 641 StartAutoReloadTimer(); | 668 StartAutoReloadTimer(); |
| 642 return true; | 669 return true; |
| 643 } | 670 } |
| 644 | 671 |
| 645 void NetErrorHelperCore::StartAutoReloadTimer() { | 672 void NetErrorHelperCore::StartAutoReloadTimer() { |
| 646 DCHECK(committed_error_page_info_); | 673 DCHECK(committed_error_page_info_); |
| 647 DCHECK(can_auto_reload_page_); | 674 |
| 675 if (!online_) { | |
| 676 auto_reload_timer_paused_ = true; | |
|
mmenke
2014/04/30 18:06:58
Should expand the CL description to include behavi
Elly Fong-Jones
2014/05/01 18:33:03
argh gerrit eats changed commit messages. Will fix
| |
| 677 return; | |
| 678 } | |
| 679 | |
| 680 auto_reload_timer_paused_ = false; | |
| 648 base::TimeDelta delay = GetAutoReloadTime(auto_reload_count_); | 681 base::TimeDelta delay = GetAutoReloadTime(auto_reload_count_); |
| 649 auto_reload_timer_->Stop(); | 682 auto_reload_timer_->Stop(); |
| 650 auto_reload_timer_->Start(FROM_HERE, delay, | 683 auto_reload_timer_->Start(FROM_HERE, delay, |
| 651 base::Bind(&NetErrorHelperCore::AutoReloadTimerFired, | 684 base::Bind(&NetErrorHelperCore::AutoReloadTimerFired, |
| 652 base::Unretained(this))); | 685 base::Unretained(this))); |
| 653 } | 686 } |
| 654 | 687 |
| 655 void NetErrorHelperCore::AutoReloadTimerFired() { | 688 void NetErrorHelperCore::AutoReloadTimerFired() { |
| 656 auto_reload_count_++; | 689 auto_reload_count_++; |
| 657 Reload(); | 690 Reload(); |
| 658 } | 691 } |
| 659 | 692 |
| 660 void NetErrorHelperCore::NetworkStateChanged(bool online) { | 693 void NetErrorHelperCore::NetworkStateChanged(bool online) { |
| 694 bool was_online = online_; | |
| 661 online_ = online; | 695 online_ = online; |
| 662 if (auto_reload_timer_->IsRunning()) { | 696 // Transitioning offline -> online |
|
mmenke
2014/04/30 18:06:58
I believe comments for else/ifs generally go insid
Elly Fong-Jones
2014/05/01 18:33:03
Moved the comment. I do not understand your remark
| |
| 663 DCHECK(committed_error_page_info_); | 697 if (!was_online && online) { |
| 664 // If there's an existing timer running, stop it and reset the retry count. | 698 if (auto_reload_timer_paused_) |
|
mmenke
2014/04/30 18:06:58
I don't think we need to check was_online here. I
Elly Fong-Jones
2014/05/01 18:33:03
I wrote the code this way to make it very clear wh
| |
| 665 auto_reload_timer_->Stop(); | 699 MaybeStartAutoReloadTimer(); |
| 666 auto_reload_count_ = 0; | 700 // Transitioning online -> offline |
| 701 } else if (was_online && !online) { | |
|
mmenke
2014/04/30 18:06:58
Again, do we get anything out of checking was_onli
Elly Fong-Jones
2014/05/01 18:33:03
No. It is just there for clarity.
| |
| 702 if (auto_reload_timer_->IsRunning()) { | |
| 703 DCHECK(committed_error_page_info_); | |
|
mmenke
2014/04/30 18:06:58
Maybe:
DCHECK(!auto_reload_timer_paused_)?
DCHECK
Elly Fong-Jones
2014/05/01 18:33:03
Done.
| |
| 704 auto_reload_timer_->Stop(); | |
| 705 auto_reload_count_ = 0; | |
| 706 auto_reload_timer_paused_ = true; | |
| 707 } | |
| 667 } | 708 } |
| 668 | |
| 669 // If the network state changed to online, maybe start auto-reloading again. | |
| 670 if (online) | |
| 671 MaybeStartAutoReloadTimer(); | |
| 672 } | 709 } |
| 673 | 710 |
| 674 bool NetErrorHelperCore::ShouldSuppressErrorPage(FrameType frame_type, | 711 bool NetErrorHelperCore::ShouldSuppressErrorPage(FrameType frame_type, |
| 675 const GURL& url) { | 712 const GURL& url) { |
| 676 // Don't suppress child frame errors. | 713 // Don't suppress child frame errors. |
| 677 if (frame_type != MAIN_FRAME) | 714 if (frame_type != MAIN_FRAME) |
| 678 return false; | 715 return false; |
| 679 | 716 |
| 680 // If |auto_reload_timer_| is still running, this error page isn't from an | 717 // If |auto_reload_timer_| is still running or is paused, this error page |
| 681 // auto reload. | 718 // isn't from an auto reload. |
| 682 if (auto_reload_timer_->IsRunning()) | 719 if (auto_reload_timer_->IsRunning() || auto_reload_timer_paused_) |
| 683 return false; | 720 return false; |
| 684 | 721 |
| 685 // If there's no committed error page, this error page wasn't from an auto | 722 // If there's no committed error page, this error page wasn't from an auto |
| 686 // reload. | 723 // reload. |
| 687 if (!committed_error_page_info_ || !can_auto_reload_page_) | 724 if (!committed_error_page_info_) |
| 688 return false; | 725 return false; |
|
mmenke
2014/04/30 18:06:58
optional: I think it may make more sense to put t
Elly Fong-Jones
2014/05/01 18:33:03
Done.
| |
| 689 | 726 |
|
mmenke
2014/04/30 18:06:58
Optional: Could throw in a DCHECK(committed_error
Elly Fong-Jones
2014/05/01 18:33:03
Done.
| |
| 690 GURL error_url = committed_error_page_info_->error.unreachableURL; | 727 GURL error_url = committed_error_page_info_->error.unreachableURL; |
| 691 // TODO(ellyjones): also plumb the error code down to CCRC and check that | 728 // TODO(ellyjones): also plumb the error code down to CCRC and check that |
| 692 if (error_url != url) | 729 if (error_url != url) |
| 693 return false; | 730 return false; |
| 694 | 731 |
| 695 // The first iteration of the timer is started by OnFinishLoad calling | 732 // The first iteration of the timer is started by OnFinishLoad calling |
| 696 // MaybeStartAutoReloadTimer, but since error pages for subsequent loads are | 733 // MaybeStartAutoReloadTimer, but since error pages for subsequent loads are |
| 697 // suppressed in this function, subsequent iterations of the timer have to be | 734 // suppressed in this function, subsequent iterations of the timer have to be |
| 698 // started here. | 735 // started here. |
| 699 MaybeStartAutoReloadTimer(); | 736 MaybeStartAutoReloadTimer(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 719 // Visual effects on page are handled in Javascript code. | 756 // Visual effects on page are handled in Javascript code. |
| 720 chrome_common_net::RecordEvent( | 757 chrome_common_net::RecordEvent( |
| 721 chrome_common_net::NETWORK_ERROR_PAGE_MORE_BUTTON_CLICKED); | 758 chrome_common_net::NETWORK_ERROR_PAGE_MORE_BUTTON_CLICKED); |
| 722 return; | 759 return; |
| 723 case NO_BUTTON: | 760 case NO_BUTTON: |
| 724 NOTREACHED(); | 761 NOTREACHED(); |
| 725 return; | 762 return; |
| 726 } | 763 } |
| 727 } | 764 } |
| 728 | 765 |
| OLD | NEW |