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

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

Issue 2064323004: Defines initial DeviceConditions and and plumbs down through StartProcessing() call. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 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/offliner.h" 15 #include "components/offline_pages/background/offliner.h"
15 #include "components/offline_pages/background/request_queue.h" 16 #include "components/offline_pages/background/request_queue.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace offline_pages { 19 namespace offline_pages {
19 20
20 struct ClientId; 21 struct ClientId;
21 class OfflinerPolicy; 22 class OfflinerPolicy;
22 class OfflinerFactory; 23 class OfflinerFactory;
23 class Offliner; 24 class Offliner;
(...skipping 16 matching lines...) Expand all
40 41
41 ~RequestCoordinator() override; 42 ~RequestCoordinator() override;
42 43
43 // Queues |request| to later load and save when system conditions allow. 44 // Queues |request| to later load and save when system conditions allow.
44 // Returns true if the page could be queued successfully. 45 // Returns true if the page could be queued successfully.
45 bool SavePageLater(const GURL& url, const ClientId& client_id); 46 bool SavePageLater(const GURL& url, const ClientId& client_id);
46 47
47 // Starts processing of one or more queued save page later requests. 48 // Starts processing of one or more queued save page later requests.
48 // Returns whether processing was started and that caller should expect 49 // Returns whether processing was started and that caller should expect
49 // a callback. If processing was already active, returns false. 50 // a callback. If processing was already active, returns false.
50 bool StartProcessing(const base::Callback<void(bool)>& callback); 51 bool StartProcessing(const DeviceConditions& device_conditions,
52 const base::Callback<void(bool)>& callback);
51 53
52 // Stops the current request processing if active. This is a way for 54 // Stops the current request processing if active. This is a way for
53 // caller to abort processing; otherwise, processing will complete on 55 // caller to abort processing; otherwise, processing will complete on
54 // its own. In either case, the callback will be called when processing 56 // its own. In either case, the callback will be called when processing
55 // is stopped or complete. 57 // is stopped or complete.
56 void StopProcessing(); 58 void StopProcessing();
57 59
58 // A way for tests to set the callback in use when an operation is over. 60 // A way for tests to set the callback in use when an operation is over.
59 void SetProcessingCallbackForTest(const base::Callback<void(bool)> callback) { 61 void SetProcessingCallbackForTest(const base::Callback<void(bool)> callback) {
60 scheduler_callback_ = callback; 62 scheduler_callback_ = callback;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 base::Callback<void(bool)> scheduler_callback_; 112 base::Callback<void(bool)> scheduler_callback_;
111 // Allows us to pass a weak pointer to callbacks. 113 // Allows us to pass a weak pointer to callbacks.
112 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 114 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
113 115
114 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 116 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
115 }; 117 };
116 118
117 } // namespace offline_pages 119 } // namespace offline_pages
118 120
119 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 121 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/device_conditions.h ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698