OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 |
| 10 namespace offline_pages { |
| 11 |
| 12 class SavePageRequest; |
| 13 |
| 14 // Interface of a class responsible for constructing an offline page given |
| 15 // a request with a URL. |
| 16 class Offliner { |
| 17 public: |
| 18 // Completion status of processing an offline page request. |
| 19 enum CompletionStatus { |
| 20 SAVED = 0, |
| 21 CANCELED = 1, |
| 22 FAILED_CONSIDER_RETRY = 2, |
| 23 FAILED_DO_NOT_RETRY = 3, |
| 24 }; |
| 25 |
| 26 // Reports the completion status of a request. |
| 27 // TODO(dougarnett): consider passing back a request id instead of request. |
| 28 typedef base::Callback<void(const SavePageRequest& request, CompletionStatus)> |
| 29 CompletionCallback; |
| 30 |
| 31 Offliner() {} |
| 32 virtual ~Offliner() {} |
| 33 |
| 34 // Processes |request| to load and save an offline page. |
| 35 // Returns whether the request was accepted or not. |
| 36 virtual bool LoadAndSave( |
| 37 const SavePageRequest& request, |
| 38 const CompletionCallback& callback) = 0; |
| 39 |
| 40 // Clears the currently processing request, if any. |
| 41 virtual void Cancel() = 0; |
| 42 |
| 43 // TODO(dougarnett): add policy support methods. |
| 44 }; |
| 45 |
| 46 } // namespace offline_pages |
| 47 |
| 48 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ |
OLD | NEW |