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

Unified Diff: components/offline_pages/background/request_coordinator.h

Issue 1922533003: Defines initial inner circle of interfaces for background offlining. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved Coordinator Stop/Start method comments and some other feedback addressed Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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..65568172b3ab79fbf6d04a2715995c9e02948c71
--- /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_
+
+namespace offline_pages {
+
+class SavePageRequest;
+
+// Coordinates queueing and processing save page later requests.
+class RequestCoordinator : public KeyedService {
+ public:
+ // Callback to report when the processing of a triggered task is complete.
+ typedef base::Callback<void()> ProcessingDoneCallback;
+
+ // TODO(dougarnett): How to inject Offliner factories and policy objects.
+ RequestCoordinator();
+
+ ~RequestCoordinator() {}
+
+ // Handles shutdown of KeyedService.
+ void Shutdown();
+
+ // Queues |request| to later load and save when system conditions allow.
+ bool SavePageLater(const SavePageRequest& request);
+
+ // Starts processing of one or more queued save page later requests.
+ // Returns whether processing was started and that caller should expect
+ // a callback. If processing was already active, returns false.
+ bool StartProcessing(const ProcessingDoneCallback& callback);
+
+ // Stops the current request processing if active. This is a way for
+ // caller to abort processing; otherwise, processing will complete on
+ // its own. In either case, the callback will be called when processing
+ // is stopped or complete.
+ void StopProcessing();
+
+ // TODO(dougarnett): add policy support methods.
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_

Powered by Google App Engine
This is Rietveld 408576698