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

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

Issue 831523005: Remove most native WebContents references from Java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Kept same error checking behavior for aw_contents.cc Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 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 8
9 #include "android_webview/browser/aw_browser_context.h" 9 #include "android_webview/browser/aw_browser_context.h"
10 #include "android_webview/browser/aw_browser_main_parts.h" 10 #include "android_webview/browser/aw_browser_main_parts.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1); 292 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1);
293 // When the last WebView is destroyed free all discardable memory allocated by 293 // When the last WebView is destroyed free all discardable memory allocated by
294 // Chromium, because the app process may continue to run for a long time 294 // Chromium, because the app process may continue to run for a long time
295 // without ever using another WebView. 295 // without ever using another WebView.
296 if (base::subtle::NoBarrier_Load(&g_instance_count) == 0) { 296 if (base::subtle::NoBarrier_Load(&g_instance_count) == 0) {
297 base::MemoryPressureListener::NotifyMemoryPressure( 297 base::MemoryPressureListener::NotifyMemoryPressure(
298 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); 298 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
299 } 299 }
300 } 300 }
301 301
302 jlong AwContents::GetWebContents(JNIEnv* env, jobject obj) { 302 base::android::ScopedJavaLocalRef<jobject>
303 AwContents::GetWebContents(JNIEnv* env, jobject obj) {
303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
304 DCHECK(web_contents_); 305 DCHECK(web_contents_);
305 return reinterpret_cast<intptr_t>(web_contents_.get()); 306 if (!web_contents_)
307 return base::android::ScopedJavaLocalRef<jobject>();
308
309 return web_contents_->GetJavaWebContents();
306 } 310 }
307 311
308 void AwContents::Destroy(JNIEnv* env, jobject obj) { 312 void AwContents::Destroy(JNIEnv* env, jobject obj) {
309 java_ref_.reset(); 313 java_ref_.reset();
310 delete this; 314 delete this;
311 } 315 }
312 316
313 static jlong Init(JNIEnv* env, jclass, jobject browser_context) { 317 static jlong Init(JNIEnv* env, jclass, jobject browser_context) {
314 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather 318 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather
315 // than hard-code the default instance lookup here. 319 // than hard-code the default instance lookup here.
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 base::Owned(port1), 1129 base::Owned(port1),
1126 base::Owned(port2))); 1130 base::Owned(port2)));
1127 } 1131 }
1128 1132
1129 1133
1130 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { 1134 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) {
1131 g_should_download_favicons = true; 1135 g_should_download_favicons = true;
1132 } 1136 }
1133 1137
1134 } // namespace android_webview 1138 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698