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

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: cleanup 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" 8 #include "base/callback.h"
9 #include "components/keyed_service/core/keyed_service.h"
9 10
10 namespace offline_pages { 11 namespace offline_pages {
11 12
13 class OfflinerPolicy;
14 class OfflinerFactory;
15 class Offliner;
16
12 // Coordinates queueing and processing save page later requests. 17 // Coordinates queueing and processing save page later requests.
13 class RequestCoordinator { 18 class RequestCoordinator : public KeyedService {
14 public: 19 public:
15 // 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.
16 typedef base::Callback<void()> ProcessingDoneCallback; 21 typedef base::Callback<void()> ProcessingDoneCallback;
17 22
18 struct SavePageRequest { 23 struct SavePageRequest {
fgorski 2016/05/03 22:48:17 remove this.
Pete Williamson 2016/05/04 00:39:22 Done.
19 // TODO(dougarnett): define and consider making stand-alone. 24 // TODO(dougarnett): define and consider making stand-alone.
20 }; 25 };
21 26
22 // TODO(dougarnett): How to inject Offliner factories and policy objects. 27 ~RequestCoordinator() override;
23 RequestCoordinator();
24
25 ~RequestCoordinator();
26 28
27 // Queues |request| to later load and save when system conditions allow. 29 // Queues |request| to later load and save when system conditions allow.
28 bool SavePageLater(const SavePageRequest& request); 30 bool SavePageLater(const SavePageRequest& request);
29 31
30 // Starts processing of one or more queued save page later requests. 32 // Starts processing of one or more queued save page later requests.
31 // Returns whether processing was started and that caller should expect 33 // Returns whether processing was started and that caller should expect
32 // a callback. If processing was already active, returns false. 34 // a callback. If processing was already active, returns false.
33 bool StartProcessing(const ProcessingDoneCallback& callback); 35 bool StartProcessing(const ProcessingDoneCallback& callback);
34 36
35 // Stops the current request processing if active. This is a way for 37 // Stops the current request processing if active. This is a way for
36 // caller to abort processing; otherwise, processing will complete on 38 // caller to abort processing; otherwise, processing will complete on
37 // its own. In either case, the callback will be called when processing 39 // its own. In either case, the callback will be called when processing
38 // is stopped or complete. 40 // is stopped or complete.
39 void StopProcessing(); 41 void StopProcessing();
40 42
41 // TODO(dougarnett): add policy support methods. 43 // Factory has permission to call our private constructor.
44 friend class RequestCoordinatorFactory;
fgorski 2016/05/03 22:48:16 I don't think you need this. Constructor can be pu
Pete Williamson 2016/05/04 00:39:22 Removed. I'm happy without it, but I thought I re
45
46 private:
47 RequestCoordinator(
48 OfflinerPolicy* policy, OfflinerFactory* factory);
49
50 OfflinerPolicy* policy_;
fgorski 2016/05/03 22:48:16 this should be a unique_ptr.
Pete Williamson 2016/05/04 00:39:21 Can I use a unique ptr if I am going to pass a poi
fgorski 2016/05/04 05:20:57 Here is how I see this: 1. RC owns the policy (uni
Pete Williamson 2016/05/04 21:23:21 Done.
51 OfflinerFactory* factory_;
fgorski 2016/05/03 22:48:17 who controls the life of a factory?
Pete Williamson 2016/05/04 00:39:22 The request coordinator should control the lifetim
fgorski 2016/05/04 05:20:57 unique_ptr then? per response above.
Pete Williamson 2016/05/04 21:23:21 Done.
52 int factoryArraySize_;
fgorski 2016/05/03 22:48:17 ?
Pete Williamson 2016/05/04 00:39:22 Oops, leftover. Removed.
42 }; 53 };
43 54
44 } // namespace offline_pages 55 } // namespace offline_pages
45 56
46 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 57 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698