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

Side by Side Diff: chrome/browser/android/offline_pages/prerendering_offliner.cc

Issue 2052913002: For Offliner, pass in the URL from WebContents to SavePage request instead of the request URL since… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moreturnon
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/android/offline_pages/prerendering_offliner.h" 5 #include "chrome/browser/android/offline_pages/prerendering_offliner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 8 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
9 #include "components/offline_pages/background/save_page_request.h" 9 #include "components/offline_pages/background/save_page_request.h"
10 #include "components/offline_pages/offline_page_model.h" 10 #include "components/offline_pages/offline_page_model.h"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/web_contents.h"
12 13
13 namespace offline_pages { 14 namespace offline_pages {
14 15
15 PrerenderingOffliner::PrerenderingOffliner( 16 PrerenderingOffliner::PrerenderingOffliner(
16 content::BrowserContext* browser_context, 17 content::BrowserContext* browser_context,
17 const OfflinerPolicy* policy, 18 const OfflinerPolicy* policy,
18 OfflinePageModel* offline_page_model) 19 OfflinePageModel* offline_page_model)
19 : browser_context_(browser_context), 20 : browser_context_(browser_context),
20 offline_page_model_(offline_page_model), 21 offline_page_model_(offline_page_model),
21 pending_request_(nullptr), 22 pending_request_(nullptr),
(...skipping 23 matching lines...) Expand all
45 } 46 }
46 47
47 if (load_status == Offliner::RequestStatus::LOADED) { 48 if (load_status == Offliner::RequestStatus::LOADED) {
48 // The page has successfully loaded so now try to save the page. 49 // The page has successfully loaded so now try to save the page.
49 // After issuing the save request we will wait for either: the save 50 // After issuing the save request we will wait for either: the save
50 // callback or a CANCELED load callback (triggered because the loaded 51 // callback or a CANCELED load callback (triggered because the loaded
51 // WebContents are being destroyed) - whichever callback occurs first. 52 // WebContents are being destroyed) - whichever callback occurs first.
52 DCHECK(web_contents); 53 DCHECK(web_contents);
53 std::unique_ptr<OfflinePageArchiver> archiver( 54 std::unique_ptr<OfflinePageArchiver> archiver(
54 new OfflinePageMHTMLArchiver(web_contents)); 55 new OfflinePageMHTMLArchiver(web_contents));
55 SavePage(request.url(), request.client_id(), std::move(archiver), 56 // Pass in the URL from the WebContents in case it is redirected from
57 // the requested URL. This is to work around a check in the
58 // OfflinePageModel implementation that ensures URL passed in here is
59 // same as LastCommittedURL from the snapshot.
60 // TODO(dougarnett): Raise issue of how to better deal with redirects.
61 SavePage(web_contents->GetLastCommittedURL(), request.client_id(),
62 std::move(archiver),
56 base::Bind(&PrerenderingOffliner::OnSavePageDone, 63 base::Bind(&PrerenderingOffliner::OnSavePageDone,
57 weak_ptr_factory_.GetWeakPtr(), request, 64 weak_ptr_factory_.GetWeakPtr(), request,
58 completion_callback)); 65 completion_callback));
59 } else { 66 } else {
60 // Clear pending request and then run the completion callback. 67 // Clear pending request and then run the completion callback.
61 pending_request_.reset(nullptr); 68 pending_request_.reset(nullptr);
62 completion_callback.Run(request, load_status); 69 completion_callback.Run(request, load_status);
63 } 70 }
64 } 71 }
65 72
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 157 }
151 158
152 PrerenderingLoader* PrerenderingOffliner::GetOrCreateLoader() { 159 PrerenderingLoader* PrerenderingOffliner::GetOrCreateLoader() {
153 if (!loader_) { 160 if (!loader_) {
154 loader_.reset(new PrerenderingLoader(browser_context_)); 161 loader_.reset(new PrerenderingLoader(browser_context_));
155 } 162 }
156 return loader_.get(); 163 return loader_.get();
157 } 164 }
158 165
159 } // namespace offline_pages 166 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698