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

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

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/dom_distiller/content/browser/distillable_page_utils_androi d.h" 5 #include "components/dom_distiller/content/browser/distillable_page_utils_androi d.h"
6 6
7 #include <memory>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "components/dom_distiller/content/browser/distillable_page_utils.h" 11 #include "components/dom_distiller/content/browser/distillable_page_utils.h"
11 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
12 #include "jni/DistillablePageUtils_jni.h" 13 #include "jni/DistillablePageUtils_jni.h"
13 14
14 using base::android::ScopedJavaGlobalRef; 15 using base::android::ScopedJavaGlobalRef;
15 16
16 namespace dom_distiller { 17 namespace dom_distiller {
17 namespace android { 18 namespace android {
18 namespace { 19 namespace {
19 void OnIsPageDistillableResult( 20 void OnIsPageDistillableResult(
20 scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder, 21 std::unique_ptr<ScopedJavaGlobalRef<jobject>> callback_holder,
21 bool isDistillable) { 22 bool isDistillable) {
22 Java_DistillablePageUtils_callOnIsPageDistillableResult( 23 Java_DistillablePageUtils_callOnIsPageDistillableResult(
23 base::android::AttachCurrentThread(), callback_holder->obj(), 24 base::android::AttachCurrentThread(), callback_holder->obj(),
24 isDistillable); 25 isDistillable);
25 } 26 }
26 27
27 void OnIsPageDistillableUpdate( 28 void OnIsPageDistillableUpdate(
28 ScopedJavaGlobalRef<jobject>* callback_holder, 29 ScopedJavaGlobalRef<jobject>* callback_holder,
29 bool isDistillable, bool isLast) { 30 bool isDistillable, bool isLast) {
30 Java_DistillablePageUtils_callOnIsPageDistillableUpdate( 31 Java_DistillablePageUtils_callOnIsPageDistillableUpdate(
31 base::android::AttachCurrentThread(), callback_holder->obj(), 32 base::android::AttachCurrentThread(), callback_holder->obj(),
32 isDistillable, isLast); 33 isDistillable, isLast);
33 } 34 }
34 } // namespace 35 } // namespace
35 36
36 static void IsPageDistillable(JNIEnv* env, 37 static void IsPageDistillable(JNIEnv* env,
37 const JavaParamRef<jclass>& jcaller, 38 const JavaParamRef<jclass>& jcaller,
38 const JavaParamRef<jobject>& webContents, 39 const JavaParamRef<jobject>& webContents,
39 jboolean is_mobile_optimized, 40 jboolean is_mobile_optimized,
40 const JavaParamRef<jobject>& callback) { 41 const JavaParamRef<jobject>& callback) {
41 content::WebContents* web_contents( 42 content::WebContents* web_contents(
42 content::WebContents::FromJavaWebContents(webContents)); 43 content::WebContents::FromJavaWebContents(webContents));
43 scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder( 44 std::unique_ptr<ScopedJavaGlobalRef<jobject>> callback_holder(
44 new ScopedJavaGlobalRef<jobject>()); 45 new ScopedJavaGlobalRef<jobject>());
45 callback_holder->Reset(env, callback); 46 callback_holder->Reset(env, callback);
46 47
47 if (!web_contents) { 48 if (!web_contents) {
48 base::MessageLoop::current()->PostTask( 49 base::MessageLoop::current()->PostTask(
49 FROM_HERE, base::Bind(OnIsPageDistillableResult, 50 FROM_HERE, base::Bind(OnIsPageDistillableResult,
50 base::Passed(&callback_holder), false)); 51 base::Passed(&callback_holder), false));
51 return; 52 return;
52 } 53 }
53 IsDistillablePage( 54 IsDistillablePage(
(...skipping 20 matching lines...) Expand all
74 base::Bind(OnIsPageDistillableUpdate, base::Owned(callback_holder)); 75 base::Bind(OnIsPageDistillableUpdate, base::Owned(callback_holder));
75 setDelegate(web_contents, delegate); 76 setDelegate(web_contents, delegate);
76 } 77 }
77 78
78 bool RegisterDistillablePageUtils(JNIEnv* env) { 79 bool RegisterDistillablePageUtils(JNIEnv* env) {
79 return RegisterNativesImpl(env); 80 return RegisterNativesImpl(env);
80 } 81 }
81 82
82 } 83 }
83 } 84 }
OLDNEW
« no previous file with comments | « no previous file | components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698