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

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 2538463002: android: Don't pass ScopedJavaGlobalRef pointers. (Closed)
Patch Set: timeouts are very annoying Created 4 years 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 | android_webview/native/aw_contents_statics.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "android_webview/native/aw_contents.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "android_webview/browser/aw_browser_context.h" 10 #include "android_webview/browser/aw_browser_context.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 const JavaParamRef<jobject>& obj, 393 const JavaParamRef<jobject>& obj,
394 const JavaParamRef<jobject>& message) { 394 const JavaParamRef<jobject>& message) {
395 DCHECK_CURRENTLY_ON(BrowserThread::UI); 395 DCHECK_CURRENTLY_ON(BrowserThread::UI);
396 ScopedJavaGlobalRef<jobject> j_message; 396 ScopedJavaGlobalRef<jobject> j_message;
397 j_message.Reset(env, message); 397 j_message.Reset(env, message);
398 render_view_host_ext_->DocumentHasImages( 398 render_view_host_ext_->DocumentHasImages(
399 base::Bind(&DocumentHasImagesCallback, j_message)); 399 base::Bind(&DocumentHasImagesCallback, j_message));
400 } 400 }
401 401
402 namespace { 402 namespace {
403 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback, 403 void GenerateMHTMLCallback(const JavaRef<jobject>& callback,
404 const base::FilePath& path, 404 const base::FilePath& path,
405 int64_t size) { 405 int64_t size) {
406 JNIEnv* env = AttachCurrentThread(); 406 JNIEnv* env = AttachCurrentThread();
407 // Android files are UTF8, so the path conversion below is safe. 407 // Android files are UTF8, so the path conversion below is safe.
408 Java_AwContents_generateMHTMLCallback( 408 Java_AwContents_generateMHTMLCallback(
409 env, ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()), size, *callback); 409 env, ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()), size, callback);
410 } 410 }
411 } // namespace 411 } // namespace
412 412
413 void AwContents::GenerateMHTML(JNIEnv* env, 413 void AwContents::GenerateMHTML(JNIEnv* env,
414 const JavaParamRef<jobject>& obj, 414 const JavaParamRef<jobject>& obj,
415 const JavaParamRef<jstring>& jpath, 415 const JavaParamRef<jstring>& jpath,
416 const JavaParamRef<jobject>& callback) { 416 const JavaParamRef<jobject>& callback) {
417 DCHECK_CURRENTLY_ON(BrowserThread::UI); 417 DCHECK_CURRENTLY_ON(BrowserThread::UI);
418 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
419 j_callback->Reset(env, callback);
420 base::FilePath target_path(ConvertJavaStringToUTF8(env, jpath)); 418 base::FilePath target_path(ConvertJavaStringToUTF8(env, jpath));
421 web_contents_->GenerateMHTML( 419 web_contents_->GenerateMHTML(
422 content::MHTMLGenerationParams(target_path), 420 content::MHTMLGenerationParams(target_path),
423 base::Bind(&GenerateMHTMLCallback, base::Owned(j_callback), target_path)); 421 base::Bind(&GenerateMHTMLCallback,
422 ScopedJavaGlobalRef<jobject>(env, callback), target_path));
424 } 423 }
425 424
426 void AwContents::CreatePdfExporter(JNIEnv* env, 425 void AwContents::CreatePdfExporter(JNIEnv* env,
427 const JavaParamRef<jobject>& obj, 426 const JavaParamRef<jobject>& obj,
428 const JavaParamRef<jobject>& pdfExporter) { 427 const JavaParamRef<jobject>& pdfExporter) {
429 pdf_exporter_.reset( 428 pdf_exporter_.reset(
430 new AwPdfExporter(env, 429 new AwPdfExporter(env,
431 pdfExporter, 430 pdfExporter,
432 web_contents_.get())); 431 web_contents_.get()));
433 } 432 }
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 void AwContents::EnableOnNewPicture(JNIEnv* env, 1129 void AwContents::EnableOnNewPicture(JNIEnv* env,
1131 const JavaParamRef<jobject>& obj, 1130 const JavaParamRef<jobject>& obj,
1132 jboolean enabled) { 1131 jboolean enabled) {
1133 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1132 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1134 browser_view_renderer_.EnableOnNewPicture(enabled); 1133 browser_view_renderer_.EnableOnNewPicture(enabled);
1135 } 1134 }
1136 1135
1137 namespace { 1136 namespace {
1138 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef& java_ref, 1137 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef& java_ref,
1139 jlong request_id, 1138 jlong request_id,
1140 ScopedJavaGlobalRef<jobject>* callback, 1139 const JavaRef<jobject>& callback,
1141 bool result) { 1140 bool result) {
1142 JNIEnv* env = AttachCurrentThread(); 1141 JNIEnv* env = AttachCurrentThread();
1143 ScopedJavaLocalRef<jobject> obj = java_ref.get(env); 1142 ScopedJavaLocalRef<jobject> obj = java_ref.get(env);
1144 if (obj.is_null()) 1143 if (obj.is_null())
1145 return; 1144 return;
1146 Java_AwContents_invokeVisualStateCallback(env, obj, *callback, request_id); 1145 Java_AwContents_invokeVisualStateCallback(env, obj, callback, request_id);
1147 } 1146 }
1148 } // namespace 1147 } // namespace
1149 1148
1150 void AwContents::InsertVisualStateCallback( 1149 void AwContents::InsertVisualStateCallback(
1151 JNIEnv* env, 1150 JNIEnv* env,
1152 const JavaParamRef<jobject>& obj, 1151 const JavaParamRef<jobject>& obj,
1153 jlong request_id, 1152 jlong request_id,
1154 const JavaParamRef<jobject>& callback) { 1153 const JavaParamRef<jobject>& callback) {
1155 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1154 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1156 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
1157 j_callback->Reset(env, callback);
1158 web_contents_->GetMainFrame()->InsertVisualStateCallback( 1155 web_contents_->GetMainFrame()->InsertVisualStateCallback(
1159 base::Bind(&InvokeVisualStateCallback, java_ref_, request_id, 1156 base::Bind(&InvokeVisualStateCallback, java_ref_, request_id,
1160 base::Owned(j_callback))); 1157 ScopedJavaGlobalRef<jobject>(env, callback)));
1161 } 1158 }
1162 1159
1163 void AwContents::ClearView(JNIEnv* env, const JavaParamRef<jobject>& obj) { 1160 void AwContents::ClearView(JNIEnv* env, const JavaParamRef<jobject>& obj) {
1164 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1161 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1165 browser_view_renderer_.ClearView(); 1162 browser_view_renderer_.ClearView();
1166 } 1163 }
1167 1164
1168 void AwContents::SetExtraHeadersForUrl( 1165 void AwContents::SetExtraHeadersForUrl(
1169 JNIEnv* env, 1166 JNIEnv* env,
1170 const JavaParamRef<jobject>& obj, 1167 const JavaParamRef<jobject>& obj,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 int routing_id = new_host->GetRoutingID(); 1267 int routing_id = new_host->GetRoutingID();
1271 // At this point, the current RVH may or may not contain a compositor. So 1268 // At this point, the current RVH may or may not contain a compositor. So
1272 // compositor_ may be nullptr, in which case 1269 // compositor_ may be nullptr, in which case
1273 // BrowserViewRenderer::DidInitializeCompositor() callback is time when the 1270 // BrowserViewRenderer::DidInitializeCompositor() callback is time when the
1274 // new compositor is constructed. 1271 // new compositor is constructed.
1275 browser_view_renderer_.SetActiveCompositorID( 1272 browser_view_renderer_.SetActiveCompositorID(
1276 CompositorID(process_id, routing_id)); 1273 CompositorID(process_id, routing_id));
1277 } 1274 }
1278 1275
1279 } // namespace android_webview 1276 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | android_webview/native/aw_contents_statics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698