Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 icon_helper_->SetListener(NULL); | 299 icon_helper_->SetListener(NULL); |
| 300 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1); | 300 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1); |
| 301 } | 301 } |
| 302 | 302 |
| 303 jint AwContents::GetWebContents(JNIEnv* env, jobject obj) { | 303 jint AwContents::GetWebContents(JNIEnv* env, jobject obj) { |
| 304 DCHECK(web_contents_); | 304 DCHECK(web_contents_); |
| 305 return reinterpret_cast<jint>(web_contents_.get()); | 305 return reinterpret_cast<jint>(web_contents_.get()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void AwContents::Destroy(JNIEnv* env, jobject obj) { | 308 void AwContents::Destroy(JNIEnv* env, jobject obj) { |
| 309 delete this; | 309 java_ref_.reset(); |
| 310 | 310 // We do not delete AwContents immediately. Some applications try to delete |
| 311 // Webview in ShouldOverrideUrlLoading callback, which is a sync IPC from | |
| 312 // Webkit. | |
| 313 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); | |
| 311 // When the last WebView is destroyed free all discardable memory allocated by | 314 // When the last WebView is destroyed free all discardable memory allocated by |
| 312 // Chromium, because the app process may continue to run for a long time | 315 // Chromium, because the app process may continue to run for a long time |
| 313 // without ever using another WebView. | 316 // without ever using another WebView. |
| 314 if (base::subtle::NoBarrier_Load(&g_instance_count) == 0) { | 317 if (base::subtle::NoBarrier_Load(&g_instance_count) == 0) { |
|
joth
2013/10/09 02:22:40
now the delete is delayed, this must be moved to t
sgurun-gerrit only
2013/10/16 21:49:28
Done.
| |
| 315 base::MemoryPressureListener::NotifyMemoryPressure( | 318 base::MemoryPressureListener::NotifyMemoryPressure( |
| 316 base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL); | 319 base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL); |
| 317 } | 320 } |
| 318 } | 321 } |
| 319 | 322 |
| 320 static jint Init(JNIEnv* env, jclass, jobject browser_context) { | 323 static jint Init(JNIEnv* env, jclass, jobject browser_context) { |
| 321 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather | 324 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather |
| 322 // than hard-code the default instance lookup here. | 325 // than hard-code the default instance lookup here. |
| 323 scoped_ptr<WebContents> web_contents(content::WebContents::Create( | 326 scoped_ptr<WebContents> web_contents(content::WebContents::Create( |
| 324 content::WebContents::CreateParams(AwBrowserContext::GetDefault()))); | 327 content::WebContents::CreateParams(AwBrowserContext::GetDefault()))); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 | 909 |
| 907 void AwContents::TrimMemory(JNIEnv* env, jobject obj, jint level) { | 910 void AwContents::TrimMemory(JNIEnv* env, jobject obj, jint level) { |
| 908 browser_view_renderer_->TrimMemory(level); | 911 browser_view_renderer_->TrimMemory(level); |
| 909 } | 912 } |
| 910 | 913 |
| 911 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 914 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
| 912 g_should_download_favicons = true; | 915 g_should_download_favicons = true; |
| 913 } | 916 } |
| 914 | 917 |
| 915 } // namespace android_webview | 918 } // namespace android_webview |
| OLD | NEW |