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

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

Issue 1929223002: Add skeletons for the factories to create the request coordinator and (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manual merge of changes in the base changelist. Created 4 years, 7 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 "base/callback.h"
9 #include "components/keyed_service/core/keyed_service.h"
10
8 namespace offline_pages { 11 namespace offline_pages {
9 12
13 class OfflinerPolicy;
14 class OfflinerFactory;
15 class Offliner;
16
10 // Coordinates queueing and processing save page later requests. 17 // Coordinates queueing and processing save page later requests.
11 class RequestCoordinator { 18 class RequestCoordinator : public KeyedService {
12 public: 19 public:
13 // Callback to report when the processing of a triggered task is complete. 20 // Callback to report when the processing of a triggered task is complete.
14 typedef base::Callback<void()> ProcessingDoneCallback; 21 typedef base::Callback<void()> ProcessingDoneCallback;
15 22
16 struct SavePageRequest { 23 struct SavePageRequest {
17 // TODO(dougarnett): define and consider making stand-alone. 24 // TODO(dougarnett): define and consider making stand-alone.
18 }; 25 };
19 26
20 // TODO(dougarnett): How to inject Offliner factories and policy objects. 27 RequestCoordinator(
21 RequestCoordinator(); 28 OfflinerPolicy* policy, OfflinerFactory* factory);
fgorski 2016/04/29 04:16:46 a) what about multiple factories for different off
Pete Williamson 2016/05/02 20:51:14 For now we only have one factory. I have a TODO e
22 29
23 ~RequestCoordinator() {} 30 ~RequestCoordinator() override;
24 31
25 // Queues |request| to later load and save when system conditions allow. 32 // Queues |request| to later load and save when system conditions allow.
26 bool SavePageLater(const SavePageRequest& request); 33 bool SavePageLater(const SavePageRequest& request);
27 34
28 // Starts processing of one or more queued save page later requests. 35 // Starts processing of one or more queued save page later requests.
29 // Returns whether processing was started and that caller should expect 36 // Returns whether processing was started and that caller should expect
30 // a callback. If processing was already active, returns false. 37 // a callback. If processing was already active, returns false.
31 bool StartProcessing(const ProcessingDoneCallback& callback); 38 bool StartProcessing(const ProcessingDoneCallback& callback);
32 39
33 // Stops the current request processing if active. This is a way for 40 // Stops the current request processing if active. This is a way for
34 // caller to abort processing; otherwise, processing will complete on 41 // caller to abort processing; otherwise, processing will complete on
35 // its own. In either case, the callback will be called when processing 42 // its own. In either case, the callback will be called when processing
36 // is stopped or complete. 43 // is stopped or complete.
37 void StopProcessing(); 44 void StopProcessing();
38 45
39 // TODO(dougarnett): add policy support methods. 46 // Factory has permission to call our private constructor.
47 friend class RequestCoordinatorFactory;
48
49 private:
50 OfflinerPolicy* policy_;
51 OfflinerFactory* factory_;
52 // Offliner* offlinerArray_;
53 int factoryArraySize_;
40 }; 54 };
41 55
42 } // namespace offline_pages 56 } // namespace offline_pages
43 57
44 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 58 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698