Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1254)

Unified Diff: chrome/browser/android/offline_pages/background_loader_offliner.cc

Issue 2769043002: [Offline pages] Integrate snapshot controller fully into background loader. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/offline_pages/background_loader_offliner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/background_loader_offliner.cc
diff --git a/chrome/browser/android/offline_pages/background_loader_offliner.cc b/chrome/browser/android/offline_pages/background_loader_offliner.cc
index 9b163c5ee7c1e196bcf3eca650134188c3371e59..ed080b36c5c2b288ede8d2b1253238c18d65f578 100644
--- a/chrome/browser/android/offline_pages/background_loader_offliner.cc
+++ b/chrome/browser/android/offline_pages/background_loader_offliner.cc
@@ -14,6 +14,7 @@
#include "components/offline_pages/core/offline_page_model.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_handle.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_user_data.h"
@@ -21,6 +22,7 @@ namespace offline_pages {
namespace {
const long kOfflinePageDelayMs = 2000;
+const long kOfflineDomContentLoadedMs = 25000;
class OfflinerData : public content::WebContentsUserData<OfflinerData> {
public:
@@ -152,12 +154,16 @@ bool BackgroundLoaderOffliner::LoadAndSave(
// Load page attempt.
loader_.get()->LoadPage(request.url());
+ snapshot_controller_.reset(
+ new SnapshotController(base::ThreadTaskRunnerHandle::Get(), this,
+ kOfflineDomContentLoadedMs, page_delay_ms_));
+
return true;
}
void BackgroundLoaderOffliner::Cancel(const CancelCallback& callback) {
// TODO(chili): We are not able to cancel a pending
- // OfflinePageModel::SavePage() operation. We will notify caller that
+ // OfflinePageModel::SaveSnapshot() operation. We will notify caller that
// cancel completed once the SavePage operation returns.
if (!pending_request_) {
callback.Run(0LL);
@@ -181,21 +187,19 @@ bool BackgroundLoaderOffliner::HandleTimeout(const SavePageRequest& request) {
return false;
}
+void BackgroundLoaderOffliner::DocumentLoadedInFrame(
+ content::RenderFrameHost* render_host) {
+ if (!render_host->GetParent())
Pete Williamson 2017/03/27 21:45:45 Let's add a comment here: // If this was for the m
chili 2017/03/27 23:43:43 Done.
+ snapshot_controller_->DocumentAvailableInMainFrame();
+}
+
void BackgroundLoaderOffliner::DidStopLoading() {
if (!pending_request_.get()) {
DVLOG(1) << "DidStopLoading called even though no pending request.";
return;
}
- // Invalidate ptrs for any ongoing save operation.
- weak_ptr_factory_.InvalidateWeakPtrs();
-
- // Post SavePage task with 2 second delay.
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&BackgroundLoaderOffliner::SavePage,
- weak_ptr_factory_.GetWeakPtr()),
- base::TimeDelta::FromMilliseconds(page_delay_ms_));
+ snapshot_controller_->DocumentOnLoadCompletedInMainFrame();
}
void BackgroundLoaderOffliner::RenderProcessGone(
@@ -291,7 +295,7 @@ void BackgroundLoaderOffliner::OnNetworkBytesChanged(int64_t bytes) {
}
}
-void BackgroundLoaderOffliner::SavePage() {
+void BackgroundLoaderOffliner::StartSnapshot() {
if (!pending_request_.get()) {
DVLOG(1) << "Pending request was cleared during delay.";
return;
« no previous file with comments | « chrome/browser/android/offline_pages/background_loader_offliner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698