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

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

Issue 11971007: Pass ScopedJavaGlobalRef to bind() by value (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: avi comments Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/android/content_view_core_impl.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <sys/system_properties.h> 8 #include <sys/system_properties.h>
9 9
10 #include "android_webview/browser/aw_browser_context.h" 10 #include "android_webview/browser/aw_browser_context.h"
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 LOG_IF(WARNING, !g_is_skia_version_compatible) << 544 LOG_IF(WARNING, !g_is_skia_version_compatible) <<
545 "Skia native versions are not compatible."; 545 "Skia native versions are not compatible.";
546 } 546 }
547 547
548 // static 548 // static
549 jint GetAwDrawGLFunction(JNIEnv* env, jclass) { 549 jint GetAwDrawGLFunction(JNIEnv* env, jclass) {
550 return reinterpret_cast<jint>(&DrawGLFunction); 550 return reinterpret_cast<jint>(&DrawGLFunction);
551 } 551 }
552 552
553 namespace { 553 namespace {
554 // |message| is passed as base::Owned, so it will automatically be deleted 554 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message,
555 // when the callback goes out of scope.
556 void DocumentHasImagesCallback(ScopedJavaGlobalRef<jobject>* message,
557 bool has_images) { 555 bool has_images) {
558 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(), 556 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(),
559 has_images, 557 has_images,
560 message->obj()); 558 message.obj());
561 } 559 }
562 } // namespace 560 } // namespace
563 561
564 void AwContents::DocumentHasImages(JNIEnv* env, jobject obj, jobject message) { 562 void AwContents::DocumentHasImages(JNIEnv* env, jobject obj, jobject message) {
565 ScopedJavaGlobalRef<jobject>* j_message = new ScopedJavaGlobalRef<jobject>(); 563 ScopedJavaGlobalRef<jobject> j_message;
566 j_message->Reset(env, message); 564 j_message.Reset(env, message);
567 render_view_host_ext_->DocumentHasImages( 565 render_view_host_ext_->DocumentHasImages(
568 base::Bind(&DocumentHasImagesCallback, base::Owned(j_message))); 566 base::Bind(&DocumentHasImagesCallback, j_message));
569 } 567 }
570 568
571 namespace { 569 namespace {
572 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback, 570 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback,
573 const FilePath& path, int64 size) { 571 const FilePath& path, int64 size) {
574 JNIEnv* env = AttachCurrentThread(); 572 JNIEnv* env = AttachCurrentThread();
575 // Android files are UTF8, so the path conversion below is safe. 573 // Android files are UTF8, so the path conversion below is safe.
576 Java_AwContents_generateMHTMLCallback( 574 Java_AwContents_generateMHTMLCallback(
577 env, 575 env,
578 ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()).obj(), 576 ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()).obj(),
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 if (!picture) { 1076 if (!picture) {
1079 render_view_host_ext_->CapturePictureSync(); 1077 render_view_host_ext_->CapturePictureSync();
1080 picture = RendererPictureMap::GetInstance()->GetRendererPicture( 1078 picture = RendererPictureMap::GetInstance()->GetRendererPicture(
1081 web_contents_->GetRoutingID()); 1079 web_contents_->GetRoutingID());
1082 } 1080 }
1083 1081
1084 return picture; 1082 return picture;
1085 } 1083 }
1086 1084
1087 } // namespace android_webview 1085 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | content/browser/android/content_view_core_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698