| 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 #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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 void SendRequestToOffliner(const SavePageRequest& request); | 88 void SendRequestToOffliner(const SavePageRequest& request); |
| 89 | 89 |
| 90 // Called by the offliner when an offlining request is completed. (and by | 90 // Called by the offliner when an offlining request is completed. (and by |
| 91 // tests). | 91 // tests). |
| 92 void OfflinerDoneCallback(const SavePageRequest& request, | 92 void OfflinerDoneCallback(const SavePageRequest& request, |
| 93 Offliner::RequestStatus status); | 93 Offliner::RequestStatus status); |
| 94 | 94 |
| 95 void TryNextRequest(); | 95 void TryNextRequest(); |
| 96 | 96 |
| 97 void GetOffliner(); |
| 98 |
| 97 friend class RequestCoordinatorTest; | 99 friend class RequestCoordinatorTest; |
| 98 | 100 |
| 101 // Unowned pointer to the offliner, if any. |
| 102 Offliner* offliner_; |
| 103 // True if a prerender has been started. |
| 104 bool started_; |
| 105 // True if a prerender request has been cancelled. |
| 106 bool cancelled_; |
| 99 // RequestCoordinator takes over ownership of the policy | 107 // RequestCoordinator takes over ownership of the policy |
| 100 std::unique_ptr<OfflinerPolicy> policy_; | 108 std::unique_ptr<OfflinerPolicy> policy_; |
| 101 // OfflinerFactory. Used to create offline pages. Owned. | 109 // OfflinerFactory. Used to create offline pages. Owned. |
| 102 std::unique_ptr<OfflinerFactory> factory_; | 110 std::unique_ptr<OfflinerFactory> factory_; |
| 103 // RequestQueue. Used to store incoming requests. Owned. | 111 // RequestQueue. Used to store incoming requests. Owned. |
| 104 std::unique_ptr<RequestQueue> queue_; | 112 std::unique_ptr<RequestQueue> queue_; |
| 105 // Scheduler. Used to request a callback when network is available. Owned. | 113 // Scheduler. Used to request a callback when network is available. Owned. |
| 106 std::unique_ptr<Scheduler> scheduler_; | 114 std::unique_ptr<Scheduler> scheduler_; |
| 107 // Status of the most recent offlining. | 115 // Status of the most recent offlining. |
| 108 Offliner::RequestStatus last_offlining_status_; | 116 Offliner::RequestStatus last_offlining_status_; |
| 109 // Class to choose which request to schedule next | 117 // Class to choose which request to schedule next |
| 110 std::unique_ptr<RequestPicker> picker_; | 118 std::unique_ptr<RequestPicker> picker_; |
| 111 // Calling this returns to the scheduler across the JNI bridge. | 119 // Calling this returns to the scheduler across the JNI bridge. |
| 112 base::Callback<void(bool)> scheduler_callback_; | 120 base::Callback<void(bool)> scheduler_callback_; |
| 113 // Allows us to pass a weak pointer to callbacks. | 121 // Allows us to pass a weak pointer to callbacks. |
| 114 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 122 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
| 115 | 123 |
| 116 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 124 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
| 117 }; | 125 }; |
| 118 | 126 |
| 119 } // namespace offline_pages | 127 } // namespace offline_pages |
| 120 | 128 |
| 121 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 129 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| OLD | NEW |