| 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_CORE_BACKGROUND_OFFLINER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // background. | 63 // background. |
| 64 // * User swiped away the browser as it was offlining content. | 64 // * User swiped away the browser as it was offlining content. |
| 65 // * Offliner crashed. | 65 // * Offliner crashed. |
| 66 // We detect the situation in ReconcileTask after starting | 66 // We detect the situation in ReconcileTask after starting |
| 67 // RequestCoordinator. | 67 // RequestCoordinator. |
| 68 BROWSER_KILLED = 16, | 68 BROWSER_KILLED = 16, |
| 69 // NOTE: insert new values above this line and update histogram enum too. | 69 // NOTE: insert new values above this line and update histogram enum too. |
| 70 STATUS_COUNT | 70 STATUS_COUNT |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 enum ResourceDataType { |
| 74 APPLICATION, |
| 75 MEDIA, |
| 76 EXAMPLE, |
| 77 IMAGE, |
| 78 MESSAGE, |
| 79 MODEL, |
| 80 MULTIPART, |
| 81 TEXT_CSS, |
| 82 TEXT_HTML, |
| 83 TEXT_PLAIN, |
| 84 TEXT_SCRIPT, |
| 85 XHR, |
| 86 OTHER, |
| 87 RESOURCE_DATA_TYPE_COUNT, |
| 88 }; |
| 89 |
| 73 // Reports the load progress of a request. | 90 // Reports the load progress of a request. |
| 74 typedef base::Callback<void(const SavePageRequest&, int64_t received_bytes)> | 91 typedef base::Callback<void(const SavePageRequest&, int64_t received_bytes)> |
| 75 ProgressCallback; | 92 ProgressCallback; |
| 76 // Reports the completion status of a request. | 93 // Reports the completion status of a request. |
| 77 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> | 94 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> |
| 78 CompletionCallback; | 95 CompletionCallback; |
| 79 // Reports that the cancel operation has completed. | 96 // Reports that the cancel operation has completed. |
| 80 // TODO(chili): make save operation cancellable. | 97 // TODO(chili): make save operation cancellable. |
| 81 typedef base::Callback<void(const SavePageRequest&)> CancelCallback; | 98 typedef base::Callback<void(const SavePageRequest&)> CancelCallback; |
| 82 | 99 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 95 // Clears the currently processing request, if any, and skips running its | 112 // Clears the currently processing request, if any, and skips running its |
| 96 // CompletionCallback. Returns false if there is nothing to cancel, otherwise | 113 // CompletionCallback. Returns false if there is nothing to cancel, otherwise |
| 97 // returns true and canceled request will be delivered using callback. | 114 // returns true and canceled request will be delivered using callback. |
| 98 virtual bool Cancel(const CancelCallback& callback) = 0; | 115 virtual bool Cancel(const CancelCallback& callback) = 0; |
| 99 | 116 |
| 100 // Handles timeout scenario. Returns true if lowbar is met and try to do a | 117 // Handles timeout scenario. Returns true if lowbar is met and try to do a |
| 101 // snapshot of the current webcontents. If that is the case, the result of | 118 // snapshot of the current webcontents. If that is the case, the result of |
| 102 // offlining will be provided by |completion_callback|. | 119 // offlining will be provided by |completion_callback|. |
| 103 virtual bool HandleTimeout(int64_t request_id) = 0; | 120 virtual bool HandleTimeout(int64_t request_id) = 0; |
| 104 | 121 |
| 122 // We are notified of a resource load starting or ending, we can use this |
| 123 // for tracking loading signals. |
| 124 virtual void ObserveResourceTracking(const ResourceDataType type, |
| 125 int64_t started_count, |
| 126 int64_t completed_count) = 0; |
| 127 |
| 105 // TODO(dougarnett): add policy support methods. | 128 // TODO(dougarnett): add policy support methods. |
| 106 }; | 129 }; |
| 107 | 130 |
| 108 } // namespace offline_pages | 131 } // namespace offline_pages |
| 109 | 132 |
| 110 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ | 133 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ |
| OLD | NEW |