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

Side by Side Diff: components/dom_distiller/content/browser/distiller_page_web_contents.cc

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/dom_distiller/content/browser/distiller_page_web_contents.h " 5 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h "
6 6
7 #include <memory>
7 #include <utility> 8 #include <utility>
8 9
9 #include "base/callback.h" 10 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" 13 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
14 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser ver.h" 14 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser ver.h"
15 #include "components/dom_distiller/core/distiller_page.h" 15 #include "components/dom_distiller/core/distiller_page.h"
16 #include "components/dom_distiller/core/dom_distiller_constants.h" 16 #include "components/dom_distiller/core/dom_distiller_constants.h"
17 #include "components/dom_distiller/core/dom_distiller_service.h" 17 #include "components/dom_distiller/core/dom_distiller_service.h"
18 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/navigation_controller.h" 19 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
(...skipping 10 matching lines...) Expand all
31 bool owned) 31 bool owned)
32 : web_contents_(web_contents), owned_(owned) { 32 : web_contents_(web_contents), owned_(owned) {
33 } 33 }
34 34
35 SourcePageHandleWebContents::~SourcePageHandleWebContents() { 35 SourcePageHandleWebContents::~SourcePageHandleWebContents() {
36 if (owned_) { 36 if (owned_) {
37 delete web_contents_; 37 delete web_contents_;
38 } 38 }
39 } 39 }
40 40
41 scoped_ptr<DistillerPage> DistillerPageWebContentsFactory::CreateDistillerPage( 41 std::unique_ptr<DistillerPage>
42 DistillerPageWebContentsFactory::CreateDistillerPage(
42 const gfx::Size& render_view_size) const { 43 const gfx::Size& render_view_size) const {
43 DCHECK(browser_context_); 44 DCHECK(browser_context_);
44 return scoped_ptr<DistillerPage>(new DistillerPageWebContents( 45 return std::unique_ptr<DistillerPage>(new DistillerPageWebContents(
45 browser_context_, render_view_size, 46 browser_context_, render_view_size,
46 scoped_ptr<SourcePageHandleWebContents>())); 47 std::unique_ptr<SourcePageHandleWebContents>()));
47 } 48 }
48 49
49 scoped_ptr<DistillerPage> 50 std::unique_ptr<DistillerPage>
50 DistillerPageWebContentsFactory::CreateDistillerPageWithHandle( 51 DistillerPageWebContentsFactory::CreateDistillerPageWithHandle(
51 scoped_ptr<SourcePageHandle> handle) const { 52 std::unique_ptr<SourcePageHandle> handle) const {
52 DCHECK(browser_context_); 53 DCHECK(browser_context_);
53 scoped_ptr<SourcePageHandleWebContents> web_contents_handle = 54 std::unique_ptr<SourcePageHandleWebContents> web_contents_handle =
54 scoped_ptr<SourcePageHandleWebContents>( 55 std::unique_ptr<SourcePageHandleWebContents>(
55 static_cast<SourcePageHandleWebContents*>(handle.release())); 56 static_cast<SourcePageHandleWebContents*>(handle.release()));
56 return scoped_ptr<DistillerPage>(new DistillerPageWebContents( 57 return std::unique_ptr<DistillerPage>(new DistillerPageWebContents(
57 browser_context_, gfx::Size(), std::move(web_contents_handle))); 58 browser_context_, gfx::Size(), std::move(web_contents_handle)));
58 } 59 }
59 60
60 DistillerPageWebContents::DistillerPageWebContents( 61 DistillerPageWebContents::DistillerPageWebContents(
61 content::BrowserContext* browser_context, 62 content::BrowserContext* browser_context,
62 const gfx::Size& render_view_size, 63 const gfx::Size& render_view_size,
63 scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle) 64 std::unique_ptr<SourcePageHandleWebContents> optional_web_contents_handle)
64 : state_(IDLE), 65 : state_(IDLE),
65 source_page_handle_(nullptr), 66 source_page_handle_(nullptr),
66 browser_context_(browser_context), 67 browser_context_(browser_context),
67 render_view_size_(render_view_size), 68 render_view_size_(render_view_size),
68 weak_factory_(this) { 69 weak_factory_(this) {
69 if (optional_web_contents_handle) { 70 if (optional_web_contents_handle) {
70 source_page_handle_ = std::move(optional_web_contents_handle); 71 source_page_handle_ = std::move(optional_web_contents_handle);
71 if (render_view_size.IsEmpty()) 72 if (render_view_size.IsEmpty())
72 render_view_size_ = 73 render_view_size_ =
73 source_page_handle_->web_contents()->GetContainerBounds().size(); 74 source_page_handle_->web_contents()->GetContainerBounds().size();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void DistillerPageWebContents::DidFailLoad( 160 void DistillerPageWebContents::DidFailLoad(
160 content::RenderFrameHost* render_frame_host, 161 content::RenderFrameHost* render_frame_host,
161 const GURL& validated_url, 162 const GURL& validated_url,
162 int error_code, 163 int error_code,
163 const base::string16& error_description, 164 const base::string16& error_description,
164 bool was_ignored_by_handler) { 165 bool was_ignored_by_handler) {
165 if (!render_frame_host->GetParent()) { 166 if (!render_frame_host->GetParent()) {
166 content::WebContentsObserver::Observe(NULL); 167 content::WebContentsObserver::Observe(NULL);
167 DCHECK(state_ == LOADING_PAGE || state_ == EXECUTING_JAVASCRIPT); 168 DCHECK(state_ == LOADING_PAGE || state_ == EXECUTING_JAVASCRIPT);
168 state_ = PAGELOAD_FAILED; 169 state_ = PAGELOAD_FAILED;
169 scoped_ptr<base::Value> empty = base::Value::CreateNullValue(); 170 std::unique_ptr<base::Value> empty = base::Value::CreateNullValue();
170 OnWebContentsDistillationDone(GURL(), base::TimeTicks(), empty.get()); 171 OnWebContentsDistillationDone(GURL(), base::TimeTicks(), empty.get());
171 } 172 }
172 } 173 }
173 174
174 void DistillerPageWebContents::ExecuteJavaScript() { 175 void DistillerPageWebContents::ExecuteJavaScript() {
175 content::RenderFrameHost* frame = 176 content::RenderFrameHost* frame =
176 source_page_handle_->web_contents()->GetMainFrame(); 177 source_page_handle_->web_contents()->GetMainFrame();
177 DCHECK(frame); 178 DCHECK(frame);
178 DCHECK_EQ(LOADING_PAGE, state_); 179 DCHECK_EQ(LOADING_PAGE, state_);
179 state_ = EXECUTING_JAVASCRIPT; 180 state_ = EXECUTING_JAVASCRIPT;
(...skipping 21 matching lines...) Expand all
201 if (!javascript_start.is_null()) { 202 if (!javascript_start.is_null()) {
202 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; 203 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start;
203 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); 204 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time);
204 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; 205 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time;
205 } 206 }
206 207
207 DistillerPage::OnDistillationDone(page_url, value); 208 DistillerPage::OnDistillationDone(page_url, value);
208 } 209 }
209 210
210 } // namespace dom_distiller 211 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698