Chromium Code Reviews| 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 "base/callback.h" | 8 #include "base/callback.h" |
| 9 | 9 |
| 10 namespace offline_pages { | 10 namespace offline_pages { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 enum RequestStatus { | 21 enum RequestStatus { |
| 22 UNKNOWN = 0, // No status determined/reported yet. Interim status, not sent | 22 UNKNOWN = 0, // No status determined/reported yet. Interim status, not sent |
| 23 // in callback. | 23 // in callback. |
| 24 LOADED = 1, // Page loaded but not (yet) saved. Interim status, not sent in | 24 LOADED = 1, // Page loaded but not (yet) saved. Interim status, not sent in |
| 25 // callback. | 25 // callback. |
| 26 SAVED = 2, // Offline page snapshot saved. | 26 SAVED = 2, // Offline page snapshot saved. |
| 27 REQUEST_COORDINATOR_CANCELED = 3, // RequestCoordinator canceled request. | 27 REQUEST_COORDINATOR_CANCELED = 3, // RequestCoordinator canceled request. |
| 28 PRERENDERING_CANCELED = 4, // Prerendering was canceled. | 28 PRERENDERING_CANCELED = 4, // Prerendering was canceled. |
| 29 PRERENDERING_FAILED = 5, // Prerendering failed to load page. | 29 PRERENDERING_FAILED = 5, // Prerendering failed to load page. |
| 30 SAVE_FAILED = 6, // Failed to save loaded page. | 30 SAVE_FAILED = 6, // Failed to save loaded page. |
| 31 FOREGROUND_CANCELED = 7, // Foreground transition canceled request. | |
|
fgorski
2016/07/14 17:01:45
nit: Please align all of the comments.
dougarnett
2016/07/15 16:00:25
Unfortunately, this is what 'git cl format' gave m
| |
| 31 // NOTE: insert new values above this line and update histogram enum too. | 32 // NOTE: insert new values above this line and update histogram enum too. |
| 32 STATUS_COUNT | 33 STATUS_COUNT |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 // Reports the completion status of a request. | 36 // Reports the completion status of a request. |
| 36 // TODO(dougarnett): consider passing back a request id instead of request. | 37 // TODO(dougarnett): consider passing back a request id instead of request. |
| 37 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> | 38 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> |
| 38 CompletionCallback; | 39 CompletionCallback; |
| 39 | 40 |
| 40 Offliner() {} | 41 Offliner() {} |
| 41 virtual ~Offliner() {} | 42 virtual ~Offliner() {} |
| 42 | 43 |
| 43 // Processes |request| to load and save an offline page. | 44 // Processes |request| to load and save an offline page. |
| 44 // Returns whether the request was accepted or not. |callback| is guaranteed | 45 // Returns whether the request was accepted or not. |callback| is guaranteed |
| 45 // to be called if the request was accepted and |Cancel()| is not called. | 46 // to be called if the request was accepted and |Cancel()| is not called. |
| 46 virtual bool LoadAndSave( | 47 virtual bool LoadAndSave( |
| 47 const SavePageRequest& request, | 48 const SavePageRequest& request, |
| 48 const CompletionCallback& callback) = 0; | 49 const CompletionCallback& callback) = 0; |
| 49 | 50 |
| 50 // Clears the currently processing request, if any, and skips running its | 51 // Clears the currently processing request, if any, and skips running its |
| 51 // CompletionCallback. | 52 // CompletionCallback. |
| 52 virtual void Cancel() = 0; | 53 virtual void Cancel() = 0; |
| 53 | 54 |
| 54 // TODO(dougarnett): add policy support methods. | 55 // TODO(dougarnett): add policy support methods. |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 } // namespace offline_pages | 58 } // namespace offline_pages |
| 58 | 59 |
| 59 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ | 60 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ |
| OLD | NEW |