Index: components/offline_pages/background_request_coordinator.h |
diff --git a/components/offline_pages/background_request_coordinator.h b/components/offline_pages/background_request_coordinator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..292ce5ebf096fe9543562c0af07a10ef5abf7e96 |
--- /dev/null |
+++ b/components/offline_pages/background_request_coordinator.h |
@@ -0,0 +1,45 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
+#define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
+ |
+#include <stdint.h> |
fgorski
2016/04/25 21:07:37
nit: do you need this?
dougarnett
2016/04/25 21:49:08
Done.
|
+ |
+namespace offline_pages { |
+ |
+class SavePageRequest; |
+ |
+// Coordinates queueing and processing save page later requests. |
+class BackgroundRequestCoordinator { |
Pete Williamson
2016/04/25 20:12:16
"BackgroundRequestCoordinator" is a long name. Wh
fgorski
2016/04/25 21:07:38
Both ideas seem fine.
c/o/background ??
dougarnett
2016/04/25 21:54:13
Yes, like the subdirectory idea
dougarnett
2016/04/25 23:23:39
Ok, I have move these files to a background subdir
|
+ public: |
+ // Completion status of processing an offline page request. |
Pete Williamson
2016/04/25 20:12:16
We probably want completion status in only one hea
dougarnett
2016/04/25 21:49:08
woops - thanks
|
+ enum CompletionStatus { |
+ SAVED = 0, |
+ CANCELED = 1, |
+ TIMEOUT = 2, |
+ FAILED_CONSIDER_RETRY = 3, |
+ FAILED_DO_NOT_RETRY = 4, |
+ }; |
+ |
+ // Callback to report when the processing of a triggered task is complete. |
+ typedef base::Callback<void()> ProcessingDoneCallback; |
Pete Williamson
2016/04/25 20:12:16
The processing done callback should have a paramet
fgorski
2016/04/25 21:07:38
And should pass completion status...
dougarnett
2016/04/25 21:49:08
Am thinking this is single callback for however mu
dougarnett
2016/04/25 21:54:13
Although returning a saved page count or such coul
Pete Williamson
2016/04/25 21:59:57
I guess I'm thinking about two different callbacks
Pete Williamson
2016/04/25 22:18:31
I agree that the callback should be defined in the
Pete Williamson
2016/04/25 23:13:09
Oops, looks like we were not in agreement after al
|
+ |
+ virtual ~BackgroundRequestCoordinator() {} |
Pete Williamson
2016/04/25 20:12:16
We should add a constructor, too. That brings up
fgorski
2016/04/25 21:07:38
I think we mentioned this will be a KeyedService.
dougarnett
2016/04/25 21:49:08
And also discussed prospect of injecting factories
|
+ |
+ // Queues |request| to later load and save when system conditions allow. |
+ virtual bool SavePageLater(const SavePageRequest& request) = 0; |
+ |
+ // Starts processing of one or more queued save page later requests. |
+ virtual void StartProcessing(const ProcessingDoneCallback& callback) = 0; |
+ |
+ // Stops the current request processing if active. |
+ virtual void StopProcessing() = 0; |
+ |
+ // TODO(dougarnett): add policy support methods. |
+}; |
+ |
+} // namespace offline_pages |
+ |
+#endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |