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

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 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 <memory>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "components/keyed_service/core/keyed_service.h"
9 12
10 namespace offline_pages { 13 namespace offline_pages {
11 14
15 class OfflinerPolicy;
16 class OfflinerFactory;
17 class Offliner;
18 class SavePageRequest;
19
12 // Coordinates queueing and processing save page later requests. 20 // Coordinates queueing and processing save page later requests.
13 class RequestCoordinator { 21 class RequestCoordinator : public KeyedService {
14 public: 22 public:
15 // Callback to report when the processing of a triggered task is complete. 23 // Callback to report when the processing of a triggered task is complete.
16 typedef base::Callback<void()> ProcessingDoneCallback; 24 typedef base::Callback<void()> ProcessingDoneCallback;
17 25
18 struct SavePageRequest {
19 // TODO(dougarnett): define and consider making stand-alone.
20 };
21 26
22 // TODO(dougarnett): How to inject Offliner factories and policy objects. 27 RequestCoordinator(
23 RequestCoordinator(); 28 std::unique_ptr<OfflinerPolicy> policy,
fgorski 2016/05/04 21:38:25 did you run git cl format?
Pete Williamson 2016/05/04 21:54:59 Done. (though I thought this style was also allowe
29 std::unique_ptr<OfflinerFactory> factory);
24 30
25 ~RequestCoordinator(); 31 ~RequestCoordinator() override;
26 32
27 // Queues |request| to later load and save when system conditions allow. 33 // Queues |request| to later load and save when system conditions allow.
28 bool SavePageLater(const SavePageRequest& request); 34 bool SavePageLater(const SavePageRequest& request);
29 35
30 // Starts processing of one or more queued save page later requests. 36 // Starts processing of one or more queued save page later requests.
31 // Returns whether processing was started and that caller should expect 37 // Returns whether processing was started and that caller should expect
32 // a callback. If processing was already active, returns false. 38 // a callback. If processing was already active, returns false.
33 bool StartProcessing(const ProcessingDoneCallback& callback); 39 bool StartProcessing(const ProcessingDoneCallback& callback);
34 40
35 // Stops the current request processing if active. This is a way for 41 // Stops the current request processing if active. This is a way for
36 // caller to abort processing; otherwise, processing will complete on 42 // caller to abort processing; otherwise, processing will complete on
37 // its own. In either case, the callback will be called when processing 43 // its own. In either case, the callback will be called when processing
38 // is stopped or complete. 44 // is stopped or complete.
39 void StopProcessing(); 45 void StopProcessing();
40 46
41 // TODO(dougarnett): add policy support methods. 47 private:
48 // RequestCoordinator takes over ownership of the policy
49 std::unique_ptr<OfflinerPolicy> policy_;
50 // Factory is owned by the RequestCoordinator.
51 std::unique_ptr<OfflinerFactory> factory_;
52
53 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
fgorski 2016/05/04 21:38:25 nit: include "base/macros.h" explicitly
Pete Williamson 2016/05/04 21:54:59 Done.
42 }; 54 };
43 55
44 } // namespace offline_pages 56 } // namespace offline_pages
45 57
46 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 58 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/offliner_policy.h ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698