| OLD | NEW |
| 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_OFFLINER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // RequestCoordinator canceled request. | 31 // RequestCoordinator canceled request. |
| 32 REQUEST_COORDINATOR_CANCELED = 3, | 32 REQUEST_COORDINATOR_CANCELED = 3, |
| 33 // Prerendering was canceled. | 33 // Prerendering was canceled. |
| 34 PRERENDERING_CANCELED = 4, | 34 PRERENDERING_CANCELED = 4, |
| 35 // Prerendering failed to load page. | 35 // Prerendering failed to load page. |
| 36 PRERENDERING_FAILED = 5, | 36 PRERENDERING_FAILED = 5, |
| 37 // Failed to save loaded page. | 37 // Failed to save loaded page. |
| 38 SAVE_FAILED = 6, | 38 SAVE_FAILED = 6, |
| 39 // Foreground transition canceled request. | 39 // Foreground transition canceled request. |
| 40 FOREGROUND_CANCELED = 7, | 40 FOREGROUND_CANCELED = 7, |
| 41 // RequestCoordinator canceled request attempt per time limit. |
| 42 REQUEST_COORDINATOR_TIMED_OUT = 8, |
| 41 // NOTE: insert new values above this line and update histogram enum too. | 43 // NOTE: insert new values above this line and update histogram enum too. |
| 42 STATUS_COUNT | 44 STATUS_COUNT |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 // Reports the completion status of a request. | 47 // Reports the completion status of a request. |
| 46 // TODO(dougarnett): consider passing back a request id instead of request. | 48 // TODO(dougarnett): consider passing back a request id instead of request. |
| 47 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> | 49 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> |
| 48 CompletionCallback; | 50 CompletionCallback; |
| 49 | 51 |
| 50 Offliner() {} | 52 Offliner() {} |
| 51 virtual ~Offliner() {} | 53 virtual ~Offliner() {} |
| 52 | 54 |
| 53 // Processes |request| to load and save an offline page. | 55 // Processes |request| to load and save an offline page. |
| 54 // Returns whether the request was accepted or not. |callback| is guaranteed | 56 // Returns whether the request was accepted or not. |callback| is guaranteed |
| 55 // to be called if the request was accepted and |Cancel()| is not called. | 57 // to be called if the request was accepted and |Cancel()| is not called. |
| 56 virtual bool LoadAndSave( | 58 virtual bool LoadAndSave( |
| 57 const SavePageRequest& request, | 59 const SavePageRequest& request, |
| 58 const CompletionCallback& callback) = 0; | 60 const CompletionCallback& callback) = 0; |
| 59 | 61 |
| 60 // Clears the currently processing request, if any, and skips running its | 62 // Clears the currently processing request, if any, and skips running its |
| 61 // CompletionCallback. | 63 // CompletionCallback. |
| 62 virtual void Cancel() = 0; | 64 virtual void Cancel() = 0; |
| 63 | 65 |
| 64 // TODO(dougarnett): add policy support methods. | 66 // TODO(dougarnett): add policy support methods. |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 } // namespace offline_pages | 69 } // namespace offline_pages |
| 68 | 70 |
| 69 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ | 71 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ |
| OLD | NEW |