summaryrefslogtreecommitdiff
path: root/chromium/components/dom_distiller
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/components/dom_distiller
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
downloadqtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/dom_distiller')
-rw-r--r--chromium/components/dom_distiller/content/browser/BUILD.gn2
-rw-r--r--chromium/components/dom_distiller/content/browser/DEPS1
-rw-r--r--chromium/components/dom_distiller/content/browser/distillability_driver.cc65
-rw-r--r--chromium/components/dom_distiller/content/browser/distillability_driver.h20
-rw-r--r--chromium/components/dom_distiller/content/browser/distillable_page_utils.cc2
-rw-r--r--chromium/components/dom_distiller/content/browser/distillable_page_utils_android.cc7
-rw-r--r--chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc8
-rw-r--r--chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc4
-rw-r--r--chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.h11
-rw-r--r--chromium/components/dom_distiller/content/browser/distiller_page_web_contents.cc28
-rw-r--r--chromium/components/dom_distiller/content/browser/distiller_page_web_contents.h18
-rw-r--r--chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc28
-rw-r--r--chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc19
-rw-r--r--chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.h11
-rw-r--r--chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source_unittest.cc2
-rw-r--r--chromium/components/dom_distiller/content/common/BUILD.gn16
-rw-r--r--chromium/components/dom_distiller/content/common/OWNERS13
-rw-r--r--chromium/components/dom_distiller/content/common/distillability_service.mojom11
-rw-r--r--chromium/components/dom_distiller/content/common/distiller_javascript_service.mojom2
-rw-r--r--chromium/components/dom_distiller/content/common/distiller_messages.cc33
-rw-r--r--chromium/components/dom_distiller/content/common/distiller_messages.h21
-rw-r--r--chromium/components/dom_distiller/content/common/distiller_page_notifier_service.mojom2
-rw-r--r--chromium/components/dom_distiller/content/renderer/BUILD.gn1
-rw-r--r--chromium/components/dom_distiller/content/renderer/distillability_agent.cc14
-rw-r--r--chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc7
-rw-r--r--chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h6
-rw-r--r--chromium/components/dom_distiller/content/renderer/distiller_native_javascript.cc15
-rw-r--r--chromium/components/dom_distiller/content/renderer/distiller_native_javascript.h2
-rw-r--r--chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.cc2
-rw-r--r--chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.h10
-rw-r--r--chromium/components/dom_distiller/core/BUILD.gn14
-rw-r--r--chromium/components/dom_distiller/core/article_attachments_data.cc5
-rw-r--r--chromium/components/dom_distiller/core/article_attachments_data.h4
-rw-r--r--chromium/components/dom_distiller/core/css/distilledpage.css2
-rw-r--r--chromium/components/dom_distiller/core/distillable_page_detector.cc8
-rw-r--r--chromium/components/dom_distiller/core/distillable_page_detector.h6
-rw-r--r--chromium/components/dom_distiller/core/distillable_page_detector_unittest.cc13
-rw-r--r--chromium/components/dom_distiller/core/distilled_content_store.cc6
-rw-r--r--chromium/components/dom_distiller/core/distilled_content_store.h9
-rw-r--r--chromium/components/dom_distiller/core/distilled_content_store_unittest.cc7
-rw-r--r--chromium/components/dom_distiller/core/distilled_page_prefs.cc2
-rw-r--r--chromium/components/dom_distiller/core/distilled_page_prefs_unittests.cc4
-rw-r--r--chromium/components/dom_distiller/core/distiller.cc12
-rw-r--r--chromium/components/dom_distiller/core/distiller.h20
-rw-r--r--chromium/components/dom_distiller/core/distiller_page.cc6
-rw-r--r--chromium/components/dom_distiller/core/distiller_page.h15
-rw-r--r--chromium/components/dom_distiller/core/distiller_unittest.cc85
-rw-r--r--chromium/components/dom_distiller/core/distiller_url_fetcher.cc4
-rw-r--r--chromium/components/dom_distiller/core/distiller_url_fetcher.h4
-rw-r--r--chromium/components/dom_distiller/core/distiller_url_fetcher_unittest.cc4
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_request_view_base.cc4
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_request_view_base.h6
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_request_view_base_unittest.cc28
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_service.cc44
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_service.h65
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_service_unittest.cc62
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_store.cc31
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_store.h37
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_store_unittest.cc24
-rw-r--r--chromium/components/dom_distiller/core/dom_distiller_test_util.cc2
-rw-r--r--chromium/components/dom_distiller/core/fake_distiller.cc13
-rw-r--r--chromium/components/dom_distiller/core/fake_distiller.h14
-rw-r--r--chromium/components/dom_distiller/core/fake_distiller_page.h10
-rw-r--r--chromium/components/dom_distiller/core/javascript/dom_distiller_viewer.js17
-rw-r--r--chromium/components/dom_distiller/core/page_features.cc4
-rw-r--r--chromium/components/dom_distiller/core/page_features_unittest.cc8
-rw-r--r--chromium/components/dom_distiller/core/task_tracker.cc18
-rw-r--r--chromium/components/dom_distiller/core/task_tracker.h15
-rw-r--r--chromium/components/dom_distiller/core/task_tracker_unittest.cc66
-rw-r--r--chromium/components/dom_distiller/core/url_constants.cc1
-rw-r--r--chromium/components/dom_distiller/core/url_constants.h1
-rw-r--r--chromium/components/dom_distiller/core/url_utils.cc23
-rw-r--r--chromium/components/dom_distiller/core/url_utils.h7
-rw-r--r--chromium/components/dom_distiller/core/url_utils_unittest.cc2
-rw-r--r--chromium/components/dom_distiller/core/viewer.cc8
-rw-r--r--chromium/components/dom_distiller/core/viewer.h4
-rw-r--r--chromium/components/dom_distiller/core/viewer_unittest.cc38
-rw-r--r--chromium/components/dom_distiller/ios/distiller_page_factory_ios.h9
-rw-r--r--chromium/components/dom_distiller/ios/distiller_page_factory_ios.mm11
-rw-r--r--chromium/components/dom_distiller/ios/distiller_page_ios.h6
-rw-r--r--chromium/components/dom_distiller/ios/distiller_page_ios.mm4
-rw-r--r--chromium/components/dom_distiller/standalone/content_extractor_browsertest.cc47
-rw-r--r--chromium/components/dom_distiller/webui/dom_distiller_handler.cc2
83 files changed, 672 insertions, 570 deletions
diff --git a/chromium/components/dom_distiller/content/browser/BUILD.gn b/chromium/components/dom_distiller/content/browser/BUILD.gn
index db24bc274bb..e306568f3f1 100644
--- a/chromium/components/dom_distiller/content/browser/BUILD.gn
+++ b/chromium/components/dom_distiller/content/browser/BUILD.gn
@@ -30,7 +30,6 @@ static_library("browser") {
]
deps = [
"//base",
- "//components/dom_distiller/content/common",
"//components/dom_distiller/content/common:mojo_bindings",
"//components/resources",
"//components/strings",
@@ -42,6 +41,7 @@ static_library("browser") {
"//sync",
"//third_party/WebKit/public:blink_headers",
"//ui/base",
+ "//ui/display",
"//ui/gfx",
"//url",
]
diff --git a/chromium/components/dom_distiller/content/browser/DEPS b/chromium/components/dom_distiller/content/browser/DEPS
index ef8ad28d9d4..f88ee8727b1 100644
--- a/chromium/components/dom_distiller/content/browser/DEPS
+++ b/chromium/components/dom_distiller/content/browser/DEPS
@@ -1,3 +1,4 @@
include_rules = [
"+mojo/public",
+ "+ui/display",
]
diff --git a/chromium/components/dom_distiller/content/browser/distillability_driver.cc b/chromium/components/dom_distiller/content/browser/distillability_driver.cc
index 8af458f5c0a..e0897d0a337 100644
--- a/chromium/components/dom_distiller/content/browser/distillability_driver.cc
+++ b/chromium/components/dom_distiller/content/browser/distillability_driver.cc
@@ -3,24 +3,54 @@
// found in the LICENSE file.
#include "components/dom_distiller/content/browser/distillability_driver.h"
-#include "components/dom_distiller/content/common/distiller_messages.h"
#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "content/public/common/service_registry.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(
dom_distiller::DistillabilityDriver);
namespace dom_distiller {
+// Implementation of the Mojo DistillabilityService. This is called by the
+// renderer to notify the browser that a page is distillable.
+class DistillabilityServiceImpl : public mojom::DistillabilityService {
+ public:
+ DistillabilityServiceImpl(
+ mojo::InterfaceRequest<mojom::DistillabilityService> request,
+ base::WeakPtr<DistillabilityDriver> distillability_driver)
+ : binding_(this, std::move(request)),
+ distillability_driver_(distillability_driver) {}
+
+ ~DistillabilityServiceImpl() override {}
+
+ void NotifyIsDistillable(bool is_distillable, bool is_last_update) override {
+ if (!distillability_driver_) return;
+ distillability_driver_->OnDistillability(is_distillable, is_last_update);
+ }
+
+ private:
+ mojo::StrongBinding<mojom::DistillabilityService> binding_;
+ base::WeakPtr<DistillabilityDriver> distillability_driver_;
+};
+
DistillabilityDriver::DistillabilityDriver(
content::WebContents* web_contents)
- : content::WebContentsObserver(web_contents) {
+ : content::WebContentsObserver(web_contents),
+ weak_factory_(this) {
+ SetupMojoService();
}
DistillabilityDriver::~DistillabilityDriver() {
- CleanUp();
+ content::WebContentsObserver::Observe(nullptr);
+}
+
+void DistillabilityDriver::CreateDistillabilityService(
+ mojo::InterfaceRequest<mojom::DistillabilityService> request) {
+ new DistillabilityServiceImpl(std::move(request), weak_factory_.GetWeakPtr());
}
void DistillabilityDriver::SetDelegate(
@@ -28,17 +58,6 @@ void DistillabilityDriver::SetDelegate(
m_delegate_ = delegate;
}
-bool DistillabilityDriver::OnMessageReceived(const IPC::Message &msg,
- content::RenderFrameHost* render_frame_host) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(DistillabilityDriver, msg)
- IPC_MESSAGE_HANDLER(FrameHostMsg_Distillability,
- OnDistillability)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
void DistillabilityDriver::OnDistillability(
bool distillable, bool is_last) {
if (m_delegate_.is_null()) return;
@@ -46,13 +65,21 @@ void DistillabilityDriver::OnDistillability(
m_delegate_.Run(distillable, is_last);
}
-void DistillabilityDriver::RenderProcessGone(
- base::TerminationStatus status) {
- CleanUp();
+void DistillabilityDriver::DidStartProvisionalLoadForFrame(
+ content::RenderFrameHost* render_frame_host, const GURL& validated_url,
+ bool is_error_page, bool is_iframe_srcdoc) {
+ SetupMojoService();
}
-void DistillabilityDriver::CleanUp() {
- content::WebContentsObserver::Observe(NULL);
+void DistillabilityDriver::SetupMojoService() {
+ if (!web_contents()) return;
+
+ content::RenderFrameHost* frame_host = web_contents()->GetMainFrame();
+ if (!frame_host || !frame_host->GetServiceRegistry()) return;
+
+ frame_host->GetServiceRegistry()->AddService(
+ base::Bind(&DistillabilityDriver::CreateDistillabilityService,
+ weak_factory_.GetWeakPtr()));
}
} // namespace dom_distiller
diff --git a/chromium/components/dom_distiller/content/browser/distillability_driver.h b/chromium/components/dom_distiller/content/browser/distillability_driver.h
index 795b9bf438f..eb25f0a37ab 100644
--- a/chromium/components/dom_distiller/content/browser/distillability_driver.h
+++ b/chromium/components/dom_distiller/content/browser/distillability_driver.h
@@ -6,8 +6,11 @@
#define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "components/dom_distiller/content/common/distillability_service.mojom.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
namespace dom_distiller {
@@ -17,25 +20,30 @@ class DistillabilityDriver
public content::WebContentsUserData<DistillabilityDriver> {
public:
~DistillabilityDriver() override;
+ void CreateDistillabilityService(
+ mojo::InterfaceRequest<mojom::DistillabilityService> request);
void SetDelegate(const base::Callback<void(bool, bool)>& delegate);
// content::WebContentsObserver implementation.
- bool OnMessageReceived(const IPC::Message& message,
- content::RenderFrameHost* rfh) override;
- void RenderProcessGone(base::TerminationStatus status) override;
+ void DidStartProvisionalLoadForFrame(
+ content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url,
+ bool is_error_page,
+ bool is_iframe_srcdoc) override;
private:
explicit DistillabilityDriver(content::WebContents* web_contents);
friend class content::WebContentsUserData<DistillabilityDriver>;
+ friend class DistillabilityServiceImpl;
+ void SetupMojoService();
void OnDistillability(bool distillable, bool is_last);
- // Removes the observer and clears the WebContents member.
- void CleanUp();
-
base::Callback<void(bool, bool)> m_delegate_;
+ base::WeakPtrFactory<DistillabilityDriver> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(DistillabilityDriver);
};
diff --git a/chromium/components/dom_distiller/content/browser/distillable_page_utils.cc b/chromium/components/dom_distiller/content/browser/distillable_page_utils.cc
index 56d606b242a..0d79f5758cd 100644
--- a/chromium/components/dom_distiller/content/browser/distillable_page_utils.cc
+++ b/chromium/components/dom_distiller/content/browser/distillable_page_utils.cc
@@ -8,7 +8,7 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/dom_distiller/content/browser/distillability_driver.h"
#include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
diff --git a/chromium/components/dom_distiller/content/browser/distillable_page_utils_android.cc b/chromium/components/dom_distiller/content/browser/distillable_page_utils_android.cc
index ab84a56c064..84abf2d7173 100644
--- a/chromium/components/dom_distiller/content/browser/distillable_page_utils_android.cc
+++ b/chromium/components/dom_distiller/content/browser/distillable_page_utils_android.cc
@@ -4,8 +4,9 @@
#include "components/dom_distiller/content/browser/distillable_page_utils_android.h"
+#include <memory>
+
#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "components/dom_distiller/content/browser/distillable_page_utils.h"
#include "content/public/browser/web_contents.h"
@@ -17,7 +18,7 @@ namespace dom_distiller {
namespace android {
namespace {
void OnIsPageDistillableResult(
- scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder,
+ std::unique_ptr<ScopedJavaGlobalRef<jobject>> callback_holder,
bool isDistillable) {
Java_DistillablePageUtils_callOnIsPageDistillableResult(
base::android::AttachCurrentThread(), callback_holder->obj(),
@@ -40,7 +41,7 @@ static void IsPageDistillable(JNIEnv* env,
const JavaParamRef<jobject>& callback) {
content::WebContents* web_contents(
content::WebContents::FromJavaWebContents(webContents));
- scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder(
+ std::unique_ptr<ScopedJavaGlobalRef<jobject>> callback_holder(
new ScopedJavaGlobalRef<jobject>());
callback_holder->Reset(env, callback);
diff --git a/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc b/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc
index 4ec50f72bd6..99cee028959 100644
--- a/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc
+++ b/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc
@@ -133,7 +133,7 @@ IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest,
IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest,
TestIsDistillablePage) {
- scoped_ptr<AdaBoostProto> proto(new AdaBoostProto);
+ std::unique_ptr<AdaBoostProto> proto(new AdaBoostProto);
proto->set_num_features(kDerivedFeaturesCount);
proto->set_num_stumps(1);
@@ -141,7 +141,7 @@ IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest,
stump->set_feature_number(0);
stump->set_weight(1);
stump->set_split(-1);
- scoped_ptr<DistillablePageDetector> detector(
+ std::unique_ptr<DistillablePageDetector> detector(
new DistillablePageDetector(std::move(proto)));
EXPECT_DOUBLE_EQ(0.5, detector->GetThreshold());
// The first value of the first feature is either 0 or 1. Since the stump's
@@ -158,14 +158,14 @@ IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest,
IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest,
TestIsNotDistillablePage) {
- scoped_ptr<AdaBoostProto> proto(new AdaBoostProto);
+ std::unique_ptr<AdaBoostProto> proto(new AdaBoostProto);
proto->set_num_features(kDerivedFeaturesCount);
proto->set_num_stumps(1);
StumpProto* stump = proto->add_stump();
stump->set_feature_number(0);
stump->set_weight(-1);
stump->set_split(-1);
- scoped_ptr<DistillablePageDetector> detector(
+ std::unique_ptr<DistillablePageDetector> detector(
new DistillablePageDetector(std::move(proto)));
EXPECT_DOUBLE_EQ(-0.5, detector->GetThreshold());
// The first value of the first feature is either 0 or 1. Since the stump's
diff --git a/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc b/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc
index 11e3841c5ec..ea825c0014f 100644
--- a/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc
+++ b/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc
@@ -16,7 +16,7 @@ namespace dom_distiller {
DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl(
content::RenderFrameHost* render_frame_host,
DistillerUIHandle* distiller_ui_handle,
- mojo::InterfaceRequest<DistillerJavaScriptService> request)
+ mojo::InterfaceRequest<mojom::DistillerJavaScriptService> request)
: binding_(this, std::move(request)),
render_frame_host_(render_frame_host),
distiller_ui_handle_(distiller_ui_handle) {}
@@ -65,7 +65,7 @@ void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() {
void CreateDistillerJavaScriptService(
content::RenderFrameHost* render_frame_host,
DistillerUIHandle* distiller_ui_handle,
- mojo::InterfaceRequest<DistillerJavaScriptService> request) {
+ mojo::InterfaceRequest<mojom::DistillerJavaScriptService> request) {
// This is strongly bound and owned by the pipe.
new DistillerJavaScriptServiceImpl(render_frame_host, distiller_ui_handle,
std::move(request));
diff --git a/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.h b/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.h
index ad4540be80a..cc1659c8e9b 100644
--- a/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.h
+++ b/chromium/components/dom_distiller/content/browser/distiller_javascript_service_impl.h
@@ -13,15 +13,16 @@
namespace dom_distiller {
// This is the receiving end of "distiller" JavaScript object calls.
-class DistillerJavaScriptServiceImpl : public DistillerJavaScriptService {
+class DistillerJavaScriptServiceImpl
+ : public mojom::DistillerJavaScriptService {
public:
DistillerJavaScriptServiceImpl(
content::RenderFrameHost* render_frame_host,
DistillerUIHandle* distiller_ui_handle,
- mojo::InterfaceRequest<DistillerJavaScriptService> request);
+ mojo::InterfaceRequest<mojom::DistillerJavaScriptService> request);
~DistillerJavaScriptServiceImpl() override;
- // Mojo DistillerJavaScriptService implementation.
+ // Mojo mojom::DistillerJavaScriptService implementation.
// Echo implementation, this call does not actually return as it would be
// blocking.
@@ -37,7 +38,7 @@ class DistillerJavaScriptServiceImpl : public DistillerJavaScriptService {
void HandleDistillerOpenSettingsCall() override;
private:
- mojo::StrongBinding<DistillerJavaScriptService> binding_;
+ mojo::StrongBinding<mojom::DistillerJavaScriptService> binding_;
content::RenderFrameHost* render_frame_host_;
DistillerUIHandle* distiller_ui_handle_;
};
@@ -46,7 +47,7 @@ class DistillerJavaScriptServiceImpl : public DistillerJavaScriptService {
void CreateDistillerJavaScriptService(
content::RenderFrameHost* render_frame_host,
DistillerUIHandle* distiller_ui_handle,
- mojo::InterfaceRequest<DistillerJavaScriptService> request);
+ mojo::InterfaceRequest<mojom::DistillerJavaScriptService> request);
} // namespace dom_distiller
diff --git a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.cc b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.cc
index e458cf96500..27c13cdb169 100644
--- a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.cc
+++ b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.cc
@@ -4,10 +4,10 @@
#include "components/dom_distiller/content/browser/distiller_page_web_contents.h"
+#include <memory>
#include <utility>
#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/strings/utf_string_conversions.h"
#include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
@@ -21,7 +21,8 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
-#include "ui/gfx/screen.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "url/gurl.h"
namespace dom_distiller {
@@ -38,29 +39,30 @@ SourcePageHandleWebContents::~SourcePageHandleWebContents() {
}
}
-scoped_ptr<DistillerPage> DistillerPageWebContentsFactory::CreateDistillerPage(
+std::unique_ptr<DistillerPage>
+DistillerPageWebContentsFactory::CreateDistillerPage(
const gfx::Size& render_view_size) const {
DCHECK(browser_context_);
- return scoped_ptr<DistillerPage>(new DistillerPageWebContents(
+ return std::unique_ptr<DistillerPage>(new DistillerPageWebContents(
browser_context_, render_view_size,
- scoped_ptr<SourcePageHandleWebContents>()));
+ std::unique_ptr<SourcePageHandleWebContents>()));
}
-scoped_ptr<DistillerPage>
+std::unique_ptr<DistillerPage>
DistillerPageWebContentsFactory::CreateDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) const {
+ std::unique_ptr<SourcePageHandle> handle) const {
DCHECK(browser_context_);
- scoped_ptr<SourcePageHandleWebContents> web_contents_handle =
- scoped_ptr<SourcePageHandleWebContents>(
+ std::unique_ptr<SourcePageHandleWebContents> web_contents_handle =
+ std::unique_ptr<SourcePageHandleWebContents>(
static_cast<SourcePageHandleWebContents*>(handle.release()));
- return scoped_ptr<DistillerPage>(new DistillerPageWebContents(
+ return std::unique_ptr<DistillerPage>(new DistillerPageWebContents(
browser_context_, gfx::Size(), std::move(web_contents_handle)));
}
DistillerPageWebContents::DistillerPageWebContents(
content::BrowserContext* browser_context,
const gfx::Size& render_view_size,
- scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle)
+ std::unique_ptr<SourcePageHandleWebContents> optional_web_contents_handle)
: state_(IDLE),
source_page_handle_(nullptr),
browser_context_(browser_context),
@@ -143,7 +145,7 @@ gfx::Size DistillerPageWebContents::GetSizeForNewRenderView(
// in the executed domdistiller.js won't be 0.
if (size.IsEmpty()) {
DVLOG(1) << "Using fullscreen as default RenderView size";
- size = gfx::Screen::GetScreen()->GetPrimaryDisplay().size();
+ size = display::Screen::GetScreen()->GetPrimaryDisplay().size();
}
return size;
}
@@ -166,7 +168,7 @@ void DistillerPageWebContents::DidFailLoad(
content::WebContentsObserver::Observe(NULL);
DCHECK(state_ == LOADING_PAGE || state_ == EXECUTING_JAVASCRIPT);
state_ = PAGELOAD_FAILED;
- scoped_ptr<base::Value> empty = base::Value::CreateNullValue();
+ std::unique_ptr<base::Value> empty = base::Value::CreateNullValue();
OnWebContentsDistillationDone(GURL(), base::TimeTicks(), empty.get());
}
}
diff --git a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.h b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.h
index c4d5414a9e9..56883d134aa 100644
--- a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.h
+++ b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents.h
@@ -5,10 +5,10 @@
#ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_H_
#define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "components/dom_distiller/core/distiller_page.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
@@ -39,10 +39,10 @@ class DistillerPageWebContentsFactory : public DistillerPageFactory {
: DistillerPageFactory(), browser_context_(browser_context) {}
~DistillerPageWebContentsFactory() override {}
- scoped_ptr<DistillerPage> CreateDistillerPage(
+ std::unique_ptr<DistillerPage> CreateDistillerPage(
const gfx::Size& render_view_size) const override;
- scoped_ptr<DistillerPage> CreateDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) const override;
+ std::unique_ptr<DistillerPage> CreateDistillerPageWithHandle(
+ std::unique_ptr<SourcePageHandle> handle) const override;
private:
content::BrowserContext* browser_context_;
@@ -52,10 +52,10 @@ class DistillerPageWebContents : public DistillerPage,
public content::WebContentsDelegate,
public content::WebContentsObserver {
public:
- DistillerPageWebContents(
- content::BrowserContext* browser_context,
- const gfx::Size& render_view_size,
- scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle);
+ DistillerPageWebContents(content::BrowserContext* browser_context,
+ const gfx::Size& render_view_size,
+ std::unique_ptr<SourcePageHandleWebContents>
+ optional_web_contents_handle);
~DistillerPageWebContents() override;
// content::WebContentsDelegate implementation.
@@ -110,7 +110,7 @@ class DistillerPageWebContents : public DistillerPage,
// The JavaScript to inject to extract content.
std::string script_;
- scoped_ptr<SourcePageHandleWebContents> source_page_handle_;
+ std::unique_ptr<SourcePageHandleWebContents> source_page_handle_;
content::BrowserContext* browser_context_;
gfx::Size render_view_size_;
diff --git a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc
index bc52b01e54c..606843ccd02 100644
--- a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc
+++ b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc
@@ -104,7 +104,7 @@ class DistillerPageWebContentsTest : public ContentBrowserTest {
void OnPageDistillationFinished(
base::Closure quit_closure,
- scoped_ptr<proto::DomDistillerResult> distiller_result,
+ std::unique_ptr<proto::DomDistillerResult> distiller_result,
bool distillation_successful) {
distiller_result_ = std::move(distiller_result);
quit_closure.Run();
@@ -148,8 +148,8 @@ class DistillerPageWebContentsTest : public ContentBrowserTest {
bool wait_for_document_loaded);
DistillerPageWebContents* distiller_page_;
- scoped_ptr<proto::DomDistillerResult> distiller_result_;
- scoped_ptr<base::Value> js_result_;
+ std::unique_ptr<proto::DomDistillerResult> distiller_result_;
+ std::unique_ptr<base::Value> js_result_;
};
// Use this class to be able to leak the WebContents, which is needed for when
@@ -159,7 +159,7 @@ class TestDistillerPageWebContents : public DistillerPageWebContents {
TestDistillerPageWebContents(
content::BrowserContext* browser_context,
const gfx::Size& render_view_size,
- scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle,
+ std::unique_ptr<SourcePageHandleWebContents> optional_web_contents_handle,
bool expect_new_web_contents)
: DistillerPageWebContents(browser_context,
render_view_size,
@@ -184,7 +184,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, BasicDistillationWorks) {
DistillerPageWebContents distiller_page(
shell()->web_contents()->GetBrowserContext(),
shell()->web_contents()->GetContainerBounds().size(),
- scoped_ptr<SourcePageHandleWebContents>());
+ std::unique_ptr<SourcePageHandleWebContents>());
distiller_page_ = &distiller_page;
base::RunLoop run_loop;
@@ -204,7 +204,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) {
DistillerPageWebContents distiller_page(
shell()->web_contents()->GetBrowserContext(),
shell()->web_contents()->GetContainerBounds().size(),
- scoped_ptr<SourcePageHandleWebContents>());
+ std::unique_ptr<SourcePageHandleWebContents>());
distiller_page_ = &distiller_page;
base::RunLoop run_loop;
@@ -222,7 +222,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) {
DistillerPageWebContents distiller_page(
shell()->web_contents()->GetBrowserContext(),
shell()->web_contents()->GetContainerBounds().size(),
- scoped_ptr<SourcePageHandleWebContents>());
+ std::unique_ptr<SourcePageHandleWebContents>());
distiller_page_ = &distiller_page;
base::RunLoop run_loop;
@@ -241,7 +241,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeVideos) {
DistillerPageWebContents distiller_page(
shell()->web_contents()->GetBrowserContext(),
shell()->web_contents()->GetContainerBounds().size(),
- scoped_ptr<SourcePageHandleWebContents>());
+ std::unique_ptr<SourcePageHandleWebContents>());
distiller_page_ = &distiller_page;
base::RunLoop run_loop;
@@ -264,7 +264,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) {
DistillerPageWebContents distiller_page(
shell()->web_contents()->GetBrowserContext(),
shell()->web_contents()->GetContainerBounds().size(),
- scoped_ptr<SourcePageHandleWebContents>());
+ std::unique_ptr<SourcePageHandleWebContents>());
distiller_page_ = &distiller_page;
// visble_style.html and invisible_style.html only differ by the visibility
@@ -356,7 +356,7 @@ void DistillerPageWebContentsTest::RunUseCurrentWebContentsTest(
std::string());
url_loaded_runner.Run();
- scoped_ptr<SourcePageHandleWebContents> source_page_handle(
+ std::unique_ptr<SourcePageHandleWebContents> source_page_handle(
new SourcePageHandleWebContents(current_web_contents, false));
TestDistillerPageWebContents distiller_page(
@@ -393,7 +393,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
std::string());
url_loaded_runner.Run();
- scoped_ptr<SourcePageHandleWebContents> source_page_handle(
+ std::unique_ptr<SourcePageHandleWebContents> source_page_handle(
new SourcePageHandleWebContents(current_web_contents, false));
TestDistillerPageWebContents* distiller_page(new TestDistillerPageWebContents(
@@ -419,7 +419,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) {
DistillerPageWebContents distiller_page(
shell()->web_contents()->GetBrowserContext(),
shell()->web_contents()->GetContainerBounds().size(),
- scoped_ptr<SourcePageHandleWebContents>());
+ std::unique_ptr<SourcePageHandleWebContents>());
distiller_page_ = &distiller_page;
base::RunLoop run_loop;
@@ -472,14 +472,14 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT);
{ // Test zero pages.
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get());
EXPECT_THAT(js, HasSubstr(no_content));
}
{ // Test empty content.
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
(*(article_proto->add_pages())).set_html("");
std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get());
diff --git a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc
index 3ce7d160b64..12f679d322d 100644
--- a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc
+++ b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc
@@ -4,14 +4,14 @@
#include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h"
+#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/memory/ref_counted_memory.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/metrics/user_metrics.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -157,6 +157,15 @@ void DomDistillerViewerSource::RequestViewerHandle::DidFinishLoad(
return;
}
+ int64_t start_time_ms = url_utils::GetTimeFromDistillerUrl(validated_url);
+ if (start_time_ms > 0) {
+ base::TimeTicks start_time =
+ base::TimeDelta::FromMilliseconds(start_time_ms) + base::TimeTicks();
+ base::TimeDelta latency = base::TimeTicks::Now() - start_time;
+
+ UMA_HISTOGRAM_TIMES("DomDistiller.Time.ViewerLoading", latency);
+ }
+
// No SendJavaScript() calls allowed before |buffer_| is run and cleared.
waiting_for_page_ready_ = false;
if (!buffer_.empty()) {
@@ -169,7 +178,7 @@ void DomDistillerViewerSource::RequestViewerHandle::DidFinishLoad(
DomDistillerViewerSource::DomDistillerViewerSource(
DomDistillerServiceInterface* dom_distiller_service,
const std::string& scheme,
- scoped_ptr<DistillerUIHandle> ui_handle)
+ std::unique_ptr<DistillerUIHandle> ui_handle)
: scheme_(scheme),
dom_distiller_service_(dom_distiller_service),
distiller_ui_handle_(std::move(ui_handle)) {}
@@ -221,7 +230,7 @@ void DomDistillerViewerSource::StartDataRequest(
RequestViewerHandle* request_viewer_handle =
new RequestViewerHandle(web_contents, scheme_, path_after_query_separator,
dom_distiller_service_->GetDistilledPagePrefs());
- scoped_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest(
+ std::unique_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest(
dom_distiller_service_, path, request_viewer_handle,
web_contents->GetContainerBounds().size());
@@ -239,7 +248,7 @@ void DomDistillerViewerSource::StartDataRequest(
distiller_ui_handle_.get()));
// Tell the renderer that this is currently a distilled page.
- DistillerPageNotifierServicePtr page_notifier_service;
+ mojom::DistillerPageNotifierServicePtr page_notifier_service;
render_frame_host->GetServiceRegistry()->ConnectToRemoteService(
mojo::GetProxy(&page_notifier_service));
DCHECK(page_notifier_service);
diff --git a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.h b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.h
index 6b5ae35be4c..a4ec2fabdd6 100644
--- a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.h
+++ b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.h
@@ -5,11 +5,11 @@
#ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DOM_DISTILLER_VIEWER_SOURCE_H_
#define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DOM_DISTILLER_VIEWER_SOURCE_H_
+#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "components/dom_distiller/content/browser/distiller_ui_handle.h"
#include "content/public/browser/url_data_source.h"
@@ -23,10 +23,9 @@ class ViewRequestDelegate;
// Serves HTML and resources for viewing distilled articles.
class DomDistillerViewerSource : public content::URLDataSource {
public:
- DomDistillerViewerSource(
- DomDistillerServiceInterface* dom_distiller_service,
- const std::string& scheme,
- scoped_ptr<DistillerUIHandle> ui_handle);
+ DomDistillerViewerSource(DomDistillerServiceInterface* dom_distiller_service,
+ const std::string& scheme,
+ std::unique_ptr<DistillerUIHandle> ui_handle);
~DomDistillerViewerSource() override;
class RequestViewerHandle;
@@ -57,7 +56,7 @@ class DomDistillerViewerSource : public content::URLDataSource {
// An object for accessing chrome-specific UI controls including external
// feedback and opening the distiller settings.
- scoped_ptr<DistillerUIHandle> distiller_ui_handle_;
+ std::unique_ptr<DistillerUIHandle> distiller_ui_handle_;
DISALLOW_COPY_AND_ASSIGN(DomDistillerViewerSource);
};
diff --git a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source_unittest.cc b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source_unittest.cc
index 883140ce96d..df1fa73cc9f 100644
--- a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source_unittest.cc
+++ b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source_unittest.cc
@@ -18,7 +18,7 @@ class DomDistillerViewerSourceTest : public testing::Test {
}
protected:
- scoped_ptr<DomDistillerViewerSource> source_;
+ std::unique_ptr<DomDistillerViewerSource> source_;
};
TEST_F(DomDistillerViewerSourceTest, TestMimeType) {
diff --git a/chromium/components/dom_distiller/content/common/BUILD.gn b/chromium/components/dom_distiller/content/common/BUILD.gn
index 4fef7bc9bfc..57cbc89375a 100644
--- a/chromium/components/dom_distiller/content/common/BUILD.gn
+++ b/chromium/components/dom_distiller/content/common/BUILD.gn
@@ -4,24 +4,10 @@
import("//mojo/public/tools/bindings/mojom.gni")
-# GYP version: components/dom_distiller.gypi:dom_distiller_content_common
-source_set("common") {
- sources = [
- "distiller_messages.cc",
- "distiller_messages.h",
- ]
-
- deps = [
- "//base",
- "//content/public/common",
- "//ipc",
- "//url",
- ]
-}
-
# GYP version: components/dom_distiller.gypi:dom_distiller_mojo_bindings
mojom("mojo_bindings") {
sources = [
+ "distillability_service.mojom",
"distiller_javascript_service.mojom",
"distiller_page_notifier_service.mojom",
]
diff --git a/chromium/components/dom_distiller/content/common/OWNERS b/chromium/components/dom_distiller/content/common/OWNERS
new file mode 100644
index 00000000000..9e621796752
--- /dev/null
+++ b/chromium/components/dom_distiller/content/common/OWNERS
@@ -0,0 +1,13 @@
+# Changes to Mojo interfaces require a security review to avoid
+# introducing new sandbox escapes.
+per-file *.mojom=set noparent
+per-file *.mojom=dcheng@chromium.org
+per-file *.mojom=inferno@chromium.org
+per-file *.mojom=jln@chromium.org
+per-file *.mojom=jschuh@chromium.org
+per-file *.mojom=kenrb@chromium.org
+per-file *.mojom=mkwst@chromium.org
+per-file *.mojom=nasko@chromium.org
+per-file *.mojom=palmer@chromium.org
+per-file *.mojom=tsepez@chromium.org
+per-file *.mojom=wfh@chromium.org
diff --git a/chromium/components/dom_distiller/content/common/distillability_service.mojom b/chromium/components/dom_distiller/content/common/distillability_service.mojom
new file mode 100644
index 00000000000..7c2475fdbee
--- /dev/null
+++ b/chromium/components/dom_distiller/content/common/distillability_service.mojom
@@ -0,0 +1,11 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module dom_distiller.mojom;
+
+// This service is implemented in the browser process and is used by the
+// renderer to notify the Reader Mode UI if a page is distillable.
+interface DistillabilityService {
+ NotifyIsDistillable(bool page_is_distillable, bool is_last_update);
+};
diff --git a/chromium/components/dom_distiller/content/common/distiller_javascript_service.mojom b/chromium/components/dom_distiller/content/common/distiller_javascript_service.mojom
index 9bf73ffb4ff..5e2dfa9e366 100644
--- a/chromium/components/dom_distiller/content/common/distiller_javascript_service.mojom
+++ b/chromium/components/dom_distiller/content/common/distiller_javascript_service.mojom
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-module dom_distiller;
+module dom_distiller.mojom;
// This service is implemented by the browser process and is used by the
// renderer when a distiller JavaScript function is called.
diff --git a/chromium/components/dom_distiller/content/common/distiller_messages.cc b/chromium/components/dom_distiller/content/common/distiller_messages.cc
deleted file mode 100644
index e336f9efc30..00000000000
--- a/chromium/components/dom_distiller/content/common/distiller_messages.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Get basic type definitions.
-#define IPC_MESSAGE_IMPL
-#include "components/dom_distiller/content/common/distiller_messages.h"
-
-// Generate constructors.
-#include "ipc/struct_constructor_macros.h"
-#include "components/dom_distiller/content/common/distiller_messages.h"
-
-// Generate destructors.
-#include "ipc/struct_destructor_macros.h"
-#include "components/dom_distiller/content/common/distiller_messages.h"
-
-// Generate param traits write methods.
-#include "ipc/param_traits_write_macros.h"
-namespace IPC {
-#include "components/dom_distiller/content/common/distiller_messages.h"
-} // namespace IPC
-
-// Generate param traits read methods.
-#include "ipc/param_traits_read_macros.h"
-namespace IPC {
-#include "components/dom_distiller/content/common/distiller_messages.h"
-} // namespace IPC
-
-// Generate param traits log methods.
-#include "ipc/param_traits_log_macros.h"
-namespace IPC {
-#include "components/dom_distiller/content/common/distiller_messages.h"
-} // namespace IPC
diff --git a/chromium/components/dom_distiller/content/common/distiller_messages.h b/chromium/components/dom_distiller/content/common/distiller_messages.h
deleted file mode 100644
index 84c40818dc8..00000000000
--- a/chromium/components/dom_distiller/content/common/distiller_messages.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Multiply-included message file, hence no include guard.
-
-#include <string>
-#include <vector>
-
-#include "base/strings/string16.h"
-#include "content/public/common/common_param_traits.h"
-#include "content/public/common/common_param_traits_macros.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_message_utils.h"
-
-#define IPC_MESSAGE_START DistillerMsgStart
-
-// Whether a page is suitable for DOM distiller to process.
-IPC_MESSAGE_ROUTED2(FrameHostMsg_Distillability,
- bool /* is_distillable */,
- bool /* is_last_update */)
diff --git a/chromium/components/dom_distiller/content/common/distiller_page_notifier_service.mojom b/chromium/components/dom_distiller/content/common/distiller_page_notifier_service.mojom
index 3d68de4a55a..12649c2746a 100644
--- a/chromium/components/dom_distiller/content/common/distiller_page_notifier_service.mojom
+++ b/chromium/components/dom_distiller/content/common/distiller_page_notifier_service.mojom
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-module dom_distiller;
+module dom_distiller.mojom;
// This service is implemented in the renderer process and is used by the
// browser to notify a renderer that is page is a distiller page.
diff --git a/chromium/components/dom_distiller/content/renderer/BUILD.gn b/chromium/components/dom_distiller/content/renderer/BUILD.gn
index a442dec9d93..3ff8df4fcfa 100644
--- a/chromium/components/dom_distiller/content/renderer/BUILD.gn
+++ b/chromium/components/dom_distiller/content/renderer/BUILD.gn
@@ -20,7 +20,6 @@ static_library("renderer") {
]
deps = [
"//base",
- "//components/dom_distiller/content/common",
"//components/dom_distiller/content/common:mojo_bindings",
"//components/dom_distiller/core",
"//content/public/common",
diff --git a/chromium/components/dom_distiller/content/renderer/distillability_agent.cc b/chromium/components/dom_distiller/content/renderer/distillability_agent.cc
index 6caeaf7b9b2..f0ae4b511a4 100644
--- a/chromium/components/dom_distiller/content/renderer/distillability_agent.cc
+++ b/chromium/components/dom_distiller/content/renderer/distillability_agent.cc
@@ -3,13 +3,15 @@
// found in the LICENSE file.
#include "base/metrics/histogram.h"
+#include "base/strings/string_util.h"
-#include "components/dom_distiller/content/common/distiller_messages.h"
+#include "components/dom_distiller/content/common/distillability_service.mojom.h"
#include "components/dom_distiller/content/renderer/distillability_agent.h"
#include "components/dom_distiller/core/distillable_page_detector.h"
#include "components/dom_distiller/core/experiments.h"
#include "components/dom_distiller/core/page_features.h"
#include "components/dom_distiller/core/url_utils.h"
+#include "content/public/common/service_registry.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/WebKit/public/platform/WebDistillability.h"
@@ -171,11 +173,15 @@ void DistillabilityAgent::DidMeaningfulLayout(
if (!NeedToUpdate(is_loaded)) return;
bool is_last = IsLast(is_loaded);
- Send(new FrameHostMsg_Distillability(routing_id(),
- IsDistillablePage(doc, is_last), is_last));
+ // Connect to Mojo service on browser to notify page distillability.
+ mojom::DistillabilityServicePtr distillability_service;
+ render_frame()->GetServiceRegistry()->ConnectToRemoteService(
+ mojo::GetProxy(&distillability_service));
+ DCHECK(distillability_service);
+ distillability_service->NotifyIsDistillable(
+ IsDistillablePage(doc, is_last), is_last);
}
-
DistillabilityAgent::~DistillabilityAgent() {}
} // namespace dom_distiller
diff --git a/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc b/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc
index a9109f7663c..a95088b2d10 100644
--- a/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc
+++ b/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc
@@ -31,10 +31,11 @@ void DistillerJsRenderFrameObserver::DidStartProvisionalLoad() {
void DistillerJsRenderFrameObserver::DidFinishLoad() {
// If no message about the distilled page was received at this point, there
- // will not be one; remove the DistillerPageNotifierService from the registry.
+ // will not be one; remove the mojom::DistillerPageNotifierService from the
+ // registry.
render_frame()
->GetServiceRegistry()
- ->RemoveService<DistillerPageNotifierService>();
+ ->RemoveService<mojom::DistillerPageNotifierService>();
}
void DistillerJsRenderFrameObserver::DidCreateScriptContext(
@@ -57,7 +58,7 @@ void DistillerJsRenderFrameObserver::RegisterMojoService() {
}
void DistillerJsRenderFrameObserver::CreateDistillerPageNotifierService(
- mojo::InterfaceRequest<DistillerPageNotifierService> request) {
+ mojo::InterfaceRequest<mojom::DistillerPageNotifierService> request) {
// This is strongly bound to and owned by the pipe.
new DistillerPageNotifierServiceImpl(this, std::move(request));
}
diff --git a/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h b/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h
index 6589e395037..12ad0bc5328 100644
--- a/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h
+++ b/chromium/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h
@@ -40,7 +40,7 @@ class DistillerJsRenderFrameObserver : public content::RenderFrameObserver {
private:
void CreateDistillerPageNotifierService(
- mojo::InterfaceRequest<DistillerPageNotifierService> request);
+ mojo::InterfaceRequest<mojom::DistillerPageNotifierService> request);
// The isolated world that the distiller object should be written to.
int distiller_isolated_world_id_;
@@ -48,10 +48,10 @@ class DistillerJsRenderFrameObserver : public content::RenderFrameObserver {
// Track if the current page is distilled. This is needed for testing.
bool is_distiller_page_;
- //mojo::StrongBinding<DistillerPageNotifierService> binding_;
+ // mojo::StrongBinding<mojom::DistillerPageNotifierService> binding_;
// Handle to "distiller" JavaScript object functionality.
- scoped_ptr<DistillerNativeJavaScript> native_javascript_handle_;
+ std::unique_ptr<DistillerNativeJavaScript> native_javascript_handle_;
base::WeakPtrFactory<DistillerJsRenderFrameObserver> weak_factory_;
};
diff --git a/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.cc b/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.cc
index 14a34115481..e74c955938d 100644
--- a/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.cc
+++ b/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.cc
@@ -53,24 +53,21 @@ void DistillerNativeJavaScript::AddJavaScriptObjectToFrame(
// wrapper function for binding. Note that calling distiller_js_service.get()
// does not transfer ownership of the interface.
BindFunctionToObject(
- distiller_obj,
- "sendFeedback",
+ distiller_obj, "sendFeedback",
base::Bind(
- &DistillerJavaScriptService::HandleDistillerFeedbackCall,
+ &mojom::DistillerJavaScriptService::HandleDistillerFeedbackCall,
base::Unretained(distiller_js_service_.get())));
BindFunctionToObject(
- distiller_obj,
- "closePanel",
+ distiller_obj, "closePanel",
base::Bind(
- &DistillerJavaScriptService::HandleDistillerClosePanelCall,
+ &mojom::DistillerJavaScriptService::HandleDistillerClosePanelCall,
base::Unretained(distiller_js_service_.get())));
BindFunctionToObject(
- distiller_obj,
- "openSettings",
+ distiller_obj, "openSettings",
base::Bind(
- &DistillerJavaScriptService::HandleDistillerOpenSettingsCall,
+ &mojom::DistillerJavaScriptService::HandleDistillerOpenSettingsCall,
base::Unretained(distiller_js_service_.get())));
}
diff --git a/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.h b/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.h
index c1904786e6f..b8b608314f5 100644
--- a/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.h
+++ b/chromium/components/dom_distiller/content/renderer/distiller_native_javascript.h
@@ -38,7 +38,7 @@ class DistillerNativeJavaScript {
std::string DistillerEcho(const std::string& message);
content::RenderFrame* render_frame_;
- DistillerJavaScriptServicePtr distiller_js_service_;
+ mojom::DistillerJavaScriptServicePtr distiller_js_service_;
};
// static
diff --git a/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.cc b/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.cc
index 833762432e6..d7f1983e7c4 100644
--- a/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.cc
+++ b/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.cc
@@ -13,7 +13,7 @@ namespace dom_distiller {
DistillerPageNotifierServiceImpl::DistillerPageNotifierServiceImpl(
DistillerJsRenderFrameObserver* observer,
- mojo::InterfaceRequest<DistillerPageNotifierService> request)
+ mojo::InterfaceRequest<mojom::DistillerPageNotifierService> request)
: binding_(this, std::move(request)), distiller_js_observer_(observer) {}
void DistillerPageNotifierServiceImpl::NotifyIsDistillerPage() {
diff --git a/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.h b/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.h
index 35eebb0e557..3cfc393c98f 100644
--- a/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.h
+++ b/chromium/components/dom_distiller/content/renderer/distiller_page_notifier_service_impl.h
@@ -14,22 +14,24 @@ namespace dom_distiller {
class DistillerJsRenderFrameObserver;
-// DistillerPageNotifierService is responsible for listening to the browser for
+// mojom::DistillerPageNotifierService is responsible for listening to the
+// browser for
// messages about if a page is a distiller page. No message is received if the
// page is not a distiller page. This service should be removed from the
// registry once the page is done loading.
-class DistillerPageNotifierServiceImpl : public DistillerPageNotifierService {
+class DistillerPageNotifierServiceImpl
+ : public mojom::DistillerPageNotifierService {
public:
explicit DistillerPageNotifierServiceImpl(
DistillerJsRenderFrameObserver* observer,
- mojo::InterfaceRequest<DistillerPageNotifierService> request);
+ mojo::InterfaceRequest<mojom::DistillerPageNotifierService> request);
~DistillerPageNotifierServiceImpl() override;
// Implementation of mojo interface DistillerPageNotifierService.
void NotifyIsDistillerPage() override;
private:
- mojo::StrongBinding<DistillerPageNotifierService> binding_;
+ mojo::StrongBinding<mojom::DistillerPageNotifierService> binding_;
DistillerJsRenderFrameObserver* distiller_js_observer_;
};
diff --git a/chromium/components/dom_distiller/core/BUILD.gn b/chromium/components/dom_distiller/core/BUILD.gn
index 7c6dbb620a5..8406d9b8d9f 100644
--- a/chromium/components/dom_distiller/core/BUILD.gn
+++ b/chromium/components/dom_distiller/core/BUILD.gn
@@ -111,6 +111,19 @@ source_set("test_support") {
]
}
+bundle_data("unit_tests_bundle_data") {
+ visibility = [ ":unit_tests" ]
+ testonly = true
+ sources = [
+ "//components/test/data/dom_distiller/core_features.json",
+ "//components/test/data/dom_distiller/derived_features.json",
+ ]
+ outputs = [
+ "{{bundle_resources_dir}}/" +
+ "{{source_root_relative_dir}}/{{source_file_part}}",
+ ]
+}
+
source_set("unit_tests") {
testonly = true
sources = [
@@ -133,6 +146,7 @@ source_set("unit_tests") {
deps = [
":core",
":test_support",
+ ":unit_tests_bundle_data",
"//base",
"//components/leveldb_proto:test_support",
"//components/pref_registry:test_support",
diff --git a/chromium/components/dom_distiller/core/article_attachments_data.cc b/chromium/components/dom_distiller/core/article_attachments_data.cc
index 8174c48cdab..c888c00271b 100644
--- a/chromium/components/dom_distiller/core/article_attachments_data.cc
+++ b/chromium/components/dom_distiller/core/article_attachments_data.cc
@@ -16,10 +16,11 @@ syncer::AttachmentIdList GetAttachmentIds(
return ids;
}
-scoped_ptr<ArticleAttachmentsData> ArticleAttachmentsData::GetFromAttachmentMap(
+std::unique_ptr<ArticleAttachmentsData>
+ArticleAttachmentsData::GetFromAttachmentMap(
const sync_pb::ArticleAttachments& attachments_key,
const syncer::AttachmentMap& attachment_map) {
- scoped_ptr<ArticleAttachmentsData> data(new ArticleAttachmentsData);
+ std::unique_ptr<ArticleAttachmentsData> data(new ArticleAttachmentsData);
syncer::AttachmentMap::const_iterator iter =
attachment_map.find(syncer::AttachmentId::CreateFromProto(
attachments_key.distilled_article()));
diff --git a/chromium/components/dom_distiller/core/article_attachments_data.h b/chromium/components/dom_distiller/core/article_attachments_data.h
index c25df29bf9a..d5410c29700 100644
--- a/chromium/components/dom_distiller/core/article_attachments_data.h
+++ b/chromium/components/dom_distiller/core/article_attachments_data.h
@@ -5,9 +5,9 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_
#define COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
#include "sync/api/attachments/attachment.h"
#include "sync/protocol/article_specifics.pb.h"
@@ -24,7 +24,7 @@ namespace dom_distiller {
// be rather opaque.
class ArticleAttachmentsData {
public:
- static scoped_ptr<ArticleAttachmentsData> GetFromAttachmentMap(
+ static std::unique_ptr<ArticleAttachmentsData> GetFromAttachmentMap(
const sync_pb::ArticleAttachments& attachments_key,
const syncer::AttachmentMap& attachment_map);
diff --git a/chromium/components/dom_distiller/core/css/distilledpage.css b/chromium/components/dom_distiller/core/css/distilledpage.css
index c2ef269866f..4cda4e7eba7 100644
--- a/chromium/components/dom_distiller/core/css/distilledpage.css
+++ b/chromium/components/dom_distiller/core/css/distilledpage.css
@@ -363,7 +363,7 @@ video {
img {
display: block;
height: auto;
- margin: 0.6rem auto 0.4rem 0;
+ margin: 0.6rem auto 0.4rem auto;
}
/* TODO(nyquist): set these classes directly in the dom distiller. */
diff --git a/chromium/components/dom_distiller/core/distillable_page_detector.cc b/chromium/components/dom_distiller/core/distillable_page_detector.cc
index 5c2a7ee0125..f116546ff5e 100644
--- a/chromium/components/dom_distiller/core/distillable_page_detector.cc
+++ b/chromium/components/dom_distiller/core/distillable_page_detector.cc
@@ -20,7 +20,7 @@ const DistillablePageDetector* DistillablePageDetector::GetDefault() {
ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_DISTILLABLE_PAGE_SERIALIZED_MODEL)
.as_string();
- scoped_ptr<AdaBoostProto> proto(new AdaBoostProto);
+ std::unique_ptr<AdaBoostProto> proto(new AdaBoostProto);
CHECK(proto->ParseFromString(serialized_proto));
detector = new DistillablePageDetector(std::move(proto));
}
@@ -34,7 +34,7 @@ const DistillablePageDetector* DistillablePageDetector::GetNewModel() {
ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_DISTILLABLE_PAGE_SERIALIZED_MODEL_NEW)
.as_string();
- scoped_ptr<AdaBoostProto> proto(new AdaBoostProto);
+ std::unique_ptr<AdaBoostProto> proto(new AdaBoostProto);
CHECK(proto->ParseFromString(serialized_proto));
detector = new DistillablePageDetector(std::move(proto));
}
@@ -48,7 +48,7 @@ const DistillablePageDetector* DistillablePageDetector::GetLongPageModel() {
ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_LONG_PAGE_SERIALIZED_MODEL)
.as_string();
- scoped_ptr<AdaBoostProto> proto(new AdaBoostProto);
+ std::unique_ptr<AdaBoostProto> proto(new AdaBoostProto);
CHECK(proto->ParseFromString(serialized_proto));
detector = new DistillablePageDetector(std::move(proto));
}
@@ -56,7 +56,7 @@ const DistillablePageDetector* DistillablePageDetector::GetLongPageModel() {
}
DistillablePageDetector::DistillablePageDetector(
- scoped_ptr<AdaBoostProto> proto)
+ std::unique_ptr<AdaBoostProto> proto)
: proto_(std::move(proto)), threshold_(0.0) {
CHECK(proto_->num_stumps() == proto_->stump_size());
for (int i = 0; i < proto_->num_stumps(); ++i) {
diff --git a/chromium/components/dom_distiller/core/distillable_page_detector.h b/chromium/components/dom_distiller/core/distillable_page_detector.h
index 893945acc44..78efdd56e2b 100644
--- a/chromium/components/dom_distiller/core/distillable_page_detector.h
+++ b/chromium/components/dom_distiller/core/distillable_page_detector.h
@@ -5,10 +5,10 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_
#define COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_
+#include <memory>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "components/dom_distiller/core/proto/adaboost.pb.h"
namespace dom_distiller {
@@ -22,7 +22,7 @@ class DistillablePageDetector {
static const DistillablePageDetector* GetDefault();
static const DistillablePageDetector* GetNewModel();
static const DistillablePageDetector* GetLongPageModel();
- explicit DistillablePageDetector(scoped_ptr<AdaBoostProto> proto);
+ explicit DistillablePageDetector(std::unique_ptr<AdaBoostProto> proto);
~DistillablePageDetector();
// Returns true if the model classifies the vector of features as a
@@ -32,7 +32,7 @@ class DistillablePageDetector {
double Score(const std::vector<double>& features) const;
double GetThreshold() const;
private:
- scoped_ptr<AdaBoostProto> proto_;
+ std::unique_ptr<AdaBoostProto> proto_;
double threshold_;
DISALLOW_COPY_AND_ASSIGN(DistillablePageDetector);
};
diff --git a/chromium/components/dom_distiller/core/distillable_page_detector_unittest.cc b/chromium/components/dom_distiller/core/distillable_page_detector_unittest.cc
index 835f8ea6096..fc51fc968c5 100644
--- a/chromium/components/dom_distiller/core/distillable_page_detector_unittest.cc
+++ b/chromium/components/dom_distiller/core/distillable_page_detector_unittest.cc
@@ -4,6 +4,7 @@
#include "components/dom_distiller/core/distillable_page_detector.h"
+#include "base/memory/ptr_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace dom_distiller {
@@ -21,7 +22,7 @@ class Builder {
return *this;
}
- scoped_ptr<DistillablePageDetector> Build() {
+ std::unique_ptr<DistillablePageDetector> Build() {
int num_features = 0;
for (int i = 0; i < proto_.stump_size(); ++i) {
num_features =
@@ -29,8 +30,8 @@ class Builder {
}
proto_.set_num_features(num_features);
proto_.set_num_stumps(proto_.stump_size());
- return make_scoped_ptr(new DistillablePageDetector(
- make_scoped_ptr(new AdaBoostProto(proto_))));
+ return base::WrapUnique(new DistillablePageDetector(
+ base::WrapUnique(new AdaBoostProto(proto_))));
}
private:
@@ -40,7 +41,7 @@ class Builder {
}
TEST(DomDistillerDistillablePageDetectorTest, TestCalculateThreshold) {
- scoped_ptr<DistillablePageDetector> detector =
+ std::unique_ptr<DistillablePageDetector> detector =
Builder().Stump(0, 1.0, 1.0).Stump(0, 1.4, 2.0).Build();
EXPECT_DOUBLE_EQ(1.5, detector->GetThreshold());
@@ -61,7 +62,7 @@ TEST(DomDistillerDistillablePageDetectorTest, TestCalculateThreshold) {
}
TEST(DomDistillerDistillablePageDetectorTest, TestScoreAndClassify) {
- scoped_ptr<DistillablePageDetector> detector =
+ std::unique_ptr<DistillablePageDetector> detector =
Builder().Stump(0, 1.0, 1.0).Stump(0, 1.4, 2.0).Build();
EXPECT_DOUBLE_EQ(1.5, detector->GetThreshold());
@@ -92,7 +93,7 @@ TEST(DomDistillerDistillablePageDetectorTest, TestScoreAndClassify) {
}
TEST(DomDistillerDistillablePageDetectorTest, TestScoreWrongNumberFeatures) {
- scoped_ptr<DistillablePageDetector> detector =
+ std::unique_ptr<DistillablePageDetector> detector =
Builder().Stump(0, 1.0, 1.0).Stump(0, 1.4, 2.0).Build();
EXPECT_DOUBLE_EQ(1.5, detector->GetThreshold());
diff --git a/chromium/components/dom_distiller/core/distilled_content_store.cc b/chromium/components/dom_distiller/core/distilled_content_store.cc
index e6885cbd10e..a2ae21ea3a5 100644
--- a/chromium/components/dom_distiller/core/distilled_content_store.cc
+++ b/chromium/components/dom_distiller/core/distilled_content_store.cc
@@ -4,7 +4,7 @@
#include "components/dom_distiller/core/distilled_content_store.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
namespace dom_distiller {
@@ -49,7 +49,7 @@ void InMemoryContentStore::LoadContent(
}
}
}
- scoped_ptr<DistilledArticleProto> distilled_article;
+ std::unique_ptr<DistilledArticleProto> distilled_article;
if (success) {
distilled_article.reset(new DistilledArticleProto(*it->second));
} else {
@@ -63,7 +63,7 @@ void InMemoryContentStore::LoadContent(
void InMemoryContentStore::InjectContent(const ArticleEntry& entry,
const DistilledArticleProto& proto) {
cache_.Put(entry.entry_id(),
- scoped_ptr<DistilledArticleProto, CacheDeletor>(
+ std::unique_ptr<DistilledArticleProto, CacheDeletor>(
new DistilledArticleProto(proto), CacheDeletor(this)));
AddUrlToIdMapping(entry, proto);
}
diff --git a/chromium/components/dom_distiller/core/distilled_content_store.h b/chromium/components/dom_distiller/core/distilled_content_store.h
index 3b17c2d3689..bbee232ad1d 100644
--- a/chromium/components/dom_distiller/core/distilled_content_store.h
+++ b/chromium/components/dom_distiller/core/distilled_content_store.h
@@ -5,13 +5,13 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_
#define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_
+#include <memory>
#include <string>
#include "base/bind.h"
#include "base/containers/hash_tables.h"
#include "base/containers/mru_cache.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "components/dom_distiller/core/article_entry.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
@@ -24,8 +24,9 @@ const int kDefaultMaxNumCachedEntries = 32;
// ArticleEntry.
class DistilledContentStore {
public:
- typedef base::Callback<
- void(bool /* success */, scoped_ptr<DistilledArticleProto>)> LoadCallback;
+ typedef base::Callback<void(bool /* success */,
+ std::unique_ptr<DistilledArticleProto>)>
+ LoadCallback;
typedef base::Callback<void(bool /* success */)> SaveCallback;
virtual void SaveContent(const ArticleEntry& entry,
@@ -77,7 +78,7 @@ class InMemoryContentStore : public DistilledContentStore {
void EraseUrlToIdMapping(const DistilledArticleProto& proto);
typedef base::MRUCache<std::string,
- scoped_ptr<DistilledArticleProto, CacheDeletor>>
+ std::unique_ptr<DistilledArticleProto, CacheDeletor>>
ContentMap;
typedef base::hash_map<std::string, std::string> UrlMap;
diff --git a/chromium/components/dom_distiller/core/distilled_content_store_unittest.cc b/chromium/components/dom_distiller/core/distilled_content_store_unittest.cc
index 648ab42d071..6a3ad46f420 100644
--- a/chromium/components/dom_distiller/core/distilled_content_store_unittest.cc
+++ b/chromium/components/dom_distiller/core/distilled_content_store_unittest.cc
@@ -53,7 +53,8 @@ DistilledArticleProto CreateDistilledArticleForEntry(
class InMemoryContentStoreTest : public testing::Test {
public:
- void OnLoadCallback(bool success, scoped_ptr<DistilledArticleProto> proto) {
+ void OnLoadCallback(bool success,
+ std::unique_ptr<DistilledArticleProto> proto) {
load_success_ = success;
loaded_proto_ = std::move(proto);
}
@@ -69,10 +70,10 @@ class InMemoryContentStoreTest : public testing::Test {
loaded_proto_.reset();
}
- scoped_ptr<InMemoryContentStore> store_;
+ std::unique_ptr<InMemoryContentStore> store_;
bool save_success_;
bool load_success_;
- scoped_ptr<DistilledArticleProto> loaded_proto_;
+ std::unique_ptr<DistilledArticleProto> loaded_proto_;
};
// Tests whether saving and then loading a single article works as expected.
diff --git a/chromium/components/dom_distiller/core/distilled_page_prefs.cc b/chromium/components/dom_distiller/core/distilled_page_prefs.cc
index f8735a8907e..35bf0944435 100644
--- a/chromium/components/dom_distiller/core/distilled_page_prefs.cc
+++ b/chromium/components/dom_distiller/core/distilled_page_prefs.cc
@@ -9,7 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
diff --git a/chromium/components/dom_distiller/core/distilled_page_prefs_unittests.cc b/chromium/components/dom_distiller/core/distilled_page_prefs_unittests.cc
index 9c871539ab3..b034255c2e4 100644
--- a/chromium/components/dom_distiller/core/distilled_page_prefs_unittests.cc
+++ b/chromium/components/dom_distiller/core/distilled_page_prefs_unittests.cc
@@ -54,8 +54,8 @@ class DistilledPagePrefsTest : public testing::Test {
distilled_page_prefs_.reset(new DistilledPagePrefs(pref_service_.get()));
}
- scoped_ptr<user_prefs::TestingPrefServiceSyncable> pref_service_;
- scoped_ptr<DistilledPagePrefs> distilled_page_prefs_;
+ std::unique_ptr<user_prefs::TestingPrefServiceSyncable> pref_service_;
+ std::unique_ptr<DistilledPagePrefs> distilled_page_prefs_;
private:
base::MessageLoop message_loop_;
diff --git a/chromium/components/dom_distiller/core/distiller.cc b/chromium/components/dom_distiller/core/distiller.cc
index 9ac44599986..f8605162e41 100644
--- a/chromium/components/dom_distiller/core/distiller.cc
+++ b/chromium/components/dom_distiller/core/distiller.cc
@@ -31,17 +31,17 @@ const size_t kMaxPagesInArticle = 32;
namespace dom_distiller {
DistillerFactoryImpl::DistillerFactoryImpl(
- scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory,
+ std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory,
const dom_distiller::proto::DomDistillerOptions& dom_distiller_options)
: distiller_url_fetcher_factory_(std::move(distiller_url_fetcher_factory)),
dom_distiller_options_(dom_distiller_options) {}
DistillerFactoryImpl::~DistillerFactoryImpl() {}
-scoped_ptr<Distiller> DistillerFactoryImpl::CreateDistillerForUrl(
+std::unique_ptr<Distiller> DistillerFactoryImpl::CreateDistillerForUrl(
const GURL& unused) {
// This default implementation has the same behavior for all URLs.
- scoped_ptr<DistillerImpl> distiller(new DistillerImpl(
+ std::unique_ptr<DistillerImpl> distiller(new DistillerImpl(
*distiller_url_fetcher_factory_, dom_distiller_options_));
return std::move(distiller);
}
@@ -100,7 +100,7 @@ DistillerImpl::DistilledPageData* DistillerImpl::GetPageAtIndex(size_t index)
}
void DistillerImpl::DistillPage(const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const DistillationFinishedCallback& finished_cb,
const DistillationUpdateCallback& update_cb) {
DCHECK(AreAllPagesFinished());
@@ -138,7 +138,7 @@ void DistillerImpl::DistillNextPage() {
void DistillerImpl::OnPageDistillationFinished(
int page_num,
const GURL& page_url,
- scoped_ptr<proto::DomDistillerResult> distiller_result,
+ std::unique_ptr<proto::DomDistillerResult> distiller_result,
bool distillation_successful) {
DCHECK(started_pages_index_.find(page_num) != started_pages_index_.end());
if (!distillation_successful) {
@@ -370,7 +370,7 @@ void DistillerImpl::RunDistillerCallbackIfDone() {
DCHECK(!finished_cb_.is_null());
if (AreAllPagesFinished()) {
bool first_page = true;
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
// Stitch the pages back into the article.
for (std::map<int, size_t>::iterator it = finished_pages_index_.begin();
diff --git a/chromium/components/dom_distiller/core/distiller.h b/chromium/components/dom_distiller/core/distiller.h
index ef0f8081494..9cd360ccfb3 100644
--- a/chromium/components/dom_distiller/core/distiller.h
+++ b/chromium/components/dom_distiller/core/distiller.h
@@ -8,13 +8,13 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "components/dom_distiller/core/article_distillation_update.h"
@@ -30,7 +30,7 @@ class DistillerImpl;
class Distiller {
public:
- typedef base::Callback<void(scoped_ptr<DistilledArticleProto>)>
+ typedef base::Callback<void(std::unique_ptr<DistilledArticleProto>)>
DistillationFinishedCallback;
typedef base::Callback<void(const ArticleDistillationUpdate&)>
DistillationUpdateCallback;
@@ -44,14 +44,14 @@ class Distiller {
// a distilled page is added and |finished_cb| will be invoked once
// distillation is completed.
virtual void DistillPage(const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const DistillationFinishedCallback& finished_cb,
const DistillationUpdateCallback& update_cb) = 0;
};
class DistillerFactory {
public:
- virtual scoped_ptr<Distiller> CreateDistillerForUrl(const GURL& url) = 0;
+ virtual std::unique_ptr<Distiller> CreateDistillerForUrl(const GURL& url) = 0;
virtual ~DistillerFactory() {}
};
@@ -59,13 +59,13 @@ class DistillerFactory {
class DistillerFactoryImpl : public DistillerFactory {
public:
DistillerFactoryImpl(
- scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory,
+ std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory,
const dom_distiller::proto::DomDistillerOptions& dom_distiller_options);
~DistillerFactoryImpl() override;
- scoped_ptr<Distiller> CreateDistillerForUrl(const GURL& url) override;
+ std::unique_ptr<Distiller> CreateDistillerForUrl(const GURL& url) override;
private:
- scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory_;
+ std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory_;
dom_distiller::proto::DomDistillerOptions dom_distiller_options_;
};
@@ -78,7 +78,7 @@ class DistillerImpl : public Distiller {
~DistillerImpl() override;
void DistillPage(const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const DistillationFinishedCallback& finished_cb,
const DistillationUpdateCallback& update_cb) override;
@@ -113,7 +113,7 @@ class DistillerImpl : public Distiller {
void OnPageDistillationFinished(
int page_num,
const GURL& page_url,
- scoped_ptr<proto::DomDistillerResult> distilled_page,
+ std::unique_ptr<proto::DomDistillerResult> distilled_page,
bool distillation_successful);
virtual void FetchImage(int page_num,
@@ -153,7 +153,7 @@ class DistillerImpl : public Distiller {
const ArticleDistillationUpdate CreateDistillationUpdate() const;
const DistillerURLFetcherFactory& distiller_url_fetcher_factory_;
- scoped_ptr<DistillerPage> distiller_page_;
+ std::unique_ptr<DistillerPage> distiller_page_;
dom_distiller::proto::DomDistillerOptions dom_distiller_options_;
DistillationFinishedCallback finished_cb_;
diff --git a/chromium/components/dom_distiller/core/distiller_page.cc b/chromium/components/dom_distiller/core/distiller_page.cc
index 826725a7cd7..fb115d8e8f7 100644
--- a/chromium/components/dom_distiller/core/distiller_page.cc
+++ b/chromium/components/dom_distiller/core/distiller_page.cc
@@ -14,7 +14,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "grit/components_resources.h"
#include "third_party/dom_distiller_js/dom_distiller.pb.h"
@@ -39,7 +39,7 @@ std::string GetDistillerScriptWithOptions(
return "";
}
- scoped_ptr<base::Value> options_value(
+ std::unique_ptr<base::Value> options_value(
dom_distiller::proto::json::DomDistillerOptions::WriteToValue(options));
std::string options_json;
if (!base::JSONWriter::Write(*options_value, &options_json)) {
@@ -91,7 +91,7 @@ void DistillerPage::OnDistillationDone(const GURL& page_url,
DCHECK(!ready_);
ready_ = true;
- scoped_ptr<dom_distiller::proto::DomDistillerResult> distiller_result(
+ std::unique_ptr<dom_distiller::proto::DomDistillerResult> distiller_result(
new dom_distiller::proto::DomDistillerResult());
bool found_content;
if (value->IsType(base::Value::TYPE_NULL)) {
diff --git a/chromium/components/dom_distiller/core/distiller_page.h b/chromium/components/dom_distiller/core/distiller_page.h
index 511a5ebcf3a..8d381e0005c 100644
--- a/chromium/components/dom_distiller/core/distiller_page.h
+++ b/chromium/components/dom_distiller/core/distiller_page.h
@@ -5,11 +5,11 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_
#define COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "third_party/dom_distiller_js/dom_distiller.pb.h"
@@ -30,9 +30,10 @@ class SourcePageHandle {
// thrown away without ever being used.
class DistillerPage {
public:
- typedef base::Callback<
- void(scoped_ptr<proto::DomDistillerResult> distilled_page,
- bool distillation_successful)> DistillerPageCallback;
+ typedef base::Callback<void(
+ std::unique_ptr<proto::DomDistillerResult> distilled_page,
+ bool distillation_successful)>
+ DistillerPageCallback;
DistillerPage();
virtual ~DistillerPage();
@@ -75,10 +76,10 @@ class DistillerPageFactory {
// Constructs and returns a new DistillerPage. The implementation of this
// should be very cheap, since the pages can be thrown away without being
// used.
- virtual scoped_ptr<DistillerPage> CreateDistillerPage(
+ virtual std::unique_ptr<DistillerPage> CreateDistillerPage(
const gfx::Size& render_view_size) const = 0;
- virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) const = 0;
+ virtual std::unique_ptr<DistillerPage> CreateDistillerPageWithHandle(
+ std::unique_ptr<SourcePageHandle> handle) const = 0;
};
} // namespace dom_distiller
diff --git a/chromium/components/dom_distiller/core/distiller_unittest.cc b/chromium/components/dom_distiller/core/distiller_unittest.cc
index 81916cb0524..793b478e2a8 100644
--- a/chromium/components/dom_distiller/core/distiller_unittest.cc
+++ b/chromium/components/dom_distiller/core/distiller_unittest.cc
@@ -5,8 +5,10 @@
#include "components/dom_distiller/core/distiller.h"
#include <stddef.h>
+
#include <algorithm>
#include <map>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -15,11 +17,10 @@
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/dom_distiller/core/article_distillation_update.h"
#include "components/dom_distiller/core/distiller_page.h"
@@ -58,7 +59,7 @@ const string GetImageName(int page_num, int image_num) {
return base::IntToString(page_num) + "_" + base::IntToString(image_num);
}
-scoped_ptr<base::Value> CreateDistilledValueReturnedFromJS(
+std::unique_ptr<base::Value> CreateDistilledValueReturnedFromJS(
const string& title,
const string& content,
const vector<int>& image_indices,
@@ -157,9 +158,9 @@ string GeneratePrevPageUrl(const std::string& url_prefix, size_t page_num) {
return page_num > 0 ? url_prefix + base::SizeTToString(page_num - 1) : "";
}
-scoped_ptr<MultipageDistillerData> CreateMultipageDistillerDataWithoutImages(
- size_t pages_size) {
- scoped_ptr<MultipageDistillerData> result(new MultipageDistillerData());
+std::unique_ptr<MultipageDistillerData>
+CreateMultipageDistillerDataWithoutImages(size_t pages_size) {
+ std::unique_ptr<MultipageDistillerData> result(new MultipageDistillerData());
string url_prefix = kURL;
for (size_t page_num = 0; page_num < pages_size; ++page_num) {
result->page_urls.push_back(url_prefix + base::SizeTToString(page_num));
@@ -170,12 +171,10 @@ scoped_ptr<MultipageDistillerData> CreateMultipageDistillerDataWithoutImages(
GenerateNextPageUrl(url_prefix, page_num, pages_size);
string prev_page_url =
GeneratePrevPageUrl(url_prefix, page_num);
- scoped_ptr<base::Value> distilled_value =
- CreateDistilledValueReturnedFromJS(kTitle,
- result->content[page_num],
+ std::unique_ptr<base::Value> distilled_value =
+ CreateDistilledValueReturnedFromJS(kTitle, result->content[page_num],
result->image_ids[page_num],
- next_page_url,
- prev_page_url);
+ next_page_url, prev_page_url);
result->distilled_values.push_back(distilled_value.release());
}
return result;
@@ -275,7 +274,7 @@ class DistillerTest : public testing::Test {
public:
~DistillerTest() override {}
- void OnDistillArticleDone(scoped_ptr<DistilledArticleProto> proto) {
+ void OnDistillArticleDone(std::unique_ptr<DistilledArticleProto> proto) {
article_proto_ = std::move(proto);
}
@@ -284,7 +283,7 @@ class DistillerTest : public testing::Test {
}
void DistillPage(const std::string& url,
- scoped_ptr<DistillerPage> distiller_page) {
+ std::unique_ptr<DistillerPage> distiller_page) {
distiller_->DistillPage(GURL(url), std::move(distiller_page),
base::Bind(&DistillerTest::OnDistillArticleDone,
base::Unretained(this)),
@@ -293,8 +292,8 @@ class DistillerTest : public testing::Test {
}
protected:
- scoped_ptr<DistillerImpl> distiller_;
- scoped_ptr<DistilledArticleProto> article_proto_;
+ std::unique_ptr<DistillerImpl> distiller_;
+ std::unique_ptr<DistilledArticleProto> article_proto_;
std::vector<ArticleDistillationUpdate> in_sequence_updates_;
MockDistillerPageFactory page_factory_;
TestDistillerURLFetcherFactory url_fetcher_factory_;
@@ -304,24 +303,25 @@ ACTION_P3(DistillerPageOnDistillationDone, distiller_page, url, result) {
distiller_page->OnDistillationDone(url, result);
}
-scoped_ptr<DistillerPage> CreateMockDistillerPage(const base::Value* result,
- const GURL& url) {
+std::unique_ptr<DistillerPage> CreateMockDistillerPage(
+ const base::Value* result,
+ const GURL& url) {
MockDistillerPage* distiller_page = new MockDistillerPage();
EXPECT_CALL(*distiller_page, DistillPageImpl(url, _))
.WillOnce(DistillerPageOnDistillationDone(distiller_page, url, result));
- return scoped_ptr<DistillerPage>(distiller_page);
+ return std::unique_ptr<DistillerPage>(distiller_page);
}
-scoped_ptr<DistillerPage> CreateMockDistillerPageWithPendingJSCallback(
+std::unique_ptr<DistillerPage> CreateMockDistillerPageWithPendingJSCallback(
MockDistillerPage** distiller_page_ptr,
const GURL& url) {
MockDistillerPage* distiller_page = new MockDistillerPage();
*distiller_page_ptr = distiller_page;
EXPECT_CALL(*distiller_page, DistillPageImpl(url, _));
- return scoped_ptr<DistillerPage>(distiller_page);
+ return std::unique_ptr<DistillerPage>(distiller_page);
}
-scoped_ptr<DistillerPage> CreateMockDistillerPages(
+std::unique_ptr<DistillerPage> CreateMockDistillerPages(
MultipageDistillerData* distiller_data,
size_t pages_size,
int start_page_num) {
@@ -337,12 +337,12 @@ scoped_ptr<DistillerPage> CreateMockDistillerPages(
distiller_page, url, distiller_data->distilled_values[page]));
}
}
- return scoped_ptr<DistillerPage>(distiller_page);
+ return std::unique_ptr<DistillerPage>(distiller_page);
}
TEST_F(DistillerTest, DistillPage) {
base::MessageLoopForUI loop;
- scoped_ptr<base::Value> result =
+ std::unique_ptr<base::Value> result =
CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), "");
distiller_.reset(
new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
@@ -359,7 +359,7 @@ TEST_F(DistillerTest, DistillPageWithDebugInfo) {
base::MessageLoopForUI loop;
DomDistillerResult dd_result;
dd_result.mutable_debug_info()->set_log(kDebugLog);
- scoped_ptr<base::Value> result =
+ std::unique_ptr<base::Value> result =
dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result);
distiller_.reset(
new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
@@ -386,7 +386,7 @@ TEST_F(DistillerTest, DistillPageWithTimingInfo) {
dd_result.mutable_timing_info()->add_other_times(), "time0", 6.0);
SetTimingEntry(
dd_result.mutable_timing_info()->add_other_times(), "time1", 7.0);
- scoped_ptr<base::Value> result =
+ std::unique_ptr<base::Value> result =
dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result);
distiller_.reset(
new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
@@ -414,7 +414,7 @@ TEST_F(DistillerTest, DistillPageWithImages) {
image_indices.push_back(0);
image_indices.push_back(1);
image_indices.push_back(2);
- scoped_ptr<base::Value> result =
+ std::unique_ptr<base::Value> result =
CreateDistilledValueReturnedFromJS(kTitle, kContent, image_indices, "");
distiller_.reset(
new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
@@ -437,7 +437,7 @@ TEST_F(DistillerTest, DistillPageWithImages) {
TEST_F(DistillerTest, DistillMultiplePages) {
base::MessageLoopForUI loop;
const size_t kNumPages = 8;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kNumPages);
// Add images.
@@ -466,7 +466,7 @@ TEST_F(DistillerTest, DistillLinkLoop) {
base::MessageLoopForUI loop;
// Create a loop, the next page is same as the current page. This could
// happen if javascript misparses a next page link.
- scoped_ptr<base::Value> result =
+ std::unique_ptr<base::Value> result =
CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), kURL);
distiller_.reset(
new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
@@ -479,19 +479,16 @@ TEST_F(DistillerTest, DistillLinkLoop) {
TEST_F(DistillerTest, CheckMaxPageLimitExtraPage) {
base::MessageLoopForUI loop;
const size_t kMaxPagesInArticle = 10;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kMaxPagesInArticle);
// Note: Next page url of the last page of article is set. So distiller will
// try to do kMaxPagesInArticle + 1 calls if the max article limit does not
// work.
- scoped_ptr<base::Value> last_page_data =
+ std::unique_ptr<base::Value> last_page_data =
CreateDistilledValueReturnedFromJS(
- kTitle,
- distiller_data->content[kMaxPagesInArticle - 1],
- vector<int>(),
- "",
- distiller_data->page_urls[kMaxPagesInArticle - 2]);
+ kTitle, distiller_data->content[kMaxPagesInArticle - 1],
+ vector<int>(), "", distiller_data->page_urls[kMaxPagesInArticle - 2]);
distiller_data->distilled_values.pop_back();
distiller_data->distilled_values.push_back(last_page_data.release());
@@ -513,7 +510,7 @@ TEST_F(DistillerTest, CheckMaxPageLimitExtraPage) {
TEST_F(DistillerTest, CheckMaxPageLimitExactLimit) {
base::MessageLoopForUI loop;
const size_t kMaxPagesInArticle = 10;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kMaxPagesInArticle);
distiller_.reset(
@@ -534,7 +531,7 @@ TEST_F(DistillerTest, CheckMaxPageLimitExactLimit) {
TEST_F(DistillerTest, SinglePageDistillationFailure) {
base::MessageLoopForUI loop;
// To simulate failure return a null value.
- scoped_ptr<base::Value> null_value = base::Value::CreateNullValue();
+ std::unique_ptr<base::Value> null_value = base::Value::CreateNullValue();
distiller_.reset(
new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
DistillPage(kURL, CreateMockDistillerPage(null_value.get(), GURL(kURL)));
@@ -546,7 +543,7 @@ TEST_F(DistillerTest, SinglePageDistillationFailure) {
TEST_F(DistillerTest, MultiplePagesDistillationFailure) {
base::MessageLoopForUI loop;
const size_t kNumPages = 8;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kNumPages);
// The page number of the failed page.
@@ -636,7 +633,7 @@ TEST_F(DistillerTest, DistillPreviousPage) {
// The page number of the article on which distillation starts.
int start_page_num = 3;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kNumPages);
distiller_.reset(
@@ -655,7 +652,7 @@ TEST_F(DistillerTest, IncrementalUpdates) {
// The page number of the article on which distillation starts.
int start_page_num = 3;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kNumPages);
distiller_.reset(
@@ -676,7 +673,7 @@ TEST_F(DistillerTest, IncrementalUpdatesDoNotDeleteFinalArticle) {
base::MessageLoopForUI loop;
const size_t kNumPages = 8;
int start_page_num = 3;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kNumPages);
distiller_.reset(
@@ -697,7 +694,7 @@ TEST_F(DistillerTest, IncrementalUpdatesDoNotDeleteFinalArticle) {
TEST_F(DistillerTest, DeletingArticleDoesNotInterfereWithUpdates) {
base::MessageLoopForUI loop;
const size_t kNumPages = 8;
- scoped_ptr<MultipageDistillerData> distiller_data =
+ std::unique_ptr<MultipageDistillerData> distiller_data =
CreateMultipageDistillerDataWithoutImages(kNumPages);
// The page number of the article on which distillation starts.
int start_page_num = 3;
@@ -722,7 +719,7 @@ TEST_F(DistillerTest, CancelWithDelayedImageFetchCallback) {
base::MessageLoopForUI loop;
vector<int> image_indices;
image_indices.push_back(0);
- scoped_ptr<base::Value> distilled_value =
+ std::unique_ptr<base::Value> distilled_value =
CreateDistilledValueReturnedFromJS(kTitle, kContent, image_indices, "");
TestDistillerURLFetcher* delayed_fetcher = new TestDistillerURLFetcher(true);
MockDistillerURLFetcherFactory mock_url_fetcher_factory;
@@ -742,7 +739,7 @@ TEST_F(DistillerTest, CancelWithDelayedImageFetchCallback) {
TEST_F(DistillerTest, CancelWithDelayedJSCallback) {
base::MessageLoopForUI loop;
- scoped_ptr<base::Value> distilled_value =
+ std::unique_ptr<base::Value> distilled_value =
CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), "");
MockDistillerPage* distiller_page = NULL;
distiller_.reset(
diff --git a/chromium/components/dom_distiller/core/distiller_url_fetcher.cc b/chromium/components/dom_distiller/core/distiller_url_fetcher.cc
index f60efd7d68c..0061d676b14 100644
--- a/chromium/components/dom_distiller/core/distiller_url_fetcher.cc
+++ b/chromium/components/dom_distiller/core/distiller_url_fetcher.cc
@@ -43,10 +43,10 @@ void DistillerURLFetcher::FetchURL(const std::string& url,
url_fetcher_->Start();
}
-scoped_ptr<URLFetcher> DistillerURLFetcher::CreateURLFetcher(
+std::unique_ptr<URLFetcher> DistillerURLFetcher::CreateURLFetcher(
net::URLRequestContextGetter* context_getter,
const std::string& url) {
- scoped_ptr<net::URLFetcher> fetcher =
+ std::unique_ptr<net::URLFetcher> fetcher =
URLFetcher::Create(GURL(url), URLFetcher::GET, this);
fetcher->SetRequestContext(context_getter);
static const int kMaxRetries = 5;
diff --git a/chromium/components/dom_distiller/core/distiller_url_fetcher.h b/chromium/components/dom_distiller/core/distiller_url_fetcher.h
index 176db655991..d0178e0dbba 100644
--- a/chromium/components/dom_distiller/core/distiller_url_fetcher.h
+++ b/chromium/components/dom_distiller/core/distiller_url_fetcher.h
@@ -44,7 +44,7 @@ class DistillerURLFetcher : public net::URLFetcherDelegate {
const URLFetcherCallback& callback);
protected:
- virtual scoped_ptr<net::URLFetcher> CreateURLFetcher(
+ virtual std::unique_ptr<net::URLFetcher> CreateURLFetcher(
net::URLRequestContextGetter* context_getter,
const std::string& url);
@@ -52,7 +52,7 @@ class DistillerURLFetcher : public net::URLFetcherDelegate {
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
- scoped_ptr<net::URLFetcher> url_fetcher_;
+ std::unique_ptr<net::URLFetcher> url_fetcher_;
URLFetcherCallback callback_;
net::URLRequestContextGetter* context_getter_;
DISALLOW_COPY_AND_ASSIGN(DistillerURLFetcher);
diff --git a/chromium/components/dom_distiller/core/distiller_url_fetcher_unittest.cc b/chromium/components/dom_distiller/core/distiller_url_fetcher_unittest.cc
index f100d5cd482..41df9f82967 100644
--- a/chromium/components/dom_distiller/core/distiller_url_fetcher_unittest.cc
+++ b/chromium/components/dom_distiller/core/distiller_url_fetcher_unittest.cc
@@ -54,8 +54,8 @@ class DistillerURLFetcherTest : public testing::Test {
CHECK_EQ(expected_response, response_);
}
- scoped_ptr<dom_distiller::DistillerURLFetcher> url_fetcher_;
- scoped_ptr<net::FakeURLFetcherFactory> factory_;
+ std::unique_ptr<dom_distiller::DistillerURLFetcher> url_fetcher_;
+ std::unique_ptr<net::FakeURLFetcherFactory> factory_;
std::string response_;
};
diff --git a/chromium/components/dom_distiller/core/dom_distiller_request_view_base.cc b/chromium/components/dom_distiller/core/dom_distiller_request_view_base.cc
index 3cec2bbd364..b0ab8354b89 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_request_view_base.cc
+++ b/chromium/components/dom_distiller/core/dom_distiller_request_view_base.cc
@@ -4,12 +4,12 @@
#include "components/dom_distiller/core/dom_distiller_request_view_base.h"
+#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/core/experiments.h"
@@ -114,7 +114,7 @@ void DomDistillerRequestViewBase::OnChangeFontScaling(float scaling) {
}
void DomDistillerRequestViewBase::TakeViewerHandle(
- scoped_ptr<ViewerHandle> viewer_handle) {
+ std::unique_ptr<ViewerHandle> viewer_handle) {
viewer_handle_ = std::move(viewer_handle);
// Getting the viewer handle means this is not an error page, send
// the viewer JavaScript and show the loading indicator.
diff --git a/chromium/components/dom_distiller/core/dom_distiller_request_view_base.h b/chromium/components/dom_distiller/core/dom_distiller_request_view_base.h
index c35b9255ffe..308cbd0ba7e 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_request_view_base.h
+++ b/chromium/components/dom_distiller/core/dom_distiller_request_view_base.h
@@ -5,11 +5,11 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_REQUEST_VIEW_BASE_H_
#define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_REQUEST_VIEW_BASE_H_
+#include <memory>
#include <sstream>
#include <string>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/core/task_tracker.h"
@@ -36,7 +36,7 @@ class DomDistillerRequestViewBase : public ViewRequestDelegate,
void OnArticleUpdated(ArticleDistillationUpdate article_update) override;
- void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle);
+ void TakeViewerHandle(std::unique_ptr<ViewerHandle> viewer_handle);
protected:
// DistilledPagePrefs::Observer implementation:
@@ -54,7 +54,7 @@ class DomDistillerRequestViewBase : public ViewRequestDelegate,
// The handle to the view request towards the DomDistillerService. It
// needs to be kept around to ensure the distillation request finishes.
- scoped_ptr<ViewerHandle> viewer_handle_;
+ std::unique_ptr<ViewerHandle> viewer_handle_;
// Number of pages of the distilled article content that have been rendered by
// the viewer.
diff --git a/chromium/components/dom_distiller/core/dom_distiller_request_view_base_unittest.cc b/chromium/components/dom_distiller/core/dom_distiller_request_view_base_unittest.cc
index a13e4d1f797..5f661d80e7b 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_request_view_base_unittest.cc
+++ b/chromium/components/dom_distiller/core/dom_distiller_request_view_base_unittest.cc
@@ -26,8 +26,8 @@ class DomDistillerRequestViewTest : public testing::Test {
distilled_page_prefs_.reset(new DistilledPagePrefs(pref_service_.get()));
}
- scoped_ptr<user_prefs::TestingPrefServiceSyncable> pref_service_;
- scoped_ptr<DistilledPagePrefs> distilled_page_prefs_;
+ std::unique_ptr<user_prefs::TestingPrefServiceSyncable> pref_service_;
+ std::unique_ptr<DistilledPagePrefs> distilled_page_prefs_;
};
TEST_F(DomDistillerRequestViewTest, TestTitleEscaped) {
@@ -41,7 +41,7 @@ TEST_F(DomDistillerRequestViewTest, TestTitleEscaped) {
// Make sure title is properly escaped from quotes.
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
article_proto->set_title(has_quotes);
@@ -54,7 +54,7 @@ TEST_F(DomDistillerRequestViewTest, TestTitleEscaped) {
// Make sure title is properly escaped from special characters.
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
article_proto->set_title(has_special_chars);
@@ -75,7 +75,7 @@ TEST_F(DomDistillerRequestViewTest, TestTitleNeverEmpty) {
// Test that the title actually gets shown.
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
article_proto->set_title(valid_title);
@@ -87,7 +87,7 @@ TEST_F(DomDistillerRequestViewTest, TestTitleNeverEmpty) {
// Test empty string title
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
article_proto->set_title("");
@@ -99,7 +99,7 @@ TEST_F(DomDistillerRequestViewTest, TestTitleNeverEmpty) {
// Test no title.
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
handle.OnArticleReady(article_proto.get());
@@ -118,7 +118,7 @@ TEST_F(DomDistillerRequestViewTest, TestContentNeverEmpty) {
// Test single page content
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
(*(article_proto->add_pages())).set_html(valid_content);
@@ -131,7 +131,7 @@ TEST_F(DomDistillerRequestViewTest, TestContentNeverEmpty) {
// Test multiple page content
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
(*(article_proto->add_pages())).set_html(valid_content);
(*(article_proto->add_pages())).set_html(valid_content);
@@ -146,7 +146,7 @@ TEST_F(DomDistillerRequestViewTest, TestContentNeverEmpty) {
// Test empty string content
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
(*(article_proto->add_pages())).set_html("");
@@ -159,7 +159,7 @@ TEST_F(DomDistillerRequestViewTest, TestContentNeverEmpty) {
// Test page no content
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
article_proto->add_pages();
@@ -172,7 +172,7 @@ TEST_F(DomDistillerRequestViewTest, TestContentNeverEmpty) {
// Test no page.
{
- scoped_ptr<DistilledArticleProto> article_proto(
+ std::unique_ptr<DistilledArticleProto> article_proto(
new DistilledArticleProto());
handle.OnArticleReady(article_proto.get());
@@ -191,7 +191,7 @@ TEST_F(DomDistillerRequestViewTest, TestContentNeverEmpty) {
page_proto->data.set_html("");
pages.push_back(page_proto);
- scoped_ptr<ArticleDistillationUpdate> article_update(
+ std::unique_ptr<ArticleDistillationUpdate> article_update(
new ArticleDistillationUpdate(pages, false, false));
handle.OnArticleUpdated(*article_update.get());
@@ -217,7 +217,7 @@ TEST_F(DomDistillerRequestViewTest, TestLoadingIndicator) {
new base::RefCountedData<DistilledPageProto>();
pages.push_back(page_proto);
- scoped_ptr<ArticleDistillationUpdate> article_update(
+ std::unique_ptr<ArticleDistillationUpdate> article_update(
new ArticleDistillationUpdate(pages, true, false));
handle.OnArticleUpdated(*article_update.get());
diff --git a/chromium/components/dom_distiller/core/dom_distiller_service.cc b/chromium/components/dom_distiller/core/dom_distiller_service.cc
index 47d4f06d629..affdc916b1e 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_service.cc
+++ b/chromium/components/dom_distiller/core/dom_distiller_service.cc
@@ -10,7 +10,7 @@
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "components/dom_distiller/core/distilled_content_store.h"
#include "components/dom_distiller/core/dom_distiller_store.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
@@ -42,10 +42,10 @@ void RunArticleAvailableCallback(
} // namespace
DomDistillerService::DomDistillerService(
- scoped_ptr<DomDistillerStoreInterface> store,
- scoped_ptr<DistillerFactory> distiller_factory,
- scoped_ptr<DistillerPageFactory> distiller_page_factory,
- scoped_ptr<DistilledPagePrefs> distilled_page_prefs)
+ std::unique_ptr<DomDistillerStoreInterface> store,
+ std::unique_ptr<DistillerFactory> distiller_factory,
+ std::unique_ptr<DistillerPageFactory> distiller_page_factory,
+ std::unique_ptr<DistilledPagePrefs> distilled_page_prefs)
: store_(std::move(store)),
content_store_(new InMemoryContentStore(kDefaultMaxNumCachedEntries)),
distiller_factory_(std::move(distiller_factory)),
@@ -59,21 +59,21 @@ syncer::SyncableService* DomDistillerService::GetSyncableService() const {
return store_->GetSyncableService();
}
-scoped_ptr<DistillerPage> DomDistillerService::CreateDefaultDistillerPage(
+std::unique_ptr<DistillerPage> DomDistillerService::CreateDefaultDistillerPage(
const gfx::Size& render_view_size) {
return distiller_page_factory_->CreateDistillerPage(render_view_size);
}
-scoped_ptr<DistillerPage>
+std::unique_ptr<DistillerPage>
DomDistillerService::CreateDefaultDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) {
+ std::unique_ptr<SourcePageHandle> handle) {
return distiller_page_factory_->CreateDistillerPageWithHandle(
std::move(handle));
}
const std::string DomDistillerService::AddToList(
const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const ArticleAvailableCallback& article_cb) {
ArticleEntry entry;
const bool is_already_added = store_->GetEntryByUrl(url, &entry);
@@ -128,9 +128,9 @@ std::vector<ArticleEntry> DomDistillerService::GetEntries() const {
return store_->GetEntries();
}
-scoped_ptr<ArticleEntry> DomDistillerService::RemoveEntry(
+std::unique_ptr<ArticleEntry> DomDistillerService::RemoveEntry(
const std::string& entry_id) {
- scoped_ptr<ArticleEntry> entry(new ArticleEntry);
+ std::unique_ptr<ArticleEntry> entry(new ArticleEntry);
entry->set_entry_id(entry_id);
TaskTracker* task_tracker = GetTaskTrackerForEntry(*entry);
if (task_tracker != NULL) {
@@ -138,27 +138,28 @@ scoped_ptr<ArticleEntry> DomDistillerService::RemoveEntry(
}
if (!store_->GetEntryById(entry_id, entry.get())) {
- return scoped_ptr<ArticleEntry>();
+ return std::unique_ptr<ArticleEntry>();
}
if (store_->RemoveEntry(*entry)) {
return entry;
}
- return scoped_ptr<ArticleEntry>();
+ return std::unique_ptr<ArticleEntry>();
}
-scoped_ptr<ViewerHandle> DomDistillerService::ViewEntry(
+std::unique_ptr<ViewerHandle> DomDistillerService::ViewEntry(
ViewRequestDelegate* delegate,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const std::string& entry_id) {
ArticleEntry entry;
if (!store_->GetEntryById(entry_id, &entry)) {
- return scoped_ptr<ViewerHandle>();
+ return std::unique_ptr<ViewerHandle>();
}
TaskTracker* task_tracker = nullptr;
bool was_created = GetOrCreateTaskTrackerForEntry(entry, &task_tracker);
- scoped_ptr<ViewerHandle> viewer_handle = task_tracker->AddViewer(delegate);
+ std::unique_ptr<ViewerHandle> viewer_handle =
+ task_tracker->AddViewer(delegate);
if (was_created) {
task_tracker->StartDistiller(distiller_factory_.get(),
std::move(distiller_page));
@@ -168,17 +169,18 @@ scoped_ptr<ViewerHandle> DomDistillerService::ViewEntry(
return viewer_handle;
}
-scoped_ptr<ViewerHandle> DomDistillerService::ViewUrl(
+std::unique_ptr<ViewerHandle> DomDistillerService::ViewUrl(
ViewRequestDelegate* delegate,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const GURL& url) {
if (!url.is_valid()) {
- return scoped_ptr<ViewerHandle>();
+ return std::unique_ptr<ViewerHandle>();
}
TaskTracker* task_tracker = nullptr;
bool was_created = GetOrCreateTaskTrackerForUrl(url, &task_tracker);
- scoped_ptr<ViewerHandle> viewer_handle = task_tracker->AddViewer(delegate);
+ std::unique_ptr<ViewerHandle> viewer_handle =
+ task_tracker->AddViewer(delegate);
// If a distiller is already running for one URL, don't start another.
if (was_created) {
task_tracker->StartDistiller(distiller_factory_.get(),
diff --git a/chromium/components/dom_distiller/core/dom_distiller_service.h b/chromium/components/dom_distiller/core/dom_distiller_service.h
index 5d2558d1142..a9b4312fd83 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_service.h
+++ b/chromium/components/dom_distiller/core/dom_distiller_service.h
@@ -5,12 +5,12 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_
#define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "components/dom_distiller/core/article_entry.h"
@@ -53,7 +53,7 @@ class DomDistillerServiceInterface {
// distillation task in progress for the given |url|.
virtual const std::string AddToList(
const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const ArticleAvailableCallback& article_cb) = 0;
// Returns whether an article stored has the given entry id.
@@ -68,7 +68,8 @@ class DomDistillerServiceInterface {
virtual std::vector<ArticleEntry> GetEntries() const = 0;
// Removes the specified entry from the dom distiller store.
- virtual scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id) = 0;
+ virtual std::unique_ptr<ArticleEntry> RemoveEntry(
+ const std::string& entry_id) = 0;
// Request to view an article by entry id. Returns a null pointer if no entry
// with |entry_id| exists. The ViewerHandle should be destroyed before the
@@ -78,25 +79,25 @@ class DomDistillerServiceInterface {
// Use CreateDefaultDistillerPage() to create a default |distiller_page|.
// The provided |distiller_page| is only used if there is not already a
// distillation task in progress for the given |entry_id|.
- virtual scoped_ptr<ViewerHandle> ViewEntry(
+ virtual std::unique_ptr<ViewerHandle> ViewEntry(
ViewRequestDelegate* delegate,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const std::string& entry_id) = 0;
// Request to view an article by url.
// Use CreateDefaultDistillerPage() to create a default |distiller_page|.
// The provided |distiller_page| is only used if there is not already a
// distillation task in progress for the given |url|.
- virtual scoped_ptr<ViewerHandle> ViewUrl(
+ virtual std::unique_ptr<ViewerHandle> ViewUrl(
ViewRequestDelegate* delegate,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const GURL& url) = 0;
// Creates a default DistillerPage.
- virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage(
+ virtual std::unique_ptr<DistillerPage> CreateDefaultDistillerPage(
const gfx::Size& render_view_size) = 0;
- virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) = 0;
+ virtual std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
+ std::unique_ptr<SourcePageHandle> handle) = 0;
virtual void AddObserver(DomDistillerObserver* observer) = 0;
virtual void RemoveObserver(DomDistillerObserver* observer) = 0;
@@ -115,32 +116,36 @@ class DomDistillerServiceInterface {
// Provide a view of the article list and ways of interacting with it.
class DomDistillerService : public DomDistillerServiceInterface {
public:
- DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store,
- scoped_ptr<DistillerFactory> distiller_factory,
- scoped_ptr<DistillerPageFactory> distiller_page_factory,
- scoped_ptr<DistilledPagePrefs> distilled_page_prefs);
+ DomDistillerService(
+ std::unique_ptr<DomDistillerStoreInterface> store,
+ std::unique_ptr<DistillerFactory> distiller_factory,
+ std::unique_ptr<DistillerPageFactory> distiller_page_factory,
+ std::unique_ptr<DistilledPagePrefs> distilled_page_prefs);
~DomDistillerService() override;
// DomDistillerServiceInterface implementation.
syncer::SyncableService* GetSyncableService() const override;
const std::string AddToList(
const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const ArticleAvailableCallback& article_cb) override;
bool HasEntry(const std::string& entry_id) override;
std::string GetUrlForEntry(const std::string& entry_id) override;
std::vector<ArticleEntry> GetEntries() const override;
- scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id) override;
- scoped_ptr<ViewerHandle> ViewEntry(ViewRequestDelegate* delegate,
- scoped_ptr<DistillerPage> distiller_page,
- const std::string& entry_id) override;
- scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate,
- scoped_ptr<DistillerPage> distiller_page,
- const GURL& url) override;
- scoped_ptr<DistillerPage> CreateDefaultDistillerPage(
+ std::unique_ptr<ArticleEntry> RemoveEntry(
+ const std::string& entry_id) override;
+ std::unique_ptr<ViewerHandle> ViewEntry(
+ ViewRequestDelegate* delegate,
+ std::unique_ptr<DistillerPage> distiller_page,
+ const std::string& entry_id) override;
+ std::unique_ptr<ViewerHandle> ViewUrl(
+ ViewRequestDelegate* delegate,
+ std::unique_ptr<DistillerPage> distiller_page,
+ const GURL& url) override;
+ std::unique_ptr<DistillerPage> CreateDefaultDistillerPage(
const gfx::Size& render_view_size) override;
- scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) override;
+ std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
+ std::unique_ptr<SourcePageHandle> handle) override;
void AddObserver(DomDistillerObserver* observer) override;
void RemoveObserver(DomDistillerObserver* observer) override;
DistilledPagePrefs* GetDistilledPagePrefs() override;
@@ -166,11 +171,11 @@ class DomDistillerService : public DomDistillerServiceInterface {
bool GetOrCreateTaskTrackerForEntry(const ArticleEntry& entry,
TaskTracker** task_tracker);
- scoped_ptr<DomDistillerStoreInterface> store_;
- scoped_ptr<DistilledContentStore> content_store_;
- scoped_ptr<DistillerFactory> distiller_factory_;
- scoped_ptr<DistillerPageFactory> distiller_page_factory_;
- scoped_ptr<DistilledPagePrefs> distilled_page_prefs_;
+ std::unique_ptr<DomDistillerStoreInterface> store_;
+ std::unique_ptr<DistilledContentStore> content_store_;
+ std::unique_ptr<DistillerFactory> distiller_factory_;
+ std::unique_ptr<DistillerPageFactory> distiller_page_factory_;
+ std::unique_ptr<DistilledPagePrefs> distilled_page_prefs_;
typedef ScopedVector<TaskTracker> TaskList;
TaskList tasks_;
diff --git a/chromium/components/dom_distiller/core/dom_distiller_service_unittest.cc b/chromium/components/dom_distiller/core/dom_distiller_service_unittest.cc
index de664588058..cffc8d66b7b 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_service_unittest.cc
+++ b/chromium/components/dom_distiller/core/dom_distiller_service_unittest.cc
@@ -60,19 +60,20 @@ DomDistillerService::ArticleAvailableCallback ArticleCallback(
}
void RunDistillerCallback(FakeDistiller* distiller,
- scoped_ptr<DistilledArticleProto> proto) {
+ std::unique_ptr<DistilledArticleProto> proto) {
distiller->RunDistillerCallback(std::move(proto));
base::RunLoop().RunUntilIdle();
}
-scoped_ptr<DistilledArticleProto> CreateArticleWithURL(const std::string& url) {
- scoped_ptr<DistilledArticleProto> proto(new DistilledArticleProto);
+std::unique_ptr<DistilledArticleProto> CreateArticleWithURL(
+ const std::string& url) {
+ std::unique_ptr<DistilledArticleProto> proto(new DistilledArticleProto);
DistilledPageProto* page = proto->add_pages();
page->set_url(url);
return proto;
}
-scoped_ptr<DistilledArticleProto> CreateDefaultArticle() {
+std::unique_ptr<DistilledArticleProto> CreateDefaultArticle() {
return CreateArticleWithURL("http://www.example.com/default_article_page1");
}
@@ -89,10 +90,10 @@ class DomDistillerServiceTest : public testing::Test {
distiller_factory_ = new MockDistillerFactory();
distiller_page_factory_ = new MockDistillerPageFactory();
service_.reset(new DomDistillerService(
- scoped_ptr<DomDistillerStoreInterface>(store_),
- scoped_ptr<DistillerFactory>(distiller_factory_),
- scoped_ptr<DistillerPageFactory>(distiller_page_factory_),
- scoped_ptr<DistilledPagePrefs>()));
+ std::unique_ptr<DomDistillerStoreInterface>(store_),
+ std::unique_ptr<DistillerFactory>(distiller_factory_),
+ std::unique_ptr<DistillerPageFactory>(distiller_page_factory_),
+ std::unique_ptr<DistilledPagePrefs>()));
fake_db->InitCallback(true);
fake_db->LoadCallback(true);
}
@@ -109,8 +110,8 @@ class DomDistillerServiceTest : public testing::Test {
DomDistillerStoreInterface* store_;
MockDistillerFactory* distiller_factory_;
MockDistillerPageFactory* distiller_page_factory_;
- scoped_ptr<DomDistillerService> service_;
- scoped_ptr<base::MessageLoop> main_loop_;
+ std::unique_ptr<DomDistillerService> service_;
+ std::unique_ptr<base::MessageLoop> main_loop_;
FakeDB<ArticleEntry>::EntryMap db_model_;
};
@@ -128,13 +129,13 @@ TEST_F(DomDistillerServiceTest, TestViewEntry) {
store_->AddEntry(entry);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle = service_->ViewEntry(
+ std::unique_ptr<ViewerHandle> handle = service_->ViewEntry(
&viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()),
entry_id);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
- scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
+ std::unique_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
RunDistillerCallback(distiller, std::move(proto));
@@ -147,13 +148,13 @@ TEST_F(DomDistillerServiceTest, TestViewUrl) {
FakeViewRequestDelegate viewer_delegate;
GURL url("http://www.example.com/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ std::unique_ptr<ViewerHandle> handle = service_->ViewUrl(
&viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
- scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
+ std::unique_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
RunDistillerCallback(distiller, std::move(proto));
@@ -172,16 +173,16 @@ TEST_F(DomDistillerServiceTest, TestMultipleViewUrl) {
GURL url("http://www.example.com/p1");
GURL url2("http://www.example.com/a/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ std::unique_ptr<ViewerHandle> handle = service_->ViewUrl(
&viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
- scoped_ptr<ViewerHandle> handle2 = service_->ViewUrl(
+ std::unique_ptr<ViewerHandle> handle2 = service_->ViewUrl(
&viewer_delegate2, service_->CreateDefaultDistillerPage(gfx::Size()),
url2);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
- scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
+ std::unique_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
RunDistillerCallback(distiller, std::move(proto));
@@ -189,7 +190,7 @@ TEST_F(DomDistillerServiceTest, TestMultipleViewUrl) {
ASSERT_FALSE(distiller2->GetArticleCallback().is_null());
EXPECT_EQ(url2, distiller2->GetUrl());
- scoped_ptr<DistilledArticleProto> proto2 = CreateDefaultArticle();
+ std::unique_ptr<DistilledArticleProto> proto2 = CreateDefaultArticle();
EXPECT_CALL(viewer_delegate2, OnArticleReady(proto2.get()));
RunDistillerCallback(distiller2, std::move(proto2));
@@ -206,7 +207,7 @@ TEST_F(DomDistillerServiceTest, TestViewUrlCancelled) {
FakeViewRequestDelegate viewer_delegate;
GURL url("http://www.example.com/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ std::unique_ptr<ViewerHandle> handle = service_->ViewUrl(
&viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
@@ -228,10 +229,11 @@ TEST_F(DomDistillerServiceTest, TestViewUrlDoesNotAddEntry) {
FakeViewRequestDelegate viewer_delegate;
GURL url("http://www.example.com/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ std::unique_ptr<ViewerHandle> handle = service_->ViewUrl(
&viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
- scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
+ std::unique_ptr<DistilledArticleProto> proto =
+ CreateArticleWithURL(url.spec());
EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
RunDistillerCallback(distiller, std::move(proto));
@@ -257,7 +259,8 @@ TEST_F(DomDistillerServiceTest, TestAddAndRemoveEntry) {
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
- scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
+ std::unique_ptr<DistilledArticleProto> proto =
+ CreateArticleWithURL(url.spec());
RunDistillerCallback(distiller, std::move(proto));
ArticleEntry entry;
@@ -318,7 +321,7 @@ TEST_F(DomDistillerServiceTest, TestMultipleObservers) {
util::HasExpectedUpdates(expected_updates)));
}
- scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
+ std::unique_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
RunDistillerCallback(distiller, std::move(proto));
// Remove should notify all observers that article is removed.
@@ -356,7 +359,8 @@ TEST_F(DomDistillerServiceTest, TestMultipleCallbacks) {
EXPECT_CALL(article_cb[i], DistillationCompleted(true));
}
- scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
+ std::unique_ptr<DistilledArticleProto> proto =
+ CreateArticleWithURL(url.spec());
RunDistillerCallback(distiller, std::move(proto));
// Add the same url again, all callbacks should be called with true.
@@ -423,7 +427,7 @@ TEST_F(DomDistillerServiceTest, TestMultiplePageArticle) {
EXPECT_EQ(pages_url[0], distiller->GetUrl());
// Create the article with pages to pass to the distiller.
- scoped_ptr<DistilledArticleProto> proto =
+ std::unique_ptr<DistilledArticleProto> proto =
CreateArticleWithURL(pages_url[0].spec());
for (int page_num = 1; page_num < kPageCount; ++page_num) {
DistilledPageProto* distilled_page = proto->add_pages();
@@ -469,7 +473,8 @@ TEST_F(DomDistillerServiceTest, TestHasEntry) {
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
- scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
+ std::unique_ptr<DistilledArticleProto> proto =
+ CreateArticleWithURL(url.spec());
RunDistillerCallback(distiller, std::move(proto));
// Check that HasEntry returns true for the article just added.
@@ -500,7 +505,8 @@ TEST_F(DomDistillerServiceTest, TestGetUrlForOnePageEntry) {
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
- scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
+ std::unique_ptr<DistilledArticleProto> proto =
+ CreateArticleWithURL(url.spec());
RunDistillerCallback(distiller, std::move(proto));
// Check if retrieved URL is same as given URL.
@@ -540,7 +546,7 @@ TEST_F(DomDistillerServiceTest, TestGetUrlForMultiPageEntry) {
EXPECT_EQ(pages_url[0], distiller->GetUrl());
// Create the article with pages to pass to the distiller.
- scoped_ptr<DistilledArticleProto> proto =
+ std::unique_ptr<DistilledArticleProto> proto =
CreateArticleWithURL(pages_url[0].spec());
for (int page_num = 1; page_num < kPageCount; ++page_num) {
DistilledPageProto* distilled_page = proto->add_pages();
diff --git a/chromium/components/dom_distiller/core/dom_distiller_store.cc b/chromium/components/dom_distiller/core/dom_distiller_store.cc
index 2ed0ff58e70..1f76d99a473 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_store.cc
+++ b/chromium/components/dom_distiller/core/dom_distiller_store.cc
@@ -11,7 +11,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "components/dom_distiller/core/article_entry.h"
#include "sync/api/sync_change.h"
#include "sync/protocol/article_specifics.pb.h"
@@ -39,7 +39,7 @@ const char kDatabaseUMAClientName[] = "DomDistillerStore";
namespace dom_distiller {
DomDistillerStore::DomDistillerStore(
- scoped_ptr<ProtoDatabase<ArticleEntry>> database,
+ std::unique_ptr<ProtoDatabase<ArticleEntry>> database,
const base::FilePath& database_dir)
: database_(std::move(database)),
database_loaded_(false),
@@ -51,7 +51,7 @@ DomDistillerStore::DomDistillerStore(
}
DomDistillerStore::DomDistillerStore(
- scoped_ptr<ProtoDatabase<ArticleEntry>> database,
+ std::unique_ptr<ProtoDatabase<ArticleEntry>> database,
const std::vector<ArticleEntry>& initial_data,
const base::FilePath& database_dir)
: database_(std::move(database)),
@@ -82,14 +82,14 @@ bool DomDistillerStore::GetEntryByUrl(const GURL& url, ArticleEntry* entry) {
void DomDistillerStore::UpdateAttachments(
const std::string& entry_id,
- scoped_ptr<ArticleAttachmentsData> attachments_data,
+ std::unique_ptr<ArticleAttachmentsData> attachments_data,
const UpdateAttachmentsCallback& callback) {
if (!GetEntryById(entry_id, nullptr)) {
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
base::Bind(callback, false));
}
- scoped_ptr<sync_pb::ArticleAttachments> article_attachments(
+ std::unique_ptr<sync_pb::ArticleAttachments> article_attachments(
new sync_pb::ArticleAttachments());
syncer::AttachmentList attachment_list;
attachments_data->CreateSyncAttachments(&attachment_list,
@@ -104,7 +104,7 @@ void DomDistillerStore::UpdateAttachments(
void DomDistillerStore::OnAttachmentsWrite(
const std::string& entry_id,
- scoped_ptr<sync_pb::ArticleAttachments> article_attachments,
+ std::unique_ptr<sync_pb::ArticleAttachments> article_attachments,
const UpdateAttachmentsCallback& callback,
const syncer::AttachmentStore::Result& result) {
bool success = false;
@@ -174,8 +174,8 @@ void DomDistillerStore::OnAttachmentsRead(
const sync_pb::ArticleAttachments& attachments_proto,
const GetAttachmentsCallback& callback,
const syncer::AttachmentStore::Result& result,
- scoped_ptr<syncer::AttachmentMap> attachments,
- scoped_ptr<syncer::AttachmentIdList> missing) {
+ std::unique_ptr<syncer::AttachmentMap> attachments,
+ std::unique_ptr<syncer::AttachmentIdList> missing) {
bool success = false;
switch (result) {
case syncer::AttachmentStore::UNSPECIFIED_ERROR:
@@ -186,7 +186,7 @@ void DomDistillerStore::OnAttachmentsRead(
success = true;
break;
}
- scoped_ptr<ArticleAttachmentsData> attachments_data;
+ std::unique_ptr<ArticleAttachmentsData> attachments_data;
if (success) {
attachments_data = ArticleAttachmentsData::GetFromAttachmentMap(
attachments_proto, *attachments);
@@ -279,9 +279,10 @@ std::vector<ArticleEntry> DomDistillerStore::GetEntries() const {
// syncer::SyncableService implementation.
SyncMergeResult DomDistillerStore::MergeDataAndStartSyncing(
- ModelType type, const SyncDataList& initial_sync_data,
- scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
- scoped_ptr<syncer::SyncErrorFactory> error_handler) {
+ ModelType type,
+ const SyncDataList& initial_sync_data,
+ std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
+ std::unique_ptr<syncer::SyncErrorFactory> error_handler) {
DCHECK_EQ(syncer::ARTICLES, type);
DCHECK(!sync_processor_);
DCHECK(!error_factory_);
@@ -368,7 +369,7 @@ void DomDistillerStore::OnDatabaseInit(bool success) {
}
void DomDistillerStore::OnDatabaseLoad(bool success,
- scoped_ptr<EntryVector> entries) {
+ std::unique_ptr<EntryVector> entries) {
if (!success) {
DVLOG(1) << "DOM Distiller database load failed.";
database_.reset();
@@ -424,9 +425,9 @@ bool DomDistillerStore::ApplyChangesToDatabase(
if (change_list.empty()) {
return true;
}
- scoped_ptr<ProtoDatabase<ArticleEntry>::KeyEntryVector> entries_to_save(
+ std::unique_ptr<ProtoDatabase<ArticleEntry>::KeyEntryVector> entries_to_save(
new ProtoDatabase<ArticleEntry>::KeyEntryVector());
- scoped_ptr<std::vector<std::string> > keys_to_remove(
+ std::unique_ptr<std::vector<std::string>> keys_to_remove(
new std::vector<std::string>());
for (SyncChangeList::const_iterator it = change_list.begin();
diff --git a/chromium/components/dom_distiller/core/dom_distiller_store.h b/chromium/components/dom_distiller/core/dom_distiller_store.h
index 71e33b8a46c..9dededd8604 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_store.h
+++ b/chromium/components/dom_distiller/core/dom_distiller_store.h
@@ -49,8 +49,8 @@ class DomDistillerStoreInterface {
virtual bool RemoveEntry(const ArticleEntry& entry) = 0;
typedef base::Callback<void(bool success)> UpdateAttachmentsCallback;
- typedef base::Callback<void(bool success,
- scoped_ptr<ArticleAttachmentsData> attachments)>
+ typedef base::Callback<
+ void(bool success, std::unique_ptr<ArticleAttachmentsData> attachments)>
GetAttachmentsCallback;
// Updates the attachments for an entry. The callback will be called with
@@ -60,7 +60,7 @@ class DomDistillerStoreInterface {
// etc.).
virtual void UpdateAttachments(
const std::string& entry_id,
- scoped_ptr<ArticleAttachmentsData> attachments,
+ std::unique_ptr<ArticleAttachmentsData> attachments,
const UpdateAttachmentsCallback& callback) = 0;
// Gets the attachments for an entry. If the attachments are available (either
@@ -107,14 +107,14 @@ class DomDistillerStore : public syncer::SyncableService,
// Creates storage using the given database for local storage. Initializes the
// database with |database_dir|.
DomDistillerStore(
- scoped_ptr<leveldb_proto::ProtoDatabase<ArticleEntry> > database,
+ std::unique_ptr<leveldb_proto::ProtoDatabase<ArticleEntry>> database,
const base::FilePath& database_dir);
// Creates storage using the given database for local storage. Initializes the
// database with |database_dir|. Also initializes the internal model to
// |initial_model|.
DomDistillerStore(
- scoped_ptr<leveldb_proto::ProtoDatabase<ArticleEntry> > database,
+ std::unique_ptr<leveldb_proto::ProtoDatabase<ArticleEntry>> database,
const std::vector<ArticleEntry>& initial_data,
const base::FilePath& database_dir);
@@ -127,9 +127,10 @@ class DomDistillerStore : public syncer::SyncableService,
bool UpdateEntry(const ArticleEntry& entry) override;
bool RemoveEntry(const ArticleEntry& entry) override;
- void UpdateAttachments(const std::string& entry_id,
- scoped_ptr<ArticleAttachmentsData> attachments_data,
- const UpdateAttachmentsCallback& callback) override;
+ void UpdateAttachments(
+ const std::string& entry_id,
+ std::unique_ptr<ArticleAttachmentsData> attachments_data,
+ const UpdateAttachmentsCallback& callback) override;
void GetAttachments(const std::string& entry_id,
const GetAttachmentsCallback& callback) override;
@@ -144,8 +145,8 @@ class DomDistillerStore : public syncer::SyncableService,
syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
- scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
- scoped_ptr<syncer::SyncErrorFactory> error_handler) override;
+ std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
+ std::unique_ptr<syncer::SyncErrorFactory> error_handler) override;
void StopSyncing(syncer::ModelType type) override;
syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
syncer::SyncError ProcessSyncChanges(
@@ -154,7 +155,7 @@ class DomDistillerStore : public syncer::SyncableService,
private:
void OnDatabaseInit(bool success);
- void OnDatabaseLoad(bool success, scoped_ptr<EntryVector> entries);
+ void OnDatabaseLoad(bool success, std::unique_ptr<EntryVector> entries);
void OnDatabaseSave(bool success);
// Returns true if the change is successfully applied.
@@ -163,15 +164,15 @@ class DomDistillerStore : public syncer::SyncableService,
void OnAttachmentsWrite(
const std::string& entry_id,
- scoped_ptr<sync_pb::ArticleAttachments> article_attachments,
+ std::unique_ptr<sync_pb::ArticleAttachments> article_attachments,
const UpdateAttachmentsCallback& callback,
const syncer::AttachmentStore::Result& result);
void OnAttachmentsRead(const sync_pb::ArticleAttachments& attachments_proto,
const GetAttachmentsCallback& callback,
const syncer::AttachmentStore::Result& result,
- scoped_ptr<syncer::AttachmentMap> attachments,
- scoped_ptr<syncer::AttachmentIdList> missing);
+ std::unique_ptr<syncer::AttachmentMap> attachments,
+ std::unique_ptr<syncer::AttachmentIdList> missing);
syncer::SyncMergeResult MergeDataWithModel(
const syncer::SyncDataList& data, syncer::SyncChangeList* changes_applied,
@@ -196,11 +197,11 @@ class DomDistillerStore : public syncer::SyncableService,
void NotifyObservers(const syncer::SyncChangeList& changes);
- scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
- scoped_ptr<syncer::SyncErrorFactory> error_factory_;
- scoped_ptr<leveldb_proto::ProtoDatabase<ArticleEntry> > database_;
+ std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_;
+ std::unique_ptr<syncer::SyncErrorFactory> error_factory_;
+ std::unique_ptr<leveldb_proto::ProtoDatabase<ArticleEntry>> database_;
bool database_loaded_;
- scoped_ptr<syncer::AttachmentStore> attachment_store_;
+ std::unique_ptr<syncer::AttachmentStore> attachment_store_;
base::ObserverList<DomDistillerObserver> observers_;
DomDistillerModel model_;
diff --git a/chromium/components/dom_distiller/core/dom_distiller_store_unittest.cc b/chromium/components/dom_distiller/core/dom_distiller_store_unittest.cc
index c962aa4f5f5..15b3452dad7 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_store_unittest.cc
+++ b/chromium/components/dom_distiller/core/dom_distiller_store_unittest.cc
@@ -5,11 +5,13 @@
#include "components/dom_distiller/core/dom_distiller_store.h"
#include <stdint.h>
+
#include <utility>
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/time/time.h"
@@ -154,8 +156,8 @@ class DomDistillerStoreTest : public testing::Test {
store_->MergeDataAndStartSyncing(
kDomDistillerModelType, SyncDataFromEntryMap(sync_model_),
- make_scoped_ptr<SyncChangeProcessor>(fake_sync_processor_),
- scoped_ptr<SyncErrorFactory>(new FakeSyncErrorFactory()));
+ base::WrapUnique<SyncChangeProcessor>(fake_sync_processor_),
+ std::unique_ptr<SyncErrorFactory>(new FakeSyncErrorFactory()));
}
protected:
@@ -181,7 +183,7 @@ class DomDistillerStoreTest : public testing::Test {
EntryMap sync_model_;
FakeDB<ArticleEntry>::EntryMap store_model_;
- scoped_ptr<DomDistillerStore> store_;
+ std::unique_ptr<DomDistillerStore> store_;
// Both owned by |store_|.
FakeDB<ArticleEntry>* fake_db_;
@@ -316,7 +318,8 @@ class MockAttachmentsCallbacks {
MOCK_METHOD2(Get, void(bool, ArticleAttachmentsData*));
MOCK_METHOD1(Update, void(bool));
- void GetImpl(bool success, scoped_ptr<ArticleAttachmentsData> attachments) {
+ void GetImpl(bool success,
+ std::unique_ptr<ArticleAttachmentsData> attachments) {
Get(success, attachments.get());
}
@@ -351,7 +354,7 @@ TEST_F(DomDistillerStoreTest, TestAttachments) {
attachments.set_distilled_article(article_proto);
store_->UpdateAttachments(
entry.entry_id(),
- make_scoped_ptr(new ArticleAttachmentsData(attachments)),
+ base::WrapUnique(new ArticleAttachmentsData(attachments)),
callbacks.UpdateCallback());
EXPECT_CALL(callbacks, Update(true));
base::RunLoop().RunUntilIdle();
@@ -509,8 +512,9 @@ TEST_F(DomDistillerStoreTest, TestSyncMergeWithSecondDomDistillerStore) {
FakeDB<ArticleEntry>* other_fake_db =
new FakeDB<ArticleEntry>(&other_db_model);
- scoped_ptr<DomDistillerStore> owned_other_store(new DomDistillerStore(
- scoped_ptr<leveldb_proto::ProtoDatabase<ArticleEntry> >(other_fake_db),
+ std::unique_ptr<DomDistillerStore> owned_other_store(new DomDistillerStore(
+ std::unique_ptr<leveldb_proto::ProtoDatabase<ArticleEntry>>(
+ other_fake_db),
std::vector<ArticleEntry>(),
base::FilePath(FILE_PATH_LITERAL("/fake/other/path"))));
DomDistillerStore* other_store = owned_other_store.get();
@@ -525,7 +529,7 @@ TEST_F(DomDistillerStoreTest, TestSyncMergeWithSecondDomDistillerStore) {
store_->MergeDataAndStartSyncing(
kDomDistillerModelType, SyncDataFromEntryMap(other_db_model),
std::move(owned_other_store),
- make_scoped_ptr<SyncErrorFactory>(other_error_factory));
+ base::WrapUnique<SyncErrorFactory>(other_error_factory));
EXPECT_TRUE(AreEntriesEqual(store_->GetEntries(), expected_model));
EXPECT_TRUE(AreEntriesEqual(other_store->GetEntries(), expected_model));
@@ -585,8 +589,8 @@ TEST_F(DomDistillerStoreTest, TestObserver) {
new FakeSyncChangeProcessor(&fake_model);
store_->MergeDataAndStartSyncing(
kDomDistillerModelType, change_data,
- make_scoped_ptr<SyncChangeProcessor>(fake_sync_change_processor),
- make_scoped_ptr<SyncErrorFactory>(fake_error_factory));
+ base::WrapUnique<SyncChangeProcessor>(fake_sync_change_processor),
+ base::WrapUnique<SyncErrorFactory>(fake_error_factory));
}
} // namespace dom_distiller
diff --git a/chromium/components/dom_distiller/core/dom_distiller_test_util.cc b/chromium/components/dom_distiller/core/dom_distiller_test_util.cc
index 45ddf86e8bb..0b49d315934 100644
--- a/chromium/components/dom_distiller/core/dom_distiller_test_util.cc
+++ b/chromium/components/dom_distiller/core/dom_distiller_test_util.cc
@@ -94,7 +94,7 @@ DomDistillerStore* CreateStoreWithFakeDB(
FakeDB<ArticleEntry>* fake_db,
const FakeDB<ArticleEntry>::EntryMap& store_model) {
return new DomDistillerStore(
- scoped_ptr<leveldb_proto::ProtoDatabase<ArticleEntry> >(fake_db),
+ std::unique_ptr<leveldb_proto::ProtoDatabase<ArticleEntry>>(fake_db),
EntryMapToList(store_model), FakeDB<ArticleEntry>::DirectoryForTestDB());
}
diff --git a/chromium/components/dom_distiller/core/fake_distiller.cc b/chromium/components/dom_distiller/core/fake_distiller.cc
index 315490a49f2..ab64ce6e39e 100644
--- a/chromium/components/dom_distiller/core/fake_distiller.cc
+++ b/chromium/components/dom_distiller/core/fake_distiller.cc
@@ -11,7 +11,7 @@
#include "base/callback_helpers.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace dom_distiller {
@@ -42,7 +42,7 @@ FakeDistiller::~FakeDistiller() {
void FakeDistiller::DistillPage(
const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const DistillationFinishedCallback& article_callback,
const DistillationUpdateCallback& page_callback) {
url_ = url;
@@ -52,14 +52,14 @@ void FakeDistiller::DistillPage(
base::ResetAndReturn(&distillation_initiated_callback_).Run();
}
if (execute_callback_) {
- scoped_ptr<DistilledArticleProto> proto(new DistilledArticleProto);
+ std::unique_ptr<DistilledArticleProto> proto(new DistilledArticleProto);
proto->add_pages()->set_url(url_.spec());
PostDistillerCallback(std::move(proto));
}
}
void FakeDistiller::RunDistillerCallback(
- scoped_ptr<DistilledArticleProto> proto) {
+ std::unique_ptr<DistilledArticleProto> proto) {
ASSERT_FALSE(execute_callback_) << "Cannot explicitly run the distiller "
"callback for a fake distiller created "
"with automatic callback execution.";
@@ -71,16 +71,15 @@ void FakeDistiller::RunDistillerUpdateCallback(
page_callback_.Run(update);
}
-
void FakeDistiller::PostDistillerCallback(
- scoped_ptr<DistilledArticleProto> proto) {
+ std::unique_ptr<DistilledArticleProto> proto) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&FakeDistiller::RunDistillerCallbackInternal,
base::Unretained(this), base::Passed(&proto)));
}
void FakeDistiller::RunDistillerCallbackInternal(
- scoped_ptr<DistilledArticleProto> proto) {
+ std::unique_ptr<DistilledArticleProto> proto) {
EXPECT_FALSE(article_callback_.is_null());
base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_,
diff --git a/chromium/components/dom_distiller/core/fake_distiller.h b/chromium/components/dom_distiller/core/fake_distiller.h
index 87e3e6d12bf..94092d0105c 100644
--- a/chromium/components/dom_distiller/core/fake_distiller.h
+++ b/chromium/components/dom_distiller/core/fake_distiller.h
@@ -22,8 +22,9 @@ class MockDistillerFactory : public DistillerFactory {
MockDistillerFactory();
virtual ~MockDistillerFactory();
MOCK_METHOD0(CreateDistillerImpl, Distiller*());
- scoped_ptr<Distiller> CreateDistillerForUrl(const GURL& unused) override {
- return scoped_ptr<Distiller>(CreateDistillerImpl());
+ std::unique_ptr<Distiller> CreateDistillerForUrl(
+ const GURL& unused) override {
+ return std::unique_ptr<Distiller>(CreateDistillerImpl());
}
};
@@ -41,11 +42,11 @@ class FakeDistiller : public Distiller {
MOCK_METHOD0(Die, void());
void DistillPage(const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const DistillationFinishedCallback& article_callback,
const DistillationUpdateCallback& page_callback) override;
- void RunDistillerCallback(scoped_ptr<DistilledArticleProto> proto);
+ void RunDistillerCallback(std::unique_ptr<DistilledArticleProto> proto);
void RunDistillerUpdateCallback(const ArticleDistillationUpdate& update);
GURL GetUrl() { return url_; }
@@ -55,8 +56,9 @@ class FakeDistiller : public Distiller {
}
private:
- void PostDistillerCallback(scoped_ptr<DistilledArticleProto> proto);
- void RunDistillerCallbackInternal(scoped_ptr<DistilledArticleProto> proto);
+ void PostDistillerCallback(std::unique_ptr<DistilledArticleProto> proto);
+ void RunDistillerCallbackInternal(
+ std::unique_ptr<DistilledArticleProto> proto);
bool execute_callback_;
GURL url_;
diff --git a/chromium/components/dom_distiller/core/fake_distiller_page.h b/chromium/components/dom_distiller/core/fake_distiller_page.h
index 0c672932e5d..82829eb9293 100644
--- a/chromium/components/dom_distiller/core/fake_distiller_page.h
+++ b/chromium/components/dom_distiller/core/fake_distiller_page.h
@@ -16,13 +16,13 @@ class MockDistillerPageFactory : public DistillerPageFactory {
MockDistillerPageFactory();
~MockDistillerPageFactory() override;
MOCK_CONST_METHOD0(CreateDistillerPageImpl, DistillerPage*());
- scoped_ptr<DistillerPage> CreateDistillerPage(
+ std::unique_ptr<DistillerPage> CreateDistillerPage(
const gfx::Size& render_view_size) const override {
- return scoped_ptr<DistillerPage>(CreateDistillerPageImpl());
+ return std::unique_ptr<DistillerPage>(CreateDistillerPageImpl());
}
- scoped_ptr<DistillerPage> CreateDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) const override {
- return scoped_ptr<DistillerPage>(CreateDistillerPageImpl());
+ std::unique_ptr<DistillerPage> CreateDistillerPageWithHandle(
+ std::unique_ptr<SourcePageHandle> handle) const override {
+ return std::unique_ptr<DistillerPage>(CreateDistillerPageImpl());
}
};
diff --git a/chromium/components/dom_distiller/core/javascript/dom_distiller_viewer.js b/chromium/components/dom_distiller/core/javascript/dom_distiller_viewer.js
index 009f1f7b14e..641c2958e09 100644
--- a/chromium/components/dom_distiller/core/javascript/dom_distiller_viewer.js
+++ b/chromium/components/dom_distiller/core/javascript/dom_distiller_viewer.js
@@ -10,14 +10,6 @@ function addToPage(html) {
div.innerHTML = html;
document.getElementById('content').appendChild(div);
fillYouTubePlaceholders();
-
- if (typeof navigate_on_initial_content_load !== 'undefined' &&
- navigate_on_initial_content_load) {
- navigate_on_initial_content_load = false;
- setTimeout(function() {
- window.location = window.location + "#loaded";
- }, 0);
- }
}
function fillYouTubePlaceholders() {
@@ -48,6 +40,15 @@ function fillYouTubePlaceholders() {
function showLoadingIndicator(isLastPage) {
document.getElementById('loadingIndicator').className =
isLastPage ? 'hidden' : 'visible';
+ // This function will be one of the last things to occur when a page is
+ // loaded. This is temporarily used to signal print preview to generate
+ // a PDF.
+ if (isLastPage && typeof isPrintPreviewDistiller !== 'undefined'
+ && isPrintPreviewDistiller) {
+ setTimeout(function() {
+ window.location = window.location + "#loaded";
+ }, 0);
+ }
}
// Sets the title.
diff --git a/chromium/components/dom_distiller/core/page_features.cc b/chromium/components/dom_distiller/core/page_features.cc
index e28cf01c450..a222bd3f2d6 100644
--- a/chromium/components/dom_distiller/core/page_features.cc
+++ b/chromium/components/dom_distiller/core/page_features.cc
@@ -6,10 +6,10 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "third_party/re2/src/re2/re2.h"
#include "url/gurl.h"
@@ -152,7 +152,7 @@ std::vector<double> CalculateDerivedFeaturesFromJSON(
return std::vector<double>();
}
- scoped_ptr<base::Value> json = base::JSONReader::Read(stringified);
+ std::unique_ptr<base::Value> json = base::JSONReader::Read(stringified);
if (!json) {
return std::vector<double>();
}
diff --git a/chromium/components/dom_distiller/core/page_features_unittest.cc b/chromium/components/dom_distiller/core/page_features_unittest.cc
index eaea31e1107..6d0bea34b80 100644
--- a/chromium/components/dom_distiller/core/page_features_unittest.cc
+++ b/chromium/components/dom_distiller/core/page_features_unittest.cc
@@ -6,13 +6,13 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -38,10 +38,10 @@ TEST(DomDistillerPageFeaturesTest, TestCalculateDerivedFeatures) {
"components/test/data/dom_distiller/derived_features.json"),
&expected_output_data));
- scoped_ptr<base::Value> input_json = base::JSONReader::Read(input_data);
+ std::unique_ptr<base::Value> input_json = base::JSONReader::Read(input_data);
ASSERT_TRUE(input_json);
- scoped_ptr<base::Value> expected_output_json =
+ std::unique_ptr<base::Value> expected_output_json =
base::JSONReader::Read(expected_output_data);
ASSERT_TRUE(expected_output_json);
@@ -74,7 +74,7 @@ TEST(DomDistillerPageFeaturesTest, TestCalculateDerivedFeatures) {
// JSON (and not a base::Value of the JSON itself)
std::string stringified_json;
ASSERT_TRUE(base::JSONWriter::Write(*core_features, &stringified_json));
- scoped_ptr<base::Value> stringified_value(
+ std::unique_ptr<base::Value> stringified_value(
new base::StringValue(stringified_json));
std::vector<double> derived(
CalculateDerivedFeaturesFromJSON(stringified_value.get()));
diff --git a/chromium/components/dom_distiller/core/task_tracker.cc b/chromium/components/dom_distiller/core/task_tracker.cc
index abb4565062c..0a967cfbf31 100644
--- a/chromium/components/dom_distiller/core/task_tracker.cc
+++ b/chromium/components/dom_distiller/core/task_tracker.cc
@@ -11,7 +11,7 @@
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "components/dom_distiller/core/distilled_content_store.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
#include "components/dom_distiller/core/proto/distilled_page.pb.h"
@@ -44,8 +44,9 @@ TaskTracker::~TaskTracker() {
DCHECK(viewers_.empty());
}
-void TaskTracker::StartDistiller(DistillerFactory* factory,
- scoped_ptr<DistillerPage> distiller_page) {
+void TaskTracker::StartDistiller(
+ DistillerFactory* factory,
+ std::unique_ptr<DistillerPage> distiller_page) {
if (distiller_) {
return;
}
@@ -82,7 +83,8 @@ void TaskTracker::AddSaveCallback(const SaveCallback& callback) {
}
}
-scoped_ptr<ViewerHandle> TaskTracker::AddViewer(ViewRequestDelegate* delegate) {
+std::unique_ptr<ViewerHandle> TaskTracker::AddViewer(
+ ViewRequestDelegate* delegate) {
viewers_.push_back(delegate);
if (content_ready_) {
// Distillation for this task has already completed, and so the delegate can
@@ -91,7 +93,7 @@ scoped_ptr<ViewerHandle> TaskTracker::AddViewer(ViewRequestDelegate* delegate) {
FROM_HERE, base::Bind(&TaskTracker::NotifyViewer,
weak_ptr_factory_.GetWeakPtr(), delegate));
}
- return scoped_ptr<ViewerHandle>(new ViewerHandle(base::Bind(
+ return std::unique_ptr<ViewerHandle>(new ViewerHandle(base::Bind(
&TaskTracker::RemoveViewer, weak_ptr_factory_.GetWeakPtr(), delegate)));
}
@@ -140,7 +142,7 @@ void TaskTracker::ScheduleSaveCallbacks(bool distillation_succeeded) {
}
void TaskTracker::OnDistillerFinished(
- scoped_ptr<DistilledArticleProto> distilled_article) {
+ std::unique_ptr<DistilledArticleProto> distilled_article) {
if (content_ready_) {
return;
}
@@ -165,7 +167,7 @@ void TaskTracker::CancelPendingSources() {
void TaskTracker::OnBlobFetched(
bool success,
- scoped_ptr<DistilledArticleProto> distilled_article) {
+ std::unique_ptr<DistilledArticleProto> distilled_article) {
blob_fetcher_running_ = false;
if (content_ready_) {
@@ -191,7 +193,7 @@ void TaskTracker::ContentSourceFinished() {
}
void TaskTracker::DistilledArticleReady(
- scoped_ptr<DistilledArticleProto> distilled_article) {
+ std::unique_ptr<DistilledArticleProto> distilled_article) {
DCHECK(!content_ready_);
if (distilled_article->pages_size() == 0) {
diff --git a/chromium/components/dom_distiller/core/task_tracker.h b/chromium/components/dom_distiller/core/task_tracker.h
index 2a59c5b1c16..14ebd11def6 100644
--- a/chromium/components/dom_distiller/core/task_tracker.h
+++ b/chromium/components/dom_distiller/core/task_tracker.h
@@ -84,7 +84,7 @@ class TaskTracker {
// |factory| will not be stored after this call.
void StartDistiller(DistillerFactory* factory,
- scoped_ptr<DistillerPage> distiller_page);
+ std::unique_ptr<DistillerPage> distiller_page);
void StartBlobFetcher();
void AddSaveCallback(const SaveCallback& callback);
@@ -92,7 +92,7 @@ class TaskTracker {
void CancelSaveCallbacks();
// The ViewerHandle should be destroyed before the ViewRequestDelegate.
- scoped_ptr<ViewerHandle> AddViewer(ViewRequestDelegate* delegate);
+ std::unique_ptr<ViewerHandle> AddViewer(ViewRequestDelegate* delegate);
const std::string& GetEntryId() const;
bool HasEntryId(const std::string& entry_id) const;
@@ -102,14 +102,15 @@ class TaskTracker {
void OnArticleDistillationUpdated(
const ArticleDistillationUpdate& article_update);
- void OnDistillerFinished(scoped_ptr<DistilledArticleProto> distilled_article);
+ void OnDistillerFinished(
+ std::unique_ptr<DistilledArticleProto> distilled_article);
void OnBlobFetched(bool success,
- scoped_ptr<DistilledArticleProto> distilled_article);
+ std::unique_ptr<DistilledArticleProto> distilled_article);
void RemoveViewer(ViewRequestDelegate* delegate);
void DistilledArticleReady(
- scoped_ptr<DistilledArticleProto> distilled_article);
+ std::unique_ptr<DistilledArticleProto> distilled_article);
// Posts a task to run DoSaveCallbacks with |distillation_succeeded|.
void ScheduleSaveCallbacks(bool distillation_succeeded);
@@ -137,11 +138,11 @@ class TaskTracker {
// made and removed when the corresponding ViewerHandle is destroyed.
std::vector<ViewRequestDelegate*> viewers_;
- scoped_ptr<Distiller> distiller_;
+ std::unique_ptr<Distiller> distiller_;
bool blob_fetcher_running_;
ArticleEntry entry_;
- scoped_ptr<DistilledArticleProto> distilled_article_;
+ std::unique_ptr<DistilledArticleProto> distilled_article_;
bool content_ready_;
diff --git a/chromium/components/dom_distiller/core/task_tracker_unittest.cc b/chromium/components/dom_distiller/core/task_tracker_unittest.cc
index bb5adce1ff5..b760b4abf82 100644
--- a/chromium/components/dom_distiller/core/task_tracker_unittest.cc
+++ b/chromium/components/dom_distiller/core/task_tracker_unittest.cc
@@ -77,7 +77,7 @@ class DomDistillerTaskTrackerTest : public testing::Test {
}
protected:
- scoped_ptr<base::MessageLoop> message_loop_;
+ std::unique_ptr<base::MessageLoop> message_loop_;
std::string entry_id_;
GURL page_0_url_;
GURL page_1_url_;
@@ -110,8 +110,10 @@ TEST_F(DomDistillerTaskTrackerTest, TestViewerCancelled) {
FakeViewRequestDelegate viewer_delegate;
FakeViewRequestDelegate viewer_delegate2;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
- scoped_ptr<ViewerHandle> handle2(task_tracker.AddViewer(&viewer_delegate2));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle2(
+ task_tracker.AddViewer(&viewer_delegate2));
EXPECT_FALSE(cancel_callback.Cancelled());
handle.reset();
@@ -127,7 +129,8 @@ TEST_F(DomDistillerTaskTrackerTest, TestViewerCancelledWithSaveRequest) {
GetDefaultEntry(), cancel_callback.GetCallback(), NULL);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
EXPECT_FALSE(cancel_callback.Cancelled());
MockSaveCallback save_callback;
@@ -149,12 +152,14 @@ TEST_F(DomDistillerTaskTrackerTest, TestViewerNotifiedOnDistillationComplete) {
GetDefaultEntry(), cancel_callback.GetCallback(), NULL);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
base::RunLoop().RunUntilIdle();
EXPECT_CALL(viewer_delegate, OnArticleReady(_));
- task_tracker.StartDistiller(&distiller_factory, scoped_ptr<DistillerPage>());
+ task_tracker.StartDistiller(&distiller_factory,
+ std::unique_ptr<DistillerPage>());
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(cancel_callback.Cancelled());
@@ -171,14 +176,16 @@ TEST_F(DomDistillerTaskTrackerTest, TestDistillerFails) {
GetDefaultEntry(), cancel_callback.GetCallback(), NULL);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
base::RunLoop().RunUntilIdle();
EXPECT_CALL(viewer_delegate, OnArticleReady(_));
- task_tracker.StartDistiller(&distiller_factory, scoped_ptr<DistillerPage>());
+ task_tracker.StartDistiller(&distiller_factory,
+ std::unique_ptr<DistillerPage>());
distiller->RunDistillerCallback(
- scoped_ptr<DistilledArticleProto>(new DistilledArticleProto));
+ std::unique_ptr<DistilledArticleProto>(new DistilledArticleProto));
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(cancel_callback.Cancelled());
@@ -201,7 +208,8 @@ TEST_F(DomDistillerTaskTrackerTest,
EXPECT_CALL(save_callback, Save(_, _, _));
- task_tracker.StartDistiller(&distiller_factory, scoped_ptr<DistillerPage>());
+ task_tracker.StartDistiller(&distiller_factory,
+ std::unique_ptr<DistillerPage>());
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(cancel_callback.Cancelled());
@@ -230,7 +238,8 @@ TEST_F(DomDistillerTaskTrackerTest, TestBlobFetcher) {
entry_with_blob, cancel_callback.GetCallback(), &content_store);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
base::RunLoop().RunUntilIdle();
const DistilledArticleProto* distilled_article;
@@ -263,7 +272,8 @@ TEST_F(DomDistillerTaskTrackerTest, TestBlobFetcherFinishesFirst) {
entry_with_blob, cancel_callback.GetCallback(), &content_store);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
base::RunLoop().RunUntilIdle();
DistilledArticleProto distilled_article;
@@ -274,7 +284,8 @@ TEST_F(DomDistillerTaskTrackerTest, TestBlobFetcherFinishesFirst) {
EXPECT_CALL(*distiller, Die())
.WillOnce(testing::Assign(&distiller_destroyed, true));
- task_tracker.StartDistiller(&distiller_factory, scoped_ptr<DistillerPage>());
+ task_tracker.StartDistiller(&distiller_factory,
+ std::unique_ptr<DistillerPage>());
task_tracker.StartBlobFetcher();
base::RunLoop().RunUntilIdle();
@@ -295,7 +306,7 @@ TEST_F(DomDistillerTaskTrackerTest, TestBlobFetcherWithoutBlob) {
ArticleEntry entry(GetDefaultEntry());
InMemoryContentStore content_store(kDefaultMaxNumCachedEntries);
- scoped_ptr<DistilledArticleProto> distilled_article(
+ std::unique_ptr<DistilledArticleProto> distilled_article(
new DistilledArticleProto(CreateDistilledArticleForEntry(entry)));
TestCancelCallback cancel_callback;
@@ -303,11 +314,13 @@ TEST_F(DomDistillerTaskTrackerTest, TestBlobFetcherWithoutBlob) {
GetDefaultEntry(), cancel_callback.GetCallback(), &content_store);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
base::RunLoop().RunUntilIdle();
task_tracker.StartBlobFetcher();
- task_tracker.StartDistiller(&distiller_factory, scoped_ptr<DistillerPage>());
+ task_tracker.StartDistiller(&distiller_factory,
+ std::unique_ptr<DistillerPage>());
// OnArticleReady shouldn't be called until distillation finishes (i.e. the
// blob fetcher shouldn't return distilled content).
@@ -335,25 +348,26 @@ TEST_F(DomDistillerTaskTrackerTest, TestDistillerFailsFirst) {
GetDefaultEntry(), cancel_callback.GetCallback(), &content_store);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
DistilledContentStore::LoadCallback content_store_load_callback;
EXPECT_CALL(content_store, LoadContent(_, _))
.WillOnce(testing::SaveArg<1>(&content_store_load_callback));
- task_tracker.StartDistiller(&distiller_factory, scoped_ptr<DistillerPage>());
+ task_tracker.StartDistiller(&distiller_factory,
+ std::unique_ptr<DistillerPage>());
task_tracker.StartBlobFetcher();
EXPECT_CALL(viewer_delegate, OnArticleReady(_)).Times(0);
distiller->RunDistillerCallback(
- scoped_ptr<DistilledArticleProto>(new DistilledArticleProto));
+ std::unique_ptr<DistilledArticleProto>(new DistilledArticleProto));
base::RunLoop().RunUntilIdle();
EXPECT_CALL(viewer_delegate, OnArticleReady(_));
content_store_load_callback.Run(
- true,
- scoped_ptr<DistilledArticleProto>(
- new DistilledArticleProto(CreateDistilledArticleForEntry(entry))));
+ true, std::unique_ptr<DistilledArticleProto>(new DistilledArticleProto(
+ CreateDistilledArticleForEntry(entry))));
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(cancel_callback.Cancelled());
@@ -375,17 +389,19 @@ TEST_F(DomDistillerTaskTrackerTest, ContentIsSaved) {
GetDefaultEntry(), cancel_callback.GetCallback(), &content_store);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate));
+ std::unique_ptr<ViewerHandle> handle(
+ task_tracker.AddViewer(&viewer_delegate));
DistilledArticleProto stored_distilled_article;
DistilledContentStore::LoadCallback content_store_load_callback;
EXPECT_CALL(content_store, SaveContent(_, _, _))
.WillOnce(testing::SaveArg<1>(&stored_distilled_article));
- task_tracker.StartDistiller(&distiller_factory, scoped_ptr<DistillerPage>());
+ task_tracker.StartDistiller(&distiller_factory,
+ std::unique_ptr<DistillerPage>());
EXPECT_CALL(viewer_delegate, OnArticleReady(_));
- distiller->RunDistillerCallback(scoped_ptr<DistilledArticleProto>(
+ distiller->RunDistillerCallback(std::unique_ptr<DistilledArticleProto>(
new DistilledArticleProto(distilled_article)));
base::RunLoop().RunUntilIdle();
diff --git a/chromium/components/dom_distiller/core/url_constants.cc b/chromium/components/dom_distiller/core/url_constants.cc
index cc54b289dc2..acacffc00a8 100644
--- a/chromium/components/dom_distiller/core/url_constants.cc
+++ b/chromium/components/dom_distiller/core/url_constants.cc
@@ -9,6 +9,7 @@ namespace dom_distiller {
const char kDomDistillerScheme[] = "chrome-distiller";
const char kEntryIdKey[] = "entry_id";
const char kUrlKey[] = "url";
+const char kTimeKey[] = "time";
const char kViewerCssPath[] = "dom_distiller_viewer.css";
const char kViewerLoadingImagePath[] = "dom_distiller_material_spinner.svg";
const char kViewerSaveFontScalingPath[] = "savefontscaling/";
diff --git a/chromium/components/dom_distiller/core/url_constants.h b/chromium/components/dom_distiller/core/url_constants.h
index 867141e8149..d54635996be 100644
--- a/chromium/components/dom_distiller/core/url_constants.h
+++ b/chromium/components/dom_distiller/core/url_constants.h
@@ -10,6 +10,7 @@ namespace dom_distiller {
extern const char kDomDistillerScheme[];
extern const char kEntryIdKey[];
extern const char kUrlKey[];
+extern const char kTimeKey[];
extern const char kViewerCssPath[];
extern const char kViewerLoadingImagePath[];
extern const char kViewerSaveFontScalingPath[];
diff --git a/chromium/components/dom_distiller/core/url_utils.cc b/chromium/components/dom_distiller/core/url_utils.cc
index cfe4fcb9a21..c1bb35fcaf4 100644
--- a/chromium/components/dom_distiller/core/url_utils.cc
+++ b/chromium/components/dom_distiller/core/url_utils.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/guid.h"
+#include "base/strings/string_number_conversions.h"
#include "components/dom_distiller/core/url_constants.h"
#include "grit/components_resources.h"
#include "net/base/url_util.h"
@@ -30,8 +31,13 @@ const GURL GetDistillerViewUrlFromEntryId(const std::string& scheme,
}
const GURL GetDistillerViewUrlFromUrl(const std::string& scheme,
- const GURL& view_url) {
+ const GURL& view_url,
+ int64_t start_time_ms) {
GURL url(scheme + "://" + base::GenerateGUID());
+ if (start_time_ms > 0) {
+ url = net::AppendOrReplaceQueryParameter(url, kTimeKey,
+ base::IntToString(start_time_ms));
+ }
return net::AppendOrReplaceQueryParameter(url, kUrlKey, view_url.spec());
}
@@ -45,6 +51,21 @@ const GURL GetOriginalUrlFromDistillerUrl(const GURL& url) {
return GURL(original_url_str);
}
+int64_t GetTimeFromDistillerUrl(const GURL& url) {
+ if (!dom_distiller::url_utils::IsDistilledPage(url))
+ return 0;
+
+ std::string time_str;
+ if (!net::GetValueForKeyInQuery(url, kTimeKey, &time_str))
+ return 0;
+
+ int64_t time_int = 0;
+ if (!base::StringToInt64(time_str, &time_int))
+ return 0;
+
+ return time_int;
+}
+
std::string GetValueForKeyInUrl(const GURL& url, const std::string& key) {
if (!url.is_valid())
return "";
diff --git a/chromium/components/dom_distiller/core/url_utils.h b/chromium/components/dom_distiller/core/url_utils.h
index 71a7d5ce87a..8f6593617a6 100644
--- a/chromium/components/dom_distiller/core/url_utils.h
+++ b/chromium/components/dom_distiller/core/url_utils.h
@@ -19,12 +19,17 @@ const GURL GetDistillerViewUrlFromEntryId(const std::string& scheme,
// Returns the URL for viewing distilled content for a URL.
const GURL GetDistillerViewUrlFromUrl(const std::string& scheme,
- const GURL& view_url);
+ const GURL& view_url,
+ int64_t start_time_ms = 0);
// Returns the original URL from the distilled URL.
// If the URL is not distilled, it is returned as is.
const GURL GetOriginalUrlFromDistillerUrl(const GURL& distilled_url);
+// Returns the starting time from the distilled URL.
+// Returns 0 when not available or on error.
+int64_t GetTimeFromDistillerUrl(const GURL& url);
+
// Returns the value of the query parameter for the given |key| for a given URL.
// If the URL is invalid or if the key is not found, returns an empty string.
// If there are multiple keys found in the URL, returns the value for the first
diff --git a/chromium/components/dom_distiller/core/url_utils_unittest.cc b/chromium/components/dom_distiller/core/url_utils_unittest.cc
index 5572a0c1ae3..5604417811a 100644
--- a/chromium/components/dom_distiller/core/url_utils_unittest.cc
+++ b/chromium/components/dom_distiller/core/url_utils_unittest.cc
@@ -43,7 +43,7 @@ TEST(DomDistillerUrlUtilsTest, TestGetValueForKeyInUrlPathQuery) {
std::string ThroughDistiller(const std::string& url) {
return GetOriginalUrlFromDistillerUrl(
- GetDistillerViewUrlFromUrl(kDomDistillerScheme, GURL(url))).spec();
+ GetDistillerViewUrlFromUrl(kDomDistillerScheme, GURL(url), 123)).spec();
}
std::string GetOriginalUrlFromDistillerUrl(const std::string& url) {
diff --git a/chromium/components/dom_distiller/core/viewer.cc b/chromium/components/dom_distiller/core/viewer.cc
index f0ebdc934de..9cac0c5138b 100644
--- a/chromium/components/dom_distiller/core/viewer.cc
+++ b/chromium/components/dom_distiller/core/viewer.cc
@@ -4,11 +4,11 @@
#include "components/dom_distiller/core/viewer.h"
+#include <memory>
#include <string>
#include <vector>
#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -267,7 +267,7 @@ const std::string GetJavaScript() {
.as_string();
}
-scoped_ptr<ViewerHandle> CreateViewRequest(
+std::unique_ptr<ViewerHandle> CreateViewRequest(
DomDistillerServiceInterface* dom_distiller_service,
const std::string& path,
ViewRequestDelegate* view_request_delegate,
@@ -285,7 +285,7 @@ scoped_ptr<ViewerHandle> CreateViewRequest(
if (has_valid_entry_id && has_valid_url) {
// It is invalid to specify a query param for both |kEntryIdKey| and
// |kUrlKey|.
- return scoped_ptr<ViewerHandle>();
+ return std::unique_ptr<ViewerHandle>();
}
if (has_valid_entry_id) {
@@ -301,7 +301,7 @@ scoped_ptr<ViewerHandle> CreateViewRequest(
}
// It is invalid to not specify a query param for |kEntryIdKey| or |kUrlKey|.
- return scoped_ptr<ViewerHandle>();
+ return std::unique_ptr<ViewerHandle>();
}
const std::string GetDistilledPageThemeJs(DistilledPagePrefs::Theme theme) {
diff --git a/chromium/components/dom_distiller/core/viewer.h b/chromium/components/dom_distiller/core/viewer.h
index 2335942e59a..3f924da6b85 100644
--- a/chromium/components/dom_distiller/core/viewer.h
+++ b/chromium/components/dom_distiller/core/viewer.h
@@ -5,10 +5,10 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_
#define COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_
+#include <memory>
#include <string>
#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "ui/gfx/geometry/size.h"
@@ -79,7 +79,7 @@ const std::string GetJavaScript();
// Based on the given path, calls into the DomDistillerServiceInterface for
// viewing distilled content based on the |path|.
-scoped_ptr<ViewerHandle> CreateViewRequest(
+std::unique_ptr<ViewerHandle> CreateViewRequest(
DomDistillerServiceInterface* dom_distiller_service,
const std::string& path,
ViewRequestDelegate* view_request_delegate,
diff --git a/chromium/components/dom_distiller/core/viewer_unittest.cc b/chromium/components/dom_distiller/core/viewer_unittest.cc
index 2e7478a047a..009640f68d2 100644
--- a/chromium/components/dom_distiller/core/viewer_unittest.cc
+++ b/chromium/components/dom_distiller/core/viewer_unittest.cc
@@ -35,7 +35,7 @@ class TestDomDistillerService : public DomDistillerServiceInterface {
const ArticleAvailableCallback&));
const std::string AddToList(
const GURL& url,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const ArticleAvailableCallback& article_cb) override {
return AddToList(url, distiller_page.get(), article_cb);
}
@@ -45,30 +45,30 @@ class TestDomDistillerService : public DomDistillerServiceInterface {
MOCK_METHOD1(AddObserver, void(DomDistillerObserver*));
MOCK_METHOD1(RemoveObserver, void(DomDistillerObserver*));
MOCK_METHOD0(ViewUrlImpl, ViewerHandle*());
- scoped_ptr<ViewerHandle> ViewUrl(
+ std::unique_ptr<ViewerHandle> ViewUrl(
ViewRequestDelegate*,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const GURL&) override {
- return scoped_ptr<ViewerHandle>(ViewUrlImpl());
+ return std::unique_ptr<ViewerHandle>(ViewUrlImpl());
}
MOCK_METHOD0(ViewEntryImpl, ViewerHandle*());
- scoped_ptr<ViewerHandle> ViewEntry(
+ std::unique_ptr<ViewerHandle> ViewEntry(
ViewRequestDelegate*,
- scoped_ptr<DistillerPage> distiller_page,
+ std::unique_ptr<DistillerPage> distiller_page,
const std::string&) override {
- return scoped_ptr<ViewerHandle>(ViewEntryImpl());
+ return std::unique_ptr<ViewerHandle>(ViewEntryImpl());
}
MOCK_METHOD0(RemoveEntryImpl, ArticleEntry*());
- scoped_ptr<ArticleEntry> RemoveEntry(const std::string&) override {
- return scoped_ptr<ArticleEntry>(RemoveEntryImpl());
+ std::unique_ptr<ArticleEntry> RemoveEntry(const std::string&) override {
+ return std::unique_ptr<ArticleEntry>(RemoveEntryImpl());
}
- scoped_ptr<DistillerPage> CreateDefaultDistillerPage(
+ std::unique_ptr<DistillerPage> CreateDefaultDistillerPage(
const gfx::Size& render_view_size) override {
- return scoped_ptr<DistillerPage>();
+ return std::unique_ptr<DistillerPage>();
}
- scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) override {
- return scoped_ptr<DistillerPage>();
+ std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
+ std::unique_ptr<SourcePageHandle> handle) override {
+ return std::unique_ptr<DistillerPage>();
}
DistilledPagePrefs* GetDistilledPagePrefs() override;
};
@@ -78,18 +78,18 @@ class DomDistillerViewerTest : public testing::Test {
void SetUp() override { service_.reset(new TestDomDistillerService()); }
protected:
- scoped_ptr<ViewerHandle> CreateViewRequest(
+ std::unique_ptr<ViewerHandle> CreateViewRequest(
const std::string& path,
ViewRequestDelegate* view_request_delegate) {
return viewer::CreateViewRequest(
service_.get(), path, view_request_delegate, gfx::Size());
}
- scoped_ptr<TestDomDistillerService> service_;
+ std::unique_ptr<TestDomDistillerService> service_;
};
TEST_F(DomDistillerViewerTest, TestCreatingViewUrlRequest) {
- scoped_ptr<FakeViewRequestDelegate> view_request_delegate(
+ std::unique_ptr<FakeViewRequestDelegate> view_request_delegate(
new FakeViewRequestDelegate());
ViewerHandle* viewer_handle(new ViewerHandle(ViewerHandle::CancelCallback()));
EXPECT_CALL(*service_.get(), ViewUrlImpl())
@@ -101,7 +101,7 @@ TEST_F(DomDistillerViewerTest, TestCreatingViewUrlRequest) {
}
TEST_F(DomDistillerViewerTest, TestCreatingViewEntryRequest) {
- scoped_ptr<FakeViewRequestDelegate> view_request_delegate(
+ std::unique_ptr<FakeViewRequestDelegate> view_request_delegate(
new FakeViewRequestDelegate());
ViewerHandle* viewer_handle(new ViewerHandle(ViewerHandle::CancelCallback()));
EXPECT_CALL(*service_.get(), ViewEntryImpl())
@@ -112,7 +112,7 @@ TEST_F(DomDistillerViewerTest, TestCreatingViewEntryRequest) {
}
TEST_F(DomDistillerViewerTest, TestCreatingInvalidViewRequest) {
- scoped_ptr<FakeViewRequestDelegate> view_request_delegate(
+ std::unique_ptr<FakeViewRequestDelegate> view_request_delegate(
new FakeViewRequestDelegate());
EXPECT_CALL(*service_.get(), ViewEntryImpl()).Times(0);
EXPECT_CALL(*service_.get(), ViewUrlImpl()).Times(0);
diff --git a/chromium/components/dom_distiller/ios/distiller_page_factory_ios.h b/chromium/components/dom_distiller/ios/distiller_page_factory_ios.h
index ae7f418d37b..6af72b1dde7 100644
--- a/chromium/components/dom_distiller/ios/distiller_page_factory_ios.h
+++ b/chromium/components/dom_distiller/ios/distiller_page_factory_ios.h
@@ -5,7 +5,8 @@
#ifndef COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_FACTORY_IOS_H_
#define COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_FACTORY_IOS_H_
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "components/dom_distiller/core/distiller_page.h"
namespace web {
@@ -24,10 +25,10 @@ class DistillerPageFactoryIOS : public DistillerPageFactory {
DistillerPageFactoryIOS(web::BrowserState* browser_state);
// Implementation of DistillerPageFactory:
- scoped_ptr<DistillerPage> CreateDistillerPage(
+ std::unique_ptr<DistillerPage> CreateDistillerPage(
const gfx::Size& view_size) const override;
- scoped_ptr<DistillerPage> CreateDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) const override;
+ std::unique_ptr<DistillerPage> CreateDistillerPageWithHandle(
+ std::unique_ptr<SourcePageHandle> handle) const override;
private:
web::BrowserState* browser_state_;
diff --git a/chromium/components/dom_distiller/ios/distiller_page_factory_ios.mm b/chromium/components/dom_distiller/ios/distiller_page_factory_ios.mm
index 20e9af90d23..ad355f9cd18 100644
--- a/chromium/components/dom_distiller/ios/distiller_page_factory_ios.mm
+++ b/chromium/components/dom_distiller/ios/distiller_page_factory_ios.mm
@@ -4,6 +4,7 @@
#include "components/dom_distiller/ios/distiller_page_factory_ios.h"
+#include "base/memory/ptr_util.h"
#include "components/dom_distiller/ios/distiller_page_ios.h"
#include "ios/web/public/browser_state.h"
@@ -14,15 +15,15 @@ DistillerPageFactoryIOS::DistillerPageFactoryIOS(
: browser_state_(browser_state) {
}
-scoped_ptr<DistillerPage> DistillerPageFactoryIOS::CreateDistillerPage(
+std::unique_ptr<DistillerPage> DistillerPageFactoryIOS::CreateDistillerPage(
const gfx::Size& view_size) const {
- return make_scoped_ptr<DistillerPage>(new DistillerPageIOS(browser_state_));
+ return base::WrapUnique<DistillerPage>(new DistillerPageIOS(browser_state_));
}
-scoped_ptr<DistillerPage>
+std::unique_ptr<DistillerPage>
DistillerPageFactoryIOS::CreateDistillerPageWithHandle(
- scoped_ptr<SourcePageHandle> handle) const {
- return make_scoped_ptr<DistillerPage>(new DistillerPageIOS(browser_state_));
+ std::unique_ptr<SourcePageHandle> handle) const {
+ return base::WrapUnique<DistillerPage>(new DistillerPageIOS(browser_state_));
}
} // namespace dom_distiller
diff --git a/chromium/components/dom_distiller/ios/distiller_page_ios.h b/chromium/components/dom_distiller/ios/distiller_page_ios.h
index c9320d10bdd..2103959a76e 100644
--- a/chromium/components/dom_distiller/ios/distiller_page_ios.h
+++ b/chromium/components/dom_distiller/ios/distiller_page_ios.h
@@ -5,9 +5,9 @@
#ifndef COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_
#define COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "components/dom_distiller/core/distiller_page.h"
#include "ios/web/public/web_state/web_state_observer.h"
@@ -49,8 +49,8 @@ class DistillerPageIOS : public DistillerPage {
web::BrowserState* browser_state_;
GURL url_;
std::string script_;
- scoped_ptr<ios::WebControllerProvider> provider_;
- scoped_ptr<DistillerWebStateObserver> web_state_observer_;
+ std::unique_ptr<ios::WebControllerProvider> provider_;
+ std::unique_ptr<DistillerWebStateObserver> web_state_observer_;
base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_;
};
diff --git a/chromium/components/dom_distiller/ios/distiller_page_ios.mm b/chromium/components/dom_distiller/ios/distiller_page_ios.mm
index 0009e5bdad0..a20326d2b7e 100644
--- a/chromium/components/dom_distiller/ios/distiller_page_ios.mm
+++ b/chromium/components/dom_distiller/ios/distiller_page_ios.mm
@@ -103,9 +103,9 @@ void DistillerPageIOS::OnLoadURLDone(
}
void DistillerPageIOS::HandleJavaScriptResultString(NSString* result) {
- scoped_ptr<base::Value> resultValue = base::Value::CreateNullValue();
+ std::unique_ptr<base::Value> resultValue = base::Value::CreateNullValue();
if (result.length) {
- scoped_ptr<base::Value> dictionaryValue =
+ std::unique_ptr<base::Value> dictionaryValue =
base::JSONReader::Read(base::SysNSStringToUTF8(result));
if (dictionaryValue &&
dictionaryValue->IsType(base::Value::TYPE_DICTIONARY)) {
diff --git a/chromium/components/dom_distiller/standalone/content_extractor_browsertest.cc b/chromium/components/dom_distiller/standalone/content_extractor_browsertest.cc
index 1636bc607ab..8e620b74fc3 100644
--- a/chromium/components/dom_distiller/standalone/content_extractor_browsertest.cc
+++ b/chromium/components/dom_distiller/standalone/content_extractor_browsertest.cc
@@ -15,7 +15,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
#include "components/dom_distiller/content/browser/distiller_page_web_contents.h"
#include "components/dom_distiller/core/article_entry.h"
@@ -31,6 +31,7 @@
#include "components/pref_registry/testing_pref_service_syncable.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/content_browser_test.h"
#include "content/shell/browser/shell.h"
@@ -55,7 +56,7 @@ typedef base::hash_map<std::string, std::string> FileToUrlMap;
class TestDistillerFactoryImpl : public DistillerFactory {
public:
TestDistillerFactoryImpl(
- scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory,
+ std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory,
const dom_distiller::proto::DomDistillerOptions& dom_distiller_options,
const FileToUrlMap& file_to_url_map)
: distiller_url_fetcher_factory_(
@@ -65,20 +66,20 @@ class TestDistillerFactoryImpl : public DistillerFactory {
~TestDistillerFactoryImpl() override {}
- scoped_ptr<Distiller> CreateDistillerForUrl(const GURL& url) override {
+ std::unique_ptr<Distiller> CreateDistillerForUrl(const GURL& url) override {
dom_distiller::proto::DomDistillerOptions options;
options = dom_distiller_options_;
FileToUrlMap::const_iterator it = file_to_url_map_.find(url.spec());
if (it != file_to_url_map_.end()) {
options.set_original_url(it->second);
}
- scoped_ptr<DistillerImpl> distiller(new DistillerImpl(
- *distiller_url_fetcher_factory_, options));
+ std::unique_ptr<DistillerImpl> distiller(
+ new DistillerImpl(*distiller_url_fetcher_factory_, options));
return std::move(distiller);
}
private:
- scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory_;
+ std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory_;
dom_distiller::proto::DomDistillerOptions dom_distiller_options_;
FileToUrlMap file_to_url_map_;
};
@@ -120,7 +121,7 @@ const char* kPaginationAlgo = "pagination-algo";
// Maximum number of concurrent started extractor requests.
const int kMaxExtractorTasks = 8;
-scoped_ptr<DomDistillerService> CreateDomDistillerService(
+std::unique_ptr<DomDistillerService> CreateDomDistillerService(
content::BrowserContext* context,
const base::FilePath& db_path,
const FileToUrlMap& file_to_url_map) {
@@ -130,16 +131,18 @@ scoped_ptr<DomDistillerService> CreateDomDistillerService(
// TODO(cjhopman): use an in-memory database instead of an on-disk one with
// temporary directory.
- scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry> > db(
+ std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry>> db(
new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>(
background_task_runner));
- scoped_ptr<DomDistillerStore> dom_distiller_store(
+ std::unique_ptr<DomDistillerStore> dom_distiller_store(
new DomDistillerStore(std::move(db), db_path));
- scoped_ptr<DistillerPageFactory> distiller_page_factory(
+ std::unique_ptr<DistillerPageFactory> distiller_page_factory(
new DistillerPageWebContentsFactory(context));
- scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory(
- new DistillerURLFetcherFactory(context->GetRequestContext()));
+ std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory(
+ new DistillerURLFetcherFactory(
+ content::BrowserContext::GetDefaultStoragePartition(context)
+ ->GetURLRequestContext()));
dom_distiller::proto::DomDistillerOptions options;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(kExtractTextOnly)) {
@@ -163,18 +166,20 @@ scoped_ptr<DomDistillerService> CreateDomDistillerService(
kPaginationAlgo));
}
- scoped_ptr<DistillerFactory> distiller_factory(new TestDistillerFactoryImpl(
- std::move(distiller_url_fetcher_factory), options, file_to_url_map));
+ std::unique_ptr<DistillerFactory> distiller_factory(
+ new TestDistillerFactoryImpl(std::move(distiller_url_fetcher_factory),
+ options, file_to_url_map));
// Setting up PrefService for DistilledPagePrefs.
user_prefs::TestingPrefServiceSyncable* pref_service =
new user_prefs::TestingPrefServiceSyncable();
DistilledPagePrefs::RegisterProfilePrefs(pref_service->registry());
- return scoped_ptr<DomDistillerService>(new DomDistillerService(
+ return std::unique_ptr<DomDistillerService>(new DomDistillerService(
std::move(dom_distiller_store), std::move(distiller_factory),
std::move(distiller_page_factory),
- scoped_ptr<DistilledPagePrefs>(new DistilledPagePrefs(pref_service))));
+ std::unique_ptr<DistilledPagePrefs>(
+ new DistilledPagePrefs(pref_service))));
}
void AddComponentsTestResources() {
@@ -308,7 +313,7 @@ class ContentExtractionRequest : public ViewRequestDelegate {
}
const DistilledArticleProto* article_proto_;
- scoped_ptr<ViewerHandle> viewer_handle_;
+ std::unique_ptr<ViewerHandle> viewer_handle_;
GURL url_;
base::Closure finished_callback_;
};
@@ -424,12 +429,14 @@ class ContentExtractor : public ContentBrowserTest {
size_t next_request_;
base::ScopedTempDir db_dir_;
- scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_;
- scoped_ptr<DomDistillerService> service_;
+ std::unique_ptr<net::ScopedDefaultHostResolverProc>
+ mock_host_resolver_override_;
+ std::unique_ptr<DomDistillerService> service_;
ScopedVector<ContentExtractionRequest> requests_;
std::string output_data_;
- scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_;
+ std::unique_ptr<google::protobuf::io::StringOutputStream>
+ protobuf_output_stream_;
};
IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) {
diff --git a/chromium/components/dom_distiller/webui/dom_distiller_handler.cc b/chromium/components/dom_distiller/webui/dom_distiller_handler.cc
index d70dce4798c..4fdf081a0a2 100644
--- a/chromium/components/dom_distiller/webui/dom_distiller_handler.cc
+++ b/chromium/components/dom_distiller/webui/dom_distiller_handler.cc
@@ -108,7 +108,7 @@ void DomDistillerHandler::HandleRequestEntries(const base::ListValue* args) {
++it) {
const ArticleEntry& article = *it;
DCHECK(IsEntryValid(article));
- scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
entry->SetString("entry_id", article.entry_id());
std::string title = (!article.has_title() || article.title().empty())
? article.entry_id()