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

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

Issue 1950733002: Add unit test for request coordiator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/offline_pages/background/save_page_request.h"
fgorski 2016/05/03 22:55:49 forward declare instead and add the .h file in .cc
Pete Williamson 2016/05/04 17:29:27 Done.
9 10
10 namespace offline_pages { 11 namespace offline_pages {
11 12
12 // Coordinates queueing and processing save page later requests. 13 // Coordinates queueing and processing save page later requests.
13 class RequestCoordinator { 14 class RequestCoordinator {
14 public: 15 public:
15 // Callback to report when the processing of a triggered task is complete. 16 // Callback to report when the processing of a triggered task is complete.
16 typedef base::Callback<void()> ProcessingDoneCallback; 17 typedef base::Callback<void()> ProcessingDoneCallback;
17 18
18 struct SavePageRequest {
19 // TODO(dougarnett): define and consider making stand-alone.
20 };
21
22 // TODO(dougarnett): How to inject Offliner factories and policy objects. 19 // TODO(dougarnett): How to inject Offliner factories and policy objects.
23 RequestCoordinator(); 20 RequestCoordinator();
24 21
25 ~RequestCoordinator(); 22 ~RequestCoordinator();
26 23
27 // Queues |request| to later load and save when system conditions allow. 24 // Queues |request| to later load and save when system conditions allow.
dougarnett 2016/05/03 22:42:06 guess we should comment return value
Pete Williamson 2016/05/03 22:51:47 Done.
28 bool SavePageLater(const SavePageRequest& request); 25 bool SavePageLater(const SavePageRequest& request);
29 26
30 // Starts processing of one or more queued save page later requests. 27 // Starts processing of one or more queued save page later requests.
31 // Returns whether processing was started and that caller should expect 28 // Returns whether processing was started and that caller should expect
32 // a callback. If processing was already active, returns false. 29 // a callback. If processing was already active, returns false.
33 bool StartProcessing(const ProcessingDoneCallback& callback); 30 bool StartProcessing(const ProcessingDoneCallback& callback);
34 31
35 // Stops the current request processing if active. This is a way for 32 // Stops the current request processing if active. This is a way for
36 // caller to abort processing; otherwise, processing will complete on 33 // caller to abort processing; otherwise, processing will complete on
37 // its own. In either case, the callback will be called when processing 34 // its own. In either case, the callback will be called when processing
38 // is stopped or complete. 35 // is stopped or complete.
39 void StopProcessing(); 36 void StopProcessing();
40 37
41 // TODO(dougarnett): add policy support methods. 38 // TODO(dougarnett): add policy support methods.
42 }; 39 };
43 40
44 } // namespace offline_pages 41 } // namespace offline_pages
45 42
46 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 43 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698