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

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

Issue 2048923002: Fixes for turning on offliner request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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_loader.h" 5 #include "chrome/browser/android/offline_pages/prerendering_loader.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
15 15
16 namespace offline_pages { 16 namespace offline_pages {
17 17
18 PrerenderingLoader::PrerenderingLoader(content::BrowserContext* browser_context) 18 PrerenderingLoader::PrerenderingLoader(content::BrowserContext* browser_context)
19 : state_(State::IDLE), browser_context_(browser_context) { 19 : state_(State::IDLE), browser_context_(browser_context) {
20 adapter_.reset(new PrerenderAdapter(this)); 20 adapter_.reset(new PrerenderAdapter(this));
21 } 21 }
22 22
23 PrerenderingLoader::~PrerenderingLoader() { 23 PrerenderingLoader::~PrerenderingLoader() {
24 CancelPrerender(); 24 CancelPrerender();
25 } 25 }
26 26
27 bool PrerenderingLoader::LoadPage(const GURL& url, 27 bool PrerenderingLoader::LoadPage(const GURL& url, LoadPageCallback callback) {
28 const LoadPageCallback& callback) {
29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
30 if (!IsIdle()) { 29 if (!IsIdle()) {
31 DVLOG(1) 30 DVLOG(1)
32 << "WARNING: Existing request in progress or waiting for StopLoading()"; 31 << "WARNING: Existing request in progress or waiting for StopLoading()";
33 return false; 32 return false;
34 } 33 }
35 if (!CanPrerender()) 34 if (!CanPrerender())
36 return false; 35 return false;
37 36
38 // Create a WebContents instance to define and hold a SessionStorageNamespace 37 // Create a WebContents instance to define and hold a SessionStorageNamespace
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 session_contents_.reset(nullptr); 160 session_contents_.reset(nullptr);
162 if (!IsLoaded() && !IsIdle()) { 161 if (!IsLoaded() && !IsIdle()) {
163 base::ThreadTaskRunnerHandle::Get()->PostTask( 162 base::ThreadTaskRunnerHandle::Get()->PostTask(
164 FROM_HERE, 163 FROM_HERE,
165 base::Bind(callback_, Offliner::RequestStatus::CANCELED, nullptr)); 164 base::Bind(callback_, Offliner::RequestStatus::CANCELED, nullptr));
166 } 165 }
167 state_ = State::IDLE; 166 state_ = State::IDLE;
168 } 167 }
169 168
170 } // namespace offline_pages 169 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698