Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 session_contents_.reset(content::WebContents::Create( |
|
dewittj
2016/09/13 17:03:17
nit: I have a slight preference for putting it int
dougarnett
2016/09/13 18:15:22
Done. Please check.
| |
| 46 content::WebContents::CreateParams(browser_context_))); | 46 content::WebContents::CreateParams(browser_context_))); |
| 47 content::SessionStorageNamespace* sessionStorageNamespace = | 47 content::SessionStorageNamespace* sessionStorageNamespace = |
| 48 session_contents_->GetController().GetDefaultSessionStorageNamespace(); | 48 session_contents_->GetController().GetDefaultSessionStorageNamespace(); |
| 49 gfx::Size renderWindowSize = session_contents_->GetContainerBounds().size(); | 49 gfx::Size renderWindowSize = session_contents_->GetContainerBounds().size(); |
| 50 bool accepted = adapter_->StartPrerender( | 50 bool accepted = adapter_->StartPrerender( |
| 51 browser_context_, url, sessionStorageNamespace, renderWindowSize); | 51 browser_context_, url, sessionStorageNamespace, renderWindowSize); |
| 52 if (!accepted) | 52 if (!accepted) { |
| 53 session_contents_.reset(nullptr); | |
|
dewittj
2016/09/13 17:03:17
It is unfortunate that we have to create a web con
dougarnett
2016/09/13 18:15:22
Acknowledged.
| |
| 53 return false; | 54 return false; |
| 55 } | |
| 54 | 56 |
| 55 DCHECK(adapter_->IsActive()); | 57 DCHECK(adapter_->IsActive()); |
| 56 snapshot_controller_.reset( | 58 snapshot_controller_.reset( |
| 57 new SnapshotController(base::ThreadTaskRunnerHandle::Get(), this)); | 59 new SnapshotController(base::ThreadTaskRunnerHandle::Get(), this)); |
| 58 callback_ = callback; | 60 callback_ = callback; |
| 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() { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| OLD | NEW |