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

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

Issue 2091473004: Add the ability to cancel prerender reqeusts and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with pre-render single instance changes. Created 4 years, 6 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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Returns the status of the most recent offlining. 75 // Returns the status of the most recent offlining.
76 Offliner::RequestStatus last_offlining_status() { 76 Offliner::RequestStatus last_offlining_status() {
77 return last_offlining_status_; 77 return last_offlining_status_;
78 } 78 }
79 79
80 bool is_busy() { 80 bool is_busy() {
81 return is_busy_; 81 return is_busy_;
82 } 82 }
83 83
84 bool is_canceled() {
dougarnett 2016/06/23 17:19:17 or maybe was_canceled?
dougarnett 2016/06/23 17:19:17 // Tracks whether processing has been canceled. Re
Pete Williamson 2016/06/23 17:54:53 Done.
Pete Williamson 2016/06/23 17:54:54 I thought that is_canceled would work better with
85 return is_canceled_;
86 }
87
84 private: 88 private:
85 void AddRequestResultCallback(RequestQueue::AddRequestResult result, 89 void AddRequestResultCallback(RequestQueue::AddRequestResult result,
86 const SavePageRequest& request); 90 const SavePageRequest& request);
87 91
88 void UpdateRequestCallback(RequestQueue::UpdateRequestResult result); 92 void UpdateRequestCallback(RequestQueue::UpdateRequestResult result);
89 93
90 // Callback from the request picker when it has chosen our next request. 94 // Callback from the request picker when it has chosen our next request.
91 void RequestPicked(const SavePageRequest& request); 95 void RequestPicked(const SavePageRequest& request);
92 96
93 // Callback from the request picker when no more requests are in the queue. 97 // Callback from the request picker when no more requests are in the queue.
94 void RequestQueueEmpty(); 98 void RequestQueueEmpty();
95 99
96 void SendRequestToOffliner(const SavePageRequest& request); 100 void SendRequestToOffliner(const SavePageRequest& request);
97 101
98 // Called by the offliner when an offlining request is completed. (and by 102 // Called by the offliner when an offlining request is completed. (and by
99 // tests). 103 // tests).
100 void OfflinerDoneCallback(const SavePageRequest& request, 104 void OfflinerDoneCallback(const SavePageRequest& request,
101 Offliner::RequestStatus status); 105 Offliner::RequestStatus status);
102 106
103 void TryNextRequest(); 107 void TryNextRequest();
104 108
109 void GetOffliner();
dougarnett 2016/06/23 17:19:17 // Returns the appropriate Offliner to use. ?
Pete Williamson 2016/06/23 17:54:53 The real purpose of this is not choosing the offli
110
105 friend class RequestCoordinatorTest; 111 friend class RequestCoordinatorTest;
106 112
107 // The offliner can only handle one request at a time - if the offliner is 113 // The offliner can only handle one request at a time - if the offliner is
108 // busy, prevent other requests. This flag marks whether the offliner is in 114 // busy, prevent other requests. This flag marks whether the offliner is in
109 // use. 115 // use.
110 bool is_busy_; 116 bool is_busy_;
117 // True if a prerender request has been canceled.
118 bool is_canceled_;
119 // Unowned pointer to the offliner, if any.
dougarnett 2016/06/23 17:19:17 to the current offliner ?
Pete Williamson 2016/06/23 17:54:53 Done.
120 Offliner* offliner_;
111 // RequestCoordinator takes over ownership of the policy 121 // RequestCoordinator takes over ownership of the policy
112 std::unique_ptr<OfflinerPolicy> policy_; 122 std::unique_ptr<OfflinerPolicy> policy_;
113 // OfflinerFactory. Used to create offline pages. Owned. 123 // OfflinerFactory. Used to create offline pages. Owned.
114 std::unique_ptr<OfflinerFactory> factory_; 124 std::unique_ptr<OfflinerFactory> factory_;
115 // RequestQueue. Used to store incoming requests. Owned. 125 // RequestQueue. Used to store incoming requests. Owned.
116 std::unique_ptr<RequestQueue> queue_; 126 std::unique_ptr<RequestQueue> queue_;
117 // Scheduler. Used to request a callback when network is available. Owned. 127 // Scheduler. Used to request a callback when network is available. Owned.
118 std::unique_ptr<Scheduler> scheduler_; 128 std::unique_ptr<Scheduler> scheduler_;
119 // Status of the most recent offlining. 129 // Status of the most recent offlining.
120 Offliner::RequestStatus last_offlining_status_; 130 Offliner::RequestStatus last_offlining_status_;
121 // Class to choose which request to schedule next 131 // Class to choose which request to schedule next
122 std::unique_ptr<RequestPicker> picker_; 132 std::unique_ptr<RequestPicker> picker_;
123 // Calling this returns to the scheduler across the JNI bridge. 133 // Calling this returns to the scheduler across the JNI bridge.
124 base::Callback<void(bool)> scheduler_callback_; 134 base::Callback<void(bool)> scheduler_callback_;
125 // Allows us to pass a weak pointer to callbacks. 135 // Allows us to pass a weak pointer to callbacks.
126 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 136 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
127 137
128 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 138 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
129 }; 139 };
130 140
131 } // namespace offline_pages 141 } // namespace offline_pages
132 142
133 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 143 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698