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

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

Issue 2066593003: Add a general purpose facility for letting background tasks wait until (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 29 matching lines...) Expand all
40 40
41 ~RequestCoordinator() override; 41 ~RequestCoordinator() override;
42 42
43 // Queues |request| to later load and save when system conditions allow. 43 // Queues |request| to later load and save when system conditions allow.
44 // Returns true if the page could be queued successfully. 44 // Returns true if the page could be queued successfully.
45 bool SavePageLater(const GURL& url, const ClientId& client_id); 45 bool SavePageLater(const GURL& url, const ClientId& client_id);
46 46
47 // Starts processing of one or more queued save page later requests. 47 // Starts processing of one or more queued save page later requests.
48 // Returns whether processing was started and that caller should expect 48 // Returns whether processing was started and that caller should expect
49 // a callback. If processing was already active, returns false. 49 // a callback. If processing was already active, returns false.
50 bool StartProcessing(const base::Callback<void(bool)>& callback); 50 bool StartProcessing(const base::Callback<void(bool)> callback);
51 51
52 // Stops the current request processing if active. This is a way for 52 // Stops the current request processing if active. This is a way for
53 // caller to abort processing; otherwise, processing will complete on 53 // caller to abort processing; otherwise, processing will complete on
54 // its own. In either case, the callback will be called when processing 54 // its own. In either case, the callback will be called when processing
55 // is stopped or complete. 55 // is stopped or complete.
56 void StopProcessing(); 56 void StopProcessing();
57 57
58 // Returns the request queue used for requests. Coordinator keeps ownership. 58 // Returns the request queue used for requests. Coordinator keeps ownership.
59 RequestQueue* queue() { return queue_.get(); } 59 RequestQueue* queue() { return queue_.get(); }
60 60
(...skipping 25 matching lines...) Expand all
86 // OfflinerFactory. Used to create offline pages. Owned. 86 // OfflinerFactory. Used to create offline pages. Owned.
87 std::unique_ptr<OfflinerFactory> factory_; 87 std::unique_ptr<OfflinerFactory> factory_;
88 // RequestQueue. Used to store incoming requests. Owned. 88 // RequestQueue. Used to store incoming requests. Owned.
89 std::unique_ptr<RequestQueue> queue_; 89 std::unique_ptr<RequestQueue> queue_;
90 // Scheduler. Used to request a callback when network is available. Owned. 90 // Scheduler. Used to request a callback when network is available. Owned.
91 std::unique_ptr<Scheduler> scheduler_; 91 std::unique_ptr<Scheduler> scheduler_;
92 // Status of the most recent offlining. 92 // Status of the most recent offlining.
93 Offliner::RequestStatus last_offlining_status_; 93 Offliner::RequestStatus last_offlining_status_;
94 // Class to choose which request to schedule next 94 // Class to choose which request to schedule next
95 std::unique_ptr<RequestPicker> picker_; 95 std::unique_ptr<RequestPicker> picker_;
96 // Calling this returns to the scheduler across the JNI bridge.
97 base::Callback<void(bool)> scheduler_callback_;
96 // Allows us to pass a weak pointer to callbacks. 98 // Allows us to pass a weak pointer to callbacks.
97 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 99 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
98 100
99 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 101 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
100 }; 102 };
101 103
102 } // namespace offline_pages 104 } // namespace offline_pages
103 105
104 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 106 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698