| 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_SNAPSHOT_CONTROLLER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Stops current session, no more Client::StartSnapshot calls will be | 76 // Stops current session, no more Client::StartSnapshot calls will be |
| 77 // invoked from the SnapshotController until current session is Reset(). | 77 // invoked from the SnapshotController until current session is Reset(). |
| 78 // Called by Client, for example when it encounters an error loading the page. | 78 // Called by Client, for example when it encounters an error loading the page. |
| 79 void Stop(); | 79 void Stop(); |
| 80 | 80 |
| 81 // The way for Client to report that previously started snapshot is | 81 // The way for Client to report that previously started snapshot is |
| 82 // now completed (so the next one can be started). | 82 // now completed (so the next one can be started). |
| 83 void PendingSnapshotCompleted(); | 83 void PendingSnapshotCompleted(); |
| 84 | 84 |
| 85 // Invoked from WebContentObserver::DocumentAvailableInMainFrame | 85 // Invoked from WebContentsObserver::DocumentLoadedInFrame when the frame |
| 86 // is the main frame. |
| 87 void DocumentLoadedInMainFrame(); |
| 88 |
| 89 // Invoked from WebContentsObserver::DidStopLoading. |
| 90 void DidStopLoading(); |
| 91 |
| 92 // Invoked from WebContentsObserver::DocumentAvailableInMainFrame. |
| 93 // Maps to DocumentLoadedInMainFrame for now. |
| 86 void DocumentAvailableInMainFrame(); | 94 void DocumentAvailableInMainFrame(); |
| 87 | 95 |
| 88 // Invoked from WebContentObserver::DocumentOnLoadCompletedInMainFrame | 96 // Invoked from WebContentsObserver::DocumentOnLoadCompletedInMainFrame. |
| 97 // Maps to DidStopLoading for now. |
| 89 void DocumentOnLoadCompletedInMainFrame(); | 98 void DocumentOnLoadCompletedInMainFrame(); |
| 90 | 99 |
| 91 int64_t GetDelayAfterDocumentAvailableForTest(); | 100 int64_t GetDelayAfterDocumentLoadedForTest(); |
| 92 int64_t GetDelayAfterDocumentOnLoadCompletedForTest(); | 101 int64_t GetDelayAfterLoadCompletedForTest(); |
| 93 | 102 |
| 94 PageQuality current_page_quality() const { return current_page_quality_; } | 103 PageQuality current_page_quality() const { return current_page_quality_; } |
| 95 | 104 |
| 96 private: | 105 private: |
| 97 void MaybeStartSnapshot(PageQuality updated_page_quality); | 106 void MaybeStartSnapshot(PageQuality updated_page_quality); |
| 98 void MaybeStartSnapshotThenStop(); | 107 void MaybeStartSnapshotThenStop(); |
| 99 | 108 |
| 100 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 109 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 101 // Client owns this class. | 110 // Client owns this class. |
| 102 SnapshotController::Client* client_; | 111 SnapshotController::Client* client_; |
| 103 SnapshotController::State state_; | 112 SnapshotController::State state_; |
| 104 int64_t delay_after_document_available_ms_; | 113 int64_t delay_after_document_loaded_ms_; |
| 105 int64_t delay_after_document_on_load_completed_ms_; | 114 int64_t delay_after_load_completed_ms_; |
| 106 | 115 |
| 107 // The expected quality of a snapshot taken at the moment this value is | 116 // The expected quality of a snapshot taken at the moment this value is |
| 108 // queried. | 117 // queried. |
| 109 PageQuality current_page_quality_ = PageQuality::POOR; | 118 PageQuality current_page_quality_ = PageQuality::POOR; |
| 110 | 119 |
| 111 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_; | 120 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_; |
| 112 | 121 |
| 113 DISALLOW_COPY_AND_ASSIGN(SnapshotController); | 122 DISALLOW_COPY_AND_ASSIGN(SnapshotController); |
| 114 }; | 123 }; |
| 115 | 124 |
| 116 } // namespace offline_pages | 125 } // namespace offline_pages |
| 117 | 126 |
| 118 #endif // COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_ | 127 #endif // COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_ |
| OLD | NEW |