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 #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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 | 187 |
188 AwContents::AwContents(scoped_ptr<WebContents> web_contents) | 188 AwContents::AwContents(scoped_ptr<WebContents> web_contents) |
189 : browser_view_renderer_( | 189 : browser_view_renderer_( |
190 this, | 190 this, |
191 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 191 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
192 base::CommandLine::ForCurrentProcess()->HasSwitch( | 192 base::CommandLine::ForCurrentProcess()->HasSwitch( |
193 switches::kDisablePageVisibility)), | 193 switches::kDisablePageVisibility)), |
194 web_contents_(std::move(web_contents)), | 194 web_contents_(std::move(web_contents)), |
195 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) { | 195 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) { |
196 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); | 196 base::subtle::Atomic32 instance_count = |
| 197 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); |
| 198 VLOG(2) << "AwContents::~AwContents " << this << " instance_count " |
| 199 << instance_count; |
197 icon_helper_.reset(new IconHelper(web_contents_.get())); | 200 icon_helper_.reset(new IconHelper(web_contents_.get())); |
198 icon_helper_->SetListener(this); | 201 icon_helper_->SetListener(this); |
199 web_contents_->SetUserData(android_webview::kAwContentsUserDataKey, | 202 web_contents_->SetUserData(android_webview::kAwContentsUserDataKey, |
200 new AwContentsUserData(this)); | 203 new AwContentsUserData(this)); |
201 browser_view_renderer_.RegisterWithWebContents(web_contents_.get()); | 204 browser_view_renderer_.RegisterWithWebContents(web_contents_.get()); |
202 render_view_host_ext_.reset( | 205 render_view_host_ext_.reset( |
203 new AwRenderViewHostExt(this, web_contents_.get())); | 206 new AwRenderViewHostExt(this, web_contents_.get())); |
204 | 207 |
205 permission_request_handler_.reset( | 208 permission_request_handler_.reset( |
206 new PermissionRequestHandler(this, web_contents_.get())); | 209 new PermissionRequestHandler(this, web_contents_.get())); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1); | 298 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1); |
296 // When the last WebView is destroyed free all discardable memory allocated by | 299 // When the last WebView is destroyed free all discardable memory allocated by |
297 // Chromium, because the app process may continue to run for a long time | 300 // Chromium, because the app process may continue to run for a long time |
298 // without ever using another WebView. | 301 // without ever using another WebView. |
299 if (instance_count == 0) { | 302 if (instance_count == 0) { |
300 // TODO(timvolodine): consider moving NotifyMemoryPressure to | 303 // TODO(timvolodine): consider moving NotifyMemoryPressure to |
301 // AwContentsLifecycleNotifier (crbug.com/522988). | 304 // AwContentsLifecycleNotifier (crbug.com/522988). |
302 base::MemoryPressureListener::NotifyMemoryPressure( | 305 base::MemoryPressureListener::NotifyMemoryPressure( |
303 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); | 306 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); |
304 } | 307 } |
| 308 VLOG(2) << "AwContents::~AwContents " << this << " instance_count " |
| 309 << instance_count; |
305 AwContentsLifecycleNotifier::OnWebViewDestroyed(); | 310 AwContentsLifecycleNotifier::OnWebViewDestroyed(); |
306 } | 311 } |
307 | 312 |
308 base::android::ScopedJavaLocalRef<jobject> AwContents::GetWebContents( | 313 base::android::ScopedJavaLocalRef<jobject> AwContents::GetWebContents( |
309 JNIEnv* env, | 314 JNIEnv* env, |
310 const JavaParamRef<jobject>& obj) { | 315 const JavaParamRef<jobject>& obj) { |
311 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 316 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
312 DCHECK(web_contents_); | 317 DCHECK(web_contents_); |
313 if (!web_contents_) | 318 if (!web_contents_) |
314 return base::android::ScopedJavaLocalRef<jobject>(); | 319 return base::android::ScopedJavaLocalRef<jobject>(); |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 const JavaParamRef<jobject>& obj) { | 1283 const JavaParamRef<jobject>& obj) { |
1279 web_contents_->ResumeLoadingCreatedWebContents(); | 1284 web_contents_->ResumeLoadingCreatedWebContents(); |
1280 } | 1285 } |
1281 | 1286 |
1282 void SetShouldDownloadFavicons(JNIEnv* env, | 1287 void SetShouldDownloadFavicons(JNIEnv* env, |
1283 const JavaParamRef<jclass>& jclazz) { | 1288 const JavaParamRef<jclass>& jclazz) { |
1284 g_should_download_favicons = true; | 1289 g_should_download_favicons = true; |
1285 } | 1290 } |
1286 | 1291 |
1287 } // namespace android_webview | 1292 } // namespace android_webview |
OLD | NEW |