| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/offline_pages/background/request_coordinator.h" | 5 #include "components/offline_pages/background/request_coordinator.h" |
| 6 | 6 |
| 7 #include <limits> |
| 8 #include <string> |
| 7 #include <utility> | 9 #include <utility> |
| 10 #include <vector> |
| 8 | 11 |
| 9 #include "base/bind.h" | 12 #include "base/bind.h" |
| 10 #include "base/callback.h" | 13 #include "base/callback.h" |
| 11 #include "base/logging.h" | 14 #include "base/logging.h" |
| 12 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
| 14 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
| 15 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 16 #include "components/offline_pages/background/offliner_factory.h" | 19 #include "components/offline_pages/background/offliner_factory.h" |
| 17 #include "components/offline_pages/background/offliner_policy.h" | 20 #include "components/offline_pages/background/offliner_policy.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 117 |
| 115 RequestCoordinator::RequestCoordinator( | 118 RequestCoordinator::RequestCoordinator( |
| 116 std::unique_ptr<OfflinerPolicy> policy, | 119 std::unique_ptr<OfflinerPolicy> policy, |
| 117 std::unique_ptr<OfflinerFactory> factory, | 120 std::unique_ptr<OfflinerFactory> factory, |
| 118 std::unique_ptr<RequestQueue> queue, | 121 std::unique_ptr<RequestQueue> queue, |
| 119 std::unique_ptr<Scheduler> scheduler, | 122 std::unique_ptr<Scheduler> scheduler, |
| 120 net::NetworkQualityEstimator::NetworkQualityProvider* | 123 net::NetworkQualityEstimator::NetworkQualityProvider* |
| 121 network_quality_estimator) | 124 network_quality_estimator) |
| 122 : is_busy_(false), | 125 : is_busy_(false), |
| 123 is_starting_(false), | 126 is_starting_(false), |
| 124 is_stopped_(false), | 127 processing_state_(ProcessingWindowState::STOPPED), |
| 125 use_test_connection_type_(false), | 128 use_test_connection_type_(false), |
| 126 test_connection_type_(), | 129 test_connection_type_(), |
| 127 offliner_(nullptr), | 130 offliner_(nullptr), |
| 128 policy_(std::move(policy)), | 131 policy_(std::move(policy)), |
| 129 factory_(std::move(factory)), | 132 factory_(std::move(factory)), |
| 130 queue_(std::move(queue)), | 133 queue_(std::move(queue)), |
| 131 scheduler_(std::move(scheduler)), | 134 scheduler_(std::move(scheduler)), |
| 132 policy_controller_(new ClientPolicyController()), | 135 policy_controller_(new ClientPolicyController()), |
| 133 network_quality_estimator_(network_quality_estimator), | 136 network_quality_estimator_(network_quality_estimator), |
| 134 active_request_(nullptr), | 137 active_request_(nullptr), |
| 135 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), | 138 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), |
| 136 offliner_timeout_(base::TimeDelta::FromSeconds( | |
| 137 policy_->GetSinglePageTimeLimitInSeconds())), | |
| 138 weak_ptr_factory_(this) { | 139 weak_ptr_factory_(this) { |
| 139 DCHECK(policy_ != nullptr); | 140 DCHECK(policy_ != nullptr); |
| 140 picker_.reset( | 141 picker_.reset( |
| 141 new RequestPicker(queue_.get(), policy_.get(), this, &event_logger_)); | 142 new RequestPicker(queue_.get(), policy_.get(), this, &event_logger_)); |
| 142 } | 143 } |
| 143 | 144 |
| 144 RequestCoordinator::~RequestCoordinator() {} | 145 RequestCoordinator::~RequestCoordinator() {} |
| 145 | 146 |
| 146 int64_t RequestCoordinator::SavePageLater(const GURL& url, | 147 int64_t RequestCoordinator::SavePageLater(const GURL& url, |
| 147 const ClientId& client_id, | 148 const ClientId& client_id, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (active_request_) { | 200 if (active_request_) { |
| 200 event_logger_.RecordOfflinerResult(active_request_->client_id().name_space, | 201 event_logger_.RecordOfflinerResult(active_request_->client_id().name_space, |
| 201 last_offlining_status_, | 202 last_offlining_status_, |
| 202 active_request_->request_id()); | 203 active_request_->request_id()); |
| 203 RecordOfflinerResultUMA(active_request_->client_id(), | 204 RecordOfflinerResultUMA(active_request_->client_id(), |
| 204 active_request_->creation_time(), | 205 active_request_->creation_time(), |
| 205 last_offlining_status_); | 206 last_offlining_status_); |
| 206 is_busy_ = false; | 207 is_busy_ = false; |
| 207 active_request_.reset(); | 208 active_request_.reset(); |
| 208 } | 209 } |
| 209 | |
| 210 } | 210 } |
| 211 | 211 |
| 212 void RequestCoordinator::GetRequestsForSchedulingCallback( | 212 void RequestCoordinator::GetRequestsForSchedulingCallback( |
| 213 RequestQueue::GetRequestsResult result, | 213 RequestQueue::GetRequestsResult result, |
| 214 std::vector<std::unique_ptr<SavePageRequest>> requests) { | 214 std::vector<std::unique_ptr<SavePageRequest>> requests) { |
| 215 bool user_requested = false; | 215 bool user_requested = false; |
| 216 | 216 |
| 217 // Examine all requests, if we find a user requested one, we will use the less | 217 // Examine all requests, if we find a user requested one, we will use the less |
| 218 // restrictive conditions for user_requested requests. Otherwise we will use | 218 // restrictive conditions for user_requested requests. Otherwise we will use |
| 219 // the more restrictive non-user-requested conditions. | 219 // the more restrictive non-user-requested conditions. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 317 } |
| 318 | 318 |
| 319 void RequestCoordinator::AddRequestResultCallback( | 319 void RequestCoordinator::AddRequestResultCallback( |
| 320 RequestQueue::AddRequestResult result, | 320 RequestQueue::AddRequestResult result, |
| 321 const SavePageRequest& request) { | 321 const SavePageRequest& request) { |
| 322 NotifyAdded(request); | 322 NotifyAdded(request); |
| 323 // Inform the scheduler that we have an outstanding task. | 323 // Inform the scheduler that we have an outstanding task. |
| 324 scheduler_->Schedule(GetTriggerConditions(kUserRequest)); | 324 scheduler_->Schedule(GetTriggerConditions(kUserRequest)); |
| 325 | 325 |
| 326 if (request.user_requested()) | 326 if (request.user_requested()) |
| 327 StartProcessingIfConnected(); | 327 StartImmediatelyIfConnected(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 // Called in response to updating a request in the request queue. | 330 // Called in response to updating a request in the request queue. |
| 331 void RequestCoordinator::UpdateRequestCallback( | 331 void RequestCoordinator::UpdateRequestCallback( |
| 332 const ClientId& client_id, | 332 const ClientId& client_id, |
| 333 RequestQueue::UpdateRequestResult result) { | 333 RequestQueue::UpdateRequestResult result) { |
| 334 // If the request succeeded, nothing to do. If it failed, we can't really do | 334 // If the request succeeded, nothing to do. If it failed, we can't really do |
| 335 // much, so just log it. | 335 // much, so just log it. |
| 336 if (result != RequestQueue::UpdateRequestResult::SUCCESS) { | 336 if (result != RequestQueue::UpdateRequestResult::SUCCESS) { |
| 337 DVLOG(1) << "Failed to update request attempt details. " | 337 DVLOG(1) << "Failed to update request attempt details. " |
| 338 << static_cast<int>(result); | 338 << static_cast<int>(result); |
| 339 event_logger_.RecordUpdateRequestFailed(client_id.name_space, result); | 339 event_logger_.RecordUpdateRequestFailed(client_id.name_space, result); |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 void RequestCoordinator::UpdateMultipleRequestsCallback( | 343 void RequestCoordinator::UpdateMultipleRequestsCallback( |
| 344 std::unique_ptr<UpdateRequestsResult> result) { | 344 std::unique_ptr<UpdateRequestsResult> result) { |
| 345 for (const auto& request : result->updated_items) | 345 for (const auto& request : result->updated_items) |
| 346 NotifyChanged(request); | 346 NotifyChanged(request); |
| 347 | 347 |
| 348 bool available_user_request = false; | 348 bool available_user_request = false; |
| 349 for (const auto& request : result->updated_items) { | 349 for (const auto& request : result->updated_items) { |
| 350 if (!available_user_request && request.user_requested() && | 350 if (!available_user_request && request.user_requested() && |
| 351 request.request_state() == SavePageRequest::RequestState::AVAILABLE) { | 351 request.request_state() == SavePageRequest::RequestState::AVAILABLE) { |
| 352 available_user_request = true; | 352 available_user_request = true; |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 if (available_user_request) | 356 if (available_user_request) |
| 357 StartProcessingIfConnected(); | 357 StartImmediatelyIfConnected(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 // When we successfully remove a request that completed successfully, move on to | 360 // When we successfully remove a request that completed successfully, move on to |
| 361 // the next request. | 361 // the next request. |
| 362 void RequestCoordinator::CompletedRequestCallback( | 362 void RequestCoordinator::CompletedRequestCallback( |
| 363 const MultipleItemStatuses& status) { | 363 const MultipleItemStatuses& status) { |
| 364 TryNextRequest(); | 364 TryNextRequest(); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void RequestCoordinator::HandleRemovedRequestsAndCallback( | 367 void RequestCoordinator::HandleRemovedRequestsAndCallback( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 385 | 385 |
| 386 void RequestCoordinator::ScheduleAsNeeded() { | 386 void RequestCoordinator::ScheduleAsNeeded() { |
| 387 // Get all requests from queue (there is no filtering mechanism). | 387 // Get all requests from queue (there is no filtering mechanism). |
| 388 queue_->GetRequests( | 388 queue_->GetRequests( |
| 389 base::Bind(&RequestCoordinator::GetRequestsForSchedulingCallback, | 389 base::Bind(&RequestCoordinator::GetRequestsForSchedulingCallback, |
| 390 weak_ptr_factory_.GetWeakPtr())); | 390 weak_ptr_factory_.GetWeakPtr())); |
| 391 } | 391 } |
| 392 | 392 |
| 393 void RequestCoordinator::StopProcessing( | 393 void RequestCoordinator::StopProcessing( |
| 394 Offliner::RequestStatus stop_status) { | 394 Offliner::RequestStatus stop_status) { |
| 395 is_stopped_ = true; | 395 processing_state_ = ProcessingWindowState::STOPPED; |
| 396 StopPrerendering(stop_status); | 396 StopPrerendering(stop_status); |
| 397 | 397 |
| 398 // Let the scheduler know we are done processing. | 398 // Let the scheduler know we are done processing. |
| 399 scheduler_callback_.Run(true); | 399 scheduler_callback_.Run(true); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void RequestCoordinator::HandleWatchdogTimeout() { | 402 void RequestCoordinator::HandleWatchdogTimeout() { |
| 403 StopProcessing(Offliner::REQUEST_COORDINATOR_TIMED_OUT); | 403 StopProcessing(Offliner::REQUEST_COORDINATOR_TIMED_OUT); |
| 404 } | 404 } |
| 405 | 405 |
| 406 // Returns true if the caller should expect a callback, false otherwise. For | 406 // Returns true if the caller should expect a callback, false otherwise. For |
| 407 // instance, this would return false if a request is already in progress. | 407 // instance, this would return false if a request is already in progress. |
| 408 bool RequestCoordinator::StartProcessing( | 408 bool RequestCoordinator::StartProcessing( |
| 409 const DeviceConditions& device_conditions, | 409 const DeviceConditions& device_conditions, |
| 410 const base::Callback<void(bool)>& callback) { | 410 const base::Callback<void(bool)>& callback) { |
| 411 return StartProcessingInternal(ProcessingWindowState::SCHEDULED_WINDOW, |
| 412 device_conditions, callback); |
| 413 } |
| 414 |
| 415 bool RequestCoordinator::StartProcessingInternal( |
| 416 const ProcessingWindowState processing_state, |
| 417 const DeviceConditions& device_conditions, |
| 418 const base::Callback<void(bool)>& callback) { |
| 411 current_conditions_.reset(new DeviceConditions(device_conditions)); | 419 current_conditions_.reset(new DeviceConditions(device_conditions)); |
| 412 if (is_starting_ || is_busy_) | 420 if (is_starting_ || is_busy_) |
| 413 return false; | 421 return false; |
| 414 is_starting_ = true; | 422 is_starting_ = true; |
| 423 processing_state_ = processing_state; |
| 424 scheduler_callback_ = callback; |
| 415 | 425 |
| 416 // Mark the time at which we started processing so we can check our time | 426 // Mark the time at which we started processing so we can check our time |
| 417 // budget. | 427 // budget. |
| 418 operation_start_time_ = base::Time::Now(); | 428 operation_start_time_ = base::Time::Now(); |
| 419 | 429 |
| 420 is_stopped_ = false; | |
| 421 scheduler_callback_ = callback; | |
| 422 | |
| 423 TryNextRequest(); | 430 TryNextRequest(); |
| 424 | 431 |
| 425 return true; | 432 return true; |
| 426 } | 433 } |
| 427 | 434 |
| 428 void RequestCoordinator::StartProcessingIfConnected() { | 435 void RequestCoordinator::StartImmediatelyIfConnected() { |
| 429 OfflinerImmediateStartStatus immediate_start_status = TryImmediateStart(); | 436 OfflinerImmediateStartStatus immediate_start_status = TryImmediateStart(); |
| 430 UMA_HISTOGRAM_ENUMERATION( | 437 UMA_HISTOGRAM_ENUMERATION( |
| 431 "OfflinePages.Background.ImmediateStartStatus", immediate_start_status, | 438 "OfflinePages.Background.ImmediateStartStatus", immediate_start_status, |
| 432 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT); | 439 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT); |
| 433 } | 440 } |
| 434 | 441 |
| 435 RequestCoordinator::OfflinerImmediateStartStatus | 442 RequestCoordinator::OfflinerImmediateStartStatus |
| 436 RequestCoordinator::TryImmediateStart() { | 443 RequestCoordinator::TryImmediateStart() { |
| 437 // Make sure not already busy processing. | 444 // Make sure not already busy processing. |
| 438 if (is_busy_) | 445 if (is_busy_) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 451 return OfflinerImmediateStartStatus::WEAK_CONNECTION; | 458 return OfflinerImmediateStartStatus::WEAK_CONNECTION; |
| 452 } else if (GetConnectionType() == | 459 } else if (GetConnectionType() == |
| 453 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) { | 460 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) { |
| 454 return OfflinerImmediateStartStatus::NO_CONNECTION; | 461 return OfflinerImmediateStartStatus::NO_CONNECTION; |
| 455 } | 462 } |
| 456 | 463 |
| 457 // Start processing with manufactured conservative battery conditions | 464 // Start processing with manufactured conservative battery conditions |
| 458 // (i.e., assume no battery). | 465 // (i.e., assume no battery). |
| 459 // TODO(dougarnett): Obtain actual battery conditions (from Android/Java). | 466 // TODO(dougarnett): Obtain actual battery conditions (from Android/Java). |
| 460 DeviceConditions device_conditions(false, 0, GetConnectionType()); | 467 DeviceConditions device_conditions(false, 0, GetConnectionType()); |
| 461 if (StartProcessing(device_conditions, base::Bind(&EmptySchedulerCallback))) | 468 if (StartProcessingInternal(ProcessingWindowState::IMMEDIATE_WINDOW, |
| 469 device_conditions, |
| 470 base::Bind(&EmptySchedulerCallback))) |
| 462 return OfflinerImmediateStartStatus::STARTED; | 471 return OfflinerImmediateStartStatus::STARTED; |
| 463 else | 472 else |
| 464 return OfflinerImmediateStartStatus::NOT_ACCEPTED; | 473 return OfflinerImmediateStartStatus::NOT_ACCEPTED; |
| 465 } | 474 } |
| 466 | 475 |
| 467 void RequestCoordinator::TryNextRequest() { | 476 void RequestCoordinator::TryNextRequest() { |
| 468 // If there is no time left in the budget, return to the scheduler. | 477 // If there is no time left in the budget, return to the scheduler. |
| 469 // We do not remove the pending task that was set up earlier in case | 478 // We do not remove the pending task that was set up earlier in case |
| 470 // we run out of time, so the background scheduler will return to us | 479 // we run out of time, so the background scheduler will return to us |
| 471 // at the next opportunity to run background tasks. | 480 // at the next opportunity to run background tasks. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 488 weak_ptr_factory_.GetWeakPtr()), | 497 weak_ptr_factory_.GetWeakPtr()), |
| 489 current_conditions_.get(), | 498 current_conditions_.get(), |
| 490 disabled_requests_); | 499 disabled_requests_); |
| 491 } | 500 } |
| 492 | 501 |
| 493 // Called by the request picker when a request has been picked. | 502 // Called by the request picker when a request has been picked. |
| 494 void RequestCoordinator::RequestPicked(const SavePageRequest& request) { | 503 void RequestCoordinator::RequestPicked(const SavePageRequest& request) { |
| 495 is_starting_ = false; | 504 is_starting_ = false; |
| 496 | 505 |
| 497 // Make sure we were not stopped while picking. | 506 // Make sure we were not stopped while picking. |
| 498 if (!is_stopped_) { | 507 if (processing_state_ != ProcessingWindowState::STOPPED) { |
| 499 // Send the request on to the offliner. | 508 // Send the request on to the offliner. |
| 500 SendRequestToOffliner(request); | 509 SendRequestToOffliner(request); |
| 501 } | 510 } |
| 502 } | 511 } |
| 503 | 512 |
| 504 void RequestCoordinator::RequestNotPicked( | 513 void RequestCoordinator::RequestNotPicked( |
| 505 bool non_user_requested_tasks_remaining) { | 514 bool non_user_requested_tasks_remaining) { |
| 506 is_starting_ = false; | 515 is_starting_ = false; |
| 507 | 516 |
| 508 // Clear the outstanding "safety" task in the scheduler. | 517 // Clear the outstanding "safety" task in the scheduler. |
| 509 scheduler_->Unschedule(); | 518 scheduler_->Unschedule(); |
| 510 | 519 |
| 511 // If disabled tasks remain, post a new safety task for 5 sec from now. | 520 // If disabled tasks remain, post a new safety task for 5 sec from now. |
| 512 if (disabled_requests_.size() > 0) { | 521 if (disabled_requests_.size() > 0) { |
| 513 scheduler_->BackupSchedule(GetTriggerConditions(kUserRequest), | 522 scheduler_->BackupSchedule(GetTriggerConditions(kUserRequest), |
| 514 kDisabledTaskRecheckSeconds); | 523 kDisabledTaskRecheckSeconds); |
| 515 } else if (non_user_requested_tasks_remaining) { | 524 } else if (non_user_requested_tasks_remaining) { |
| 516 // If we don't have any of those, check for non-user-requested tasks. | 525 // If we don't have any of those, check for non-user-requested tasks. |
| 517 scheduler_->Schedule(GetTriggerConditions(!kUserRequest)); | 526 scheduler_->Schedule(GetTriggerConditions(!kUserRequest)); |
| 518 } | 527 } |
| 519 | 528 |
| 520 // Let the scheduler know we are done processing. | 529 // Let the scheduler know we are done processing. |
| 521 scheduler_callback_.Run(true); | 530 scheduler_callback_.Run(true); |
| 522 } | 531 } |
| 523 | 532 |
| 524 void RequestCoordinator::SendRequestToOffliner(const SavePageRequest& request) { | 533 void RequestCoordinator::SendRequestToOffliner(const SavePageRequest& request) { |
| 525 // Check that offlining didn't get cancelled while performing some async | 534 // Check that offlining didn't get cancelled while performing some async |
| 526 // steps. | 535 // steps. |
| 527 if (is_stopped_) | 536 if (processing_state_ == ProcessingWindowState::STOPPED) |
| 528 return; | 537 return; |
| 529 | 538 |
| 530 GetOffliner(); | 539 GetOffliner(); |
| 531 if (!offliner_) { | 540 if (!offliner_) { |
| 532 DVLOG(0) << "Unable to create Offliner. " | 541 DVLOG(0) << "Unable to create Offliner. " |
| 533 << "Cannot background offline page."; | 542 << "Cannot background offline page."; |
| 534 return; | 543 return; |
| 535 } | 544 } |
| 536 | 545 |
| 537 DCHECK(!is_busy_); | 546 DCHECK(!is_busy_); |
| 538 is_busy_ = true; | 547 is_busy_ = true; |
| 539 | 548 |
| 540 // Update the request for this attempt to start it. | 549 // Update the request for this attempt to start it. |
| 541 SavePageRequest updated_request(request); | 550 SavePageRequest updated_request(request); |
| 542 updated_request.MarkAttemptStarted(base::Time::Now()); | 551 updated_request.MarkAttemptStarted(base::Time::Now()); |
| 543 queue_->UpdateRequest( | 552 queue_->UpdateRequest( |
| 544 updated_request, | 553 updated_request, |
| 545 base::Bind(&RequestCoordinator::UpdateRequestCallback, | 554 base::Bind(&RequestCoordinator::UpdateRequestCallback, |
| 546 weak_ptr_factory_.GetWeakPtr(), updated_request.client_id())); | 555 weak_ptr_factory_.GetWeakPtr(), updated_request.client_id())); |
| 547 active_request_.reset(new SavePageRequest(updated_request)); | 556 active_request_.reset(new SavePageRequest(updated_request)); |
| 548 | 557 |
| 549 // Start the load and save process in the offliner (Async). | 558 // Start the load and save process in the offliner (Async). |
| 550 if (offliner_->LoadAndSave( | 559 if (offliner_->LoadAndSave( |
| 551 updated_request, base::Bind(&RequestCoordinator::OfflinerDoneCallback, | 560 updated_request, base::Bind(&RequestCoordinator::OfflinerDoneCallback, |
| 552 weak_ptr_factory_.GetWeakPtr()))) { | 561 weak_ptr_factory_.GetWeakPtr()))) { |
| 553 // Start a watchdog timer to catch pre-renders running too long | 562 base::TimeDelta timeout; |
| 554 watchdog_timer_.Start(FROM_HERE, offliner_timeout_, this, | 563 if (processing_state_ == ProcessingWindowState::SCHEDULED_WINDOW) { |
| 564 timeout = base::TimeDelta::FromSeconds( |
| 565 policy_->GetSinglePageTimeLimitWhenBackgroundScheduledInSeconds()); |
| 566 } else { |
| 567 DCHECK(processing_state_ == ProcessingWindowState::IMMEDIATE_WINDOW); |
| 568 timeout = base::TimeDelta::FromSeconds( |
| 569 policy_->GetSinglePageTimeLimitForImmediateLoadInSeconds()); |
| 570 } |
| 571 watchdog_timer_.Start(FROM_HERE, timeout, this, |
| 555 &RequestCoordinator::HandleWatchdogTimeout); | 572 &RequestCoordinator::HandleWatchdogTimeout); |
| 556 } else { | 573 } else { |
| 557 is_busy_ = false; | 574 is_busy_ = false; |
| 558 DVLOG(0) << "Unable to start LoadAndSave"; | 575 DVLOG(0) << "Unable to start LoadAndSave"; |
| 559 StopProcessing(Offliner::PRERENDERING_NOT_STARTED); | 576 StopProcessing(Offliner::PRERENDERING_NOT_STARTED); |
| 560 } | 577 } |
| 561 } | 578 } |
| 562 | 579 |
| 563 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, | 580 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, |
| 564 Offliner::RequestStatus status) { | 581 Offliner::RequestStatus status) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 } | 654 } |
| 638 } | 655 } |
| 639 | 656 |
| 640 void RequestCoordinator::EnableForOffliner(int64_t request_id) { | 657 void RequestCoordinator::EnableForOffliner(int64_t request_id) { |
| 641 // Since the recent tab helper might call multiple times, ignore subsequent | 658 // Since the recent tab helper might call multiple times, ignore subsequent |
| 642 // calls for a particular request_id. | 659 // calls for a particular request_id. |
| 643 if (disabled_requests_.find(request_id) == disabled_requests_.end()) | 660 if (disabled_requests_.find(request_id) == disabled_requests_.end()) |
| 644 return; | 661 return; |
| 645 disabled_requests_.erase(request_id); | 662 disabled_requests_.erase(request_id); |
| 646 // If we are not busy, start processing right away. | 663 // If we are not busy, start processing right away. |
| 647 StartProcessingIfConnected(); | 664 StartImmediatelyIfConnected(); |
| 648 } | 665 } |
| 649 | 666 |
| 650 void RequestCoordinator::MarkRequestCompleted(int64_t request_id) { | 667 void RequestCoordinator::MarkRequestCompleted(int64_t request_id) { |
| 651 // Since the recent tab helper might call multiple times, ignore subsequent | 668 // Since the recent tab helper might call multiple times, ignore subsequent |
| 652 // calls for a particular request_id. | 669 // calls for a particular request_id. |
| 653 if (disabled_requests_.find(request_id) == disabled_requests_.end()) | 670 if (disabled_requests_.find(request_id) == disabled_requests_.end()) |
| 654 return; | 671 return; |
| 655 disabled_requests_.erase(request_id); | 672 disabled_requests_.erase(request_id); |
| 656 | 673 |
| 657 // Remove the request, but send out SUCCEEDED instead of removed. | 674 // Remove the request, but send out SUCCEEDED instead of removed. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 | 720 |
| 704 ClientPolicyController* RequestCoordinator::GetPolicyController() { | 721 ClientPolicyController* RequestCoordinator::GetPolicyController() { |
| 705 return policy_controller_.get(); | 722 return policy_controller_.get(); |
| 706 } | 723 } |
| 707 | 724 |
| 708 void RequestCoordinator::Shutdown() { | 725 void RequestCoordinator::Shutdown() { |
| 709 network_quality_estimator_ = nullptr; | 726 network_quality_estimator_ = nullptr; |
| 710 } | 727 } |
| 711 | 728 |
| 712 } // namespace offline_pages | 729 } // namespace offline_pages |
| OLD | NEW |