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

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: CR fixes per DougArnett and FGorski 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"
10 #include "components/offline_pages/background/save_page_request.h"
fgorski 2016/05/04 05:20:58 I think you can forward declare this one.
Pete Williamson 2016/05/04 21:23:21 Done.
9 11
10 namespace offline_pages { 12 namespace offline_pages {
11 13
14 class OfflinerPolicy;
15 class OfflinerFactory;
16 class Offliner;
17
12 // Coordinates queueing and processing save page later requests. 18 // Coordinates queueing and processing save page later requests.
13 class RequestCoordinator { 19 class RequestCoordinator : public KeyedService {
fgorski 2016/05/04 05:20:58 Did you consider adding DISALLOW... at the end?
Pete Williamson 2016/05/04 21:23:21 Done.
14 public: 20 public:
15 // Callback to report when the processing of a triggered task is complete. 21 // Callback to report when the processing of a triggered task is complete.
16 typedef base::Callback<void()> ProcessingDoneCallback; 22 typedef base::Callback<void()> ProcessingDoneCallback;
17 23
18 struct SavePageRequest {
19 // TODO(dougarnett): define and consider making stand-alone.
20 };
21 24
22 // TODO(dougarnett): How to inject Offliner factories and policy objects. 25 RequestCoordinator(
23 RequestCoordinator(); 26 OfflinerPolicy* policy, OfflinerFactory* factory);
fgorski 2016/05/04 05:20:58 To clearly communicate ownership you should probab
Pete Williamson 2016/05/04 21:23:21 Done.
24 27
25 ~RequestCoordinator(); 28 ~RequestCoordinator() override;
26 29
27 // Queues |request| to later load and save when system conditions allow. 30 // Queues |request| to later load and save when system conditions allow.
28 bool SavePageLater(const SavePageRequest& request); 31 bool SavePageLater(const SavePageRequest& request);
29 32
30 // Starts processing of one or more queued save page later requests. 33 // Starts processing of one or more queued save page later requests.
31 // Returns whether processing was started and that caller should expect 34 // Returns whether processing was started and that caller should expect
32 // a callback. If processing was already active, returns false. 35 // a callback. If processing was already active, returns false.
33 bool StartProcessing(const ProcessingDoneCallback& callback); 36 bool StartProcessing(const ProcessingDoneCallback& callback);
34 37
35 // Stops the current request processing if active. This is a way for 38 // Stops the current request processing if active. This is a way for
36 // caller to abort processing; otherwise, processing will complete on 39 // caller to abort processing; otherwise, processing will complete on
37 // its own. In either case, the callback will be called when processing 40 // its own. In either case, the callback will be called when processing
38 // is stopped or complete. 41 // is stopped or complete.
39 void StopProcessing(); 42 void StopProcessing();
40 43
41 // TODO(dougarnett): add policy support methods. 44 private:
45 OfflinerPolicy* policy_;
46 // Factory ownership is taken over here.
47 OfflinerFactory* factory_;
42 }; 48 };
43 49
44 } // namespace offline_pages 50 } // namespace offline_pages
45 51
46 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 52 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698