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

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

Issue 2333333002: [Offline Pages] Fixes PrerenderingLoader bug to clear session_contents_ when PrerenderManager does … (Closed)
Patch Set: Update per dewittj feedback Created 4 years, 3 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 | chrome/browser/android/offline_pages/prerendering_loader_unittest.cc » ('j') | 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_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 24 matching lines...) Expand all
35 DVLOG(1) 35 DVLOG(1)
36 << "WARNING: Existing request in progress or waiting for StopLoading()"; 36 << "WARNING: Existing request in progress or waiting for StopLoading()";
37 return false; 37 return false;
38 } 38 }
39 if (!CanPrerender()) 39 if (!CanPrerender())
40 return false; 40 return false;
41 41
42 // Create a WebContents instance to define and hold a SessionStorageNamespace 42 // Create a WebContents instance to define and hold a SessionStorageNamespace
43 // for this load request. 43 // for this load request.
44 DCHECK(!session_contents_.get()); 44 DCHECK(!session_contents_.get());
45 session_contents_.reset(content::WebContents::Create( 45 std::unique_ptr<content::WebContents> new_web_contents(
46 content::WebContents::CreateParams(browser_context_))); 46 content::WebContents::Create(
47 content::WebContents::CreateParams(browser_context_)));
47 content::SessionStorageNamespace* sessionStorageNamespace = 48 content::SessionStorageNamespace* sessionStorageNamespace =
48 session_contents_->GetController().GetDefaultSessionStorageNamespace(); 49 new_web_contents->GetController().GetDefaultSessionStorageNamespace();
49 gfx::Size renderWindowSize = session_contents_->GetContainerBounds().size(); 50 gfx::Size renderWindowSize = new_web_contents->GetContainerBounds().size();
50 bool accepted = adapter_->StartPrerender( 51 bool accepted = adapter_->StartPrerender(
51 browser_context_, url, sessionStorageNamespace, renderWindowSize); 52 browser_context_, url, sessionStorageNamespace, renderWindowSize);
52 if (!accepted) 53 if (!accepted)
53 return false; 54 return false;
54 55
55 DCHECK(adapter_->IsActive()); 56 DCHECK(adapter_->IsActive());
56 snapshot_controller_.reset( 57 snapshot_controller_.reset(
57 new SnapshotController(base::ThreadTaskRunnerHandle::Get(), this)); 58 new SnapshotController(base::ThreadTaskRunnerHandle::Get(), this));
58 callback_ = callback; 59 callback_ = callback;
60 session_contents_.swap(new_web_contents);
59 state_ = State::PENDING; 61 state_ = State::PENDING;
60 return true; 62 return true;
61 } 63 }
62 64
63 void PrerenderingLoader::StopLoading() { 65 void PrerenderingLoader::StopLoading() {
64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
65 CancelPrerender(); 67 CancelPrerender();
66 } 68 }
67 69
68 bool PrerenderingLoader::CanPrerender() { 70 bool PrerenderingLoader::CanPrerender() {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void PrerenderingLoader::CancelPrerender() { 199 void PrerenderingLoader::CancelPrerender() {
198 if (adapter_->IsActive()) { 200 if (adapter_->IsActive()) {
199 adapter_->DestroyActive(); 201 adapter_->DestroyActive();
200 } 202 }
201 snapshot_controller_.reset(nullptr); 203 snapshot_controller_.reset(nullptr);
202 session_contents_.reset(nullptr); 204 session_contents_.reset(nullptr);
203 state_ = State::IDLE; 205 state_ = State::IDLE;
204 } 206 }
205 207
206 } // namespace offline_pages 208 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/prerendering_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698