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

Side by Side Diff: components/offline_pages/background/request_coordinator.cc

Issue 2420543004: Improve the page download: (Closed)
Patch Set: Created 4 years, 2 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 // No further processing in this service window. 631 // No further processing in this service window.
632 break; 632 break;
633 default: 633 default:
634 // Make explicit choice about new status codes that actually reach here. 634 // Make explicit choice about new status codes that actually reach here.
635 // Their default is no further processing in this service window. 635 // Their default is no further processing in this service window.
636 NOTREACHED(); 636 NOTREACHED();
637 } 637 }
638 } 638 }
639 639
640 void RequestCoordinator::EnableForOffliner(int64_t request_id) { 640 void RequestCoordinator::EnableForOffliner(int64_t request_id) {
641 disabled_requests_.erase(request_id); 641 // Since the recent tab helper might call multiple times, ignore subsequent
642 // If we are not busy, start processing right away. 642 // calls for a particular request_id.
643 StartProcessingIfConnected(); 643 if (disabled_requests_.find(request_id) == disabled_requests_.end())
644 return;
645 disabled_requests_.erase(request_id);
646 // If we are not busy, start processing right away.
647 StartProcessingIfConnected();
644 } 648 }
645 649
646 void RequestCoordinator::MarkRequestCompleted(int64_t request_id) { 650 void RequestCoordinator::MarkRequestCompleted(int64_t request_id) {
651 // Since the recent tab helper might call multiple times, ignore subsequent
652 // calls for a particular request_id.
653 if (disabled_requests_.find(request_id) == disabled_requests_.end())
654 return;
655 disabled_requests_.erase(request_id);
656
647 // Remove the request, but send out SUCCEEDED instead of removed. 657 // Remove the request, but send out SUCCEEDED instead of removed.
648 std::vector<int64_t> request_ids { request_id }; 658 std::vector<int64_t> request_ids { request_id };
649 queue_->RemoveRequests( 659 queue_->RemoveRequests(
650 request_ids, 660 request_ids,
651 base::Bind(&RequestCoordinator::HandleRemovedRequestsAndCallback, 661 base::Bind(&RequestCoordinator::HandleRemovedRequestsAndCallback,
652 weak_ptr_factory_.GetWeakPtr(), 662 weak_ptr_factory_.GetWeakPtr(),
653 base::Bind(&RequestCoordinator::CompletedRequestCallback, 663 base::Bind(&RequestCoordinator::CompletedRequestCallback,
654 weak_ptr_factory_.GetWeakPtr()), 664 weak_ptr_factory_.GetWeakPtr()),
655 BackgroundSavePageResult::SUCCESS)); 665 BackgroundSavePageResult::SUCCESS));
656 } 666 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 703
694 ClientPolicyController* RequestCoordinator::GetPolicyController() { 704 ClientPolicyController* RequestCoordinator::GetPolicyController() {
695 return policy_controller_.get(); 705 return policy_controller_.get();
696 } 706 }
697 707
698 void RequestCoordinator::Shutdown() { 708 void RequestCoordinator::Shutdown() {
699 network_quality_estimator_ = nullptr; 709 network_quality_estimator_ = nullptr;
700 } 710 }
701 711
702 } // namespace offline_pages 712 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698