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

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

Issue 2087633002: Defines TriggerConditions and plumbs up to BackgroundScheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Exposed TriggerConditions object for test 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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/offline_pages/background/device_conditions.h" 14 #include "components/offline_pages/background/device_conditions.h"
15 #include "components/offline_pages/background/offliner.h" 15 #include "components/offline_pages/background/offliner.h"
16 #include "components/offline_pages/background/request_queue.h" 16 #include "components/offline_pages/background/request_queue.h"
17 #include "components/offline_pages/background/scheduler.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 namespace offline_pages { 20 namespace offline_pages {
20 21
21 struct ClientId; 22 struct ClientId;
22 class OfflinerPolicy; 23 class OfflinerPolicy;
23 class OfflinerFactory; 24 class OfflinerFactory;
24 class Offliner; 25 class Offliner;
25 class RequestPicker; 26 class RequestPicker;
26 class SavePageRequest; 27 class SavePageRequest;
(...skipping 23 matching lines...) Expand all
50 // a callback. If processing was already active, returns false. 51 // a callback. If processing was already active, returns false.
51 bool StartProcessing(const DeviceConditions& device_conditions, 52 bool StartProcessing(const DeviceConditions& device_conditions,
52 const base::Callback<void(bool)>& callback); 53 const base::Callback<void(bool)>& callback);
53 54
54 // Stops the current request processing if active. This is a way for 55 // Stops the current request processing if active. This is a way for
55 // caller to abort processing; otherwise, processing will complete on 56 // caller to abort processing; otherwise, processing will complete on
56 // its own. In either case, the callback will be called when processing 57 // its own. In either case, the callback will be called when processing
57 // is stopped or complete. 58 // is stopped or complete.
58 void StopProcessing(); 59 void StopProcessing();
59 60
61 // TODO(dougarnett): Move to OfflinerPolicy in some form.
62 Scheduler::TriggerConditions const& GetTriggerConditionsForUserRequest();
63
60 // A way for tests to set the callback in use when an operation is over. 64 // A way for tests to set the callback in use when an operation is over.
61 void SetProcessingCallbackForTest(const base::Callback<void(bool)> callback) { 65 void SetProcessingCallbackForTest(const base::Callback<void(bool)> callback) {
62 scheduler_callback_ = callback; 66 scheduler_callback_ = callback;
63 } 67 }
64 68
65 // Returns the request queue used for requests. Coordinator keeps ownership. 69 // Returns the request queue used for requests. Coordinator keeps ownership.
66 RequestQueue* queue() { return queue_.get(); } 70 RequestQueue* queue() { return queue_.get(); }
67 71
68 // Return an unowned pointer to the Scheduler. 72 // Return an unowned pointer to the Scheduler.
69 Scheduler* scheduler() { return scheduler_.get(); } 73 Scheduler* scheduler() { return scheduler_.get(); }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 base::Callback<void(bool)> scheduler_callback_; 116 base::Callback<void(bool)> scheduler_callback_;
113 // Allows us to pass a weak pointer to callbacks. 117 // Allows us to pass a weak pointer to callbacks.
114 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 118 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
115 119
116 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 120 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
117 }; 121 };
118 122
119 } // namespace offline_pages 123 } // namespace offline_pages
120 124
121 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 125 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698