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

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

Issue 2608553002: [OfflinePages] Improve visiblity/handling of "Loading not started" case (Closed)
Patch Set: Addes ! low-end device default to test Setup Created 3 years, 11 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/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 bool PrerenderingLoader::LoadPage(const GURL& url, 90 bool PrerenderingLoader::LoadPage(const GURL& url,
91 const LoadPageCallback& callback) { 91 const LoadPageCallback& callback) {
92 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 92 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
93 if (!IsIdle()) { 93 if (!IsIdle()) {
94 DVLOG(1) 94 DVLOG(1)
95 << "WARNING: Existing request in progress or waiting for StopLoading()"; 95 << "WARNING: Existing request in progress or waiting for StopLoading()";
96 return false; 96 return false;
97 } 97 }
98 if (!CanPrerender())
99 return false;
100 98
101 // Create a WebContents instance to define and hold a SessionStorageNamespace 99 // Create a WebContents instance to define and hold a SessionStorageNamespace
102 // for this load request. 100 // for this load request.
103 DCHECK(!session_contents_.get()); 101 DCHECK(!session_contents_.get());
104 std::unique_ptr<content::WebContents> new_web_contents( 102 std::unique_ptr<content::WebContents> new_web_contents(
105 content::WebContents::Create( 103 content::WebContents::Create(
106 content::WebContents::CreateParams(browser_context_))); 104 content::WebContents::CreateParams(browser_context_)));
107 content::SessionStorageNamespace* sessionStorageNamespace = 105 content::SessionStorageNamespace* sessionStorageNamespace =
108 new_web_contents->GetController().GetDefaultSessionStorageNamespace(); 106 new_web_contents->GetController().GetDefaultSessionStorageNamespace();
109 gfx::Size renderWindowSize = new_web_contents->GetContainerBounds().size(); 107 gfx::Size renderWindowSize = new_web_contents->GetContainerBounds().size();
(...skipping 11 matching lines...) Expand all
121 session_contents_.swap(new_web_contents); 119 session_contents_.swap(new_web_contents);
122 state_ = State::LOADING; 120 state_ = State::LOADING;
123 return true; 121 return true;
124 } 122 }
125 123
126 void PrerenderingLoader::StopLoading() { 124 void PrerenderingLoader::StopLoading() {
127 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 125 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
128 CancelPrerender(); 126 CancelPrerender();
129 } 127 }
130 128
131 bool PrerenderingLoader::CanPrerender() {
132 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
133 return adapter_->CanPrerender();
134 }
135
136 bool PrerenderingLoader::IsIdle() { 129 bool PrerenderingLoader::IsIdle() {
137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 130 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
138 return state_ == State::IDLE; 131 return state_ == State::IDLE;
139 } 132 }
140 133
141 bool PrerenderingLoader::IsLoaded() { 134 bool PrerenderingLoader::IsLoaded() {
142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 135 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
143 return state_ == State::LOADED; 136 return state_ == State::LOADED;
144 } 137 }
145 138
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void PrerenderingLoader::CancelPrerender() { 251 void PrerenderingLoader::CancelPrerender() {
259 if (adapter_->IsActive()) { 252 if (adapter_->IsActive()) {
260 adapter_->DestroyActive(); 253 adapter_->DestroyActive();
261 } 254 }
262 snapshot_controller_.reset(nullptr); 255 snapshot_controller_.reset(nullptr);
263 session_contents_.reset(nullptr); 256 session_contents_.reset(nullptr);
264 state_ = State::IDLE; 257 state_ = State::IDLE;
265 } 258 }
266 259
267 } // namespace offline_pages 260 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698