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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const content::RenderViewHost* rvh = | 144 const content::RenderViewHost* rvh = |
145 content::RenderViewHost::FromID(render_process_id, render_view_id); | 145 content::RenderViewHost::FromID(render_process_id, render_view_id); |
146 if (!rvh) return NULL; | 146 if (!rvh) return NULL; |
147 content::WebContents* web_contents = | 147 content::WebContents* web_contents = |
148 content::WebContents::FromRenderViewHost(rvh); | 148 content::WebContents::FromRenderViewHost(rvh); |
149 if (!web_contents) return NULL; | 149 if (!web_contents) return NULL; |
150 return FromWebContents(web_contents); | 150 return FromWebContents(web_contents); |
151 } | 151 } |
152 | 152 |
153 AwContents::AwContents(scoped_ptr<WebContents> web_contents) | 153 AwContents::AwContents(scoped_ptr<WebContents> web_contents) |
154 : weak_factory_on_ui_thread_(this), | 154 : web_contents_(web_contents.Pass()), |
155 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), | |
156 web_contents_(web_contents.Pass()), | |
157 shared_renderer_state_( | 155 shared_renderer_state_( |
158 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 156 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
159 this), | 157 this), |
160 browser_view_renderer_( | 158 browser_view_renderer_( |
161 this, | 159 this, |
162 &shared_renderer_state_, | 160 &shared_renderer_state_, |
163 web_contents_.get(), | 161 web_contents_.get(), |
164 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), | 162 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), |
165 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) { | 163 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) { |
166 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); | 164 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 340 |
343 if (!hardware_renderer_) | 341 if (!hardware_renderer_) |
344 return; | 342 return; |
345 | 343 |
346 // TODO(boliu): Make this a task as well. | 344 // TODO(boliu): Make this a task as well. |
347 DrawGLResult result; | 345 DrawGLResult result; |
348 if (hardware_renderer_->DrawGL(state_restore.stencil_enabled(), | 346 if (hardware_renderer_->DrawGL(state_restore.stencil_enabled(), |
349 state_restore.framebuffer_binding_ext(), | 347 state_restore.framebuffer_binding_ext(), |
350 draw_info, | 348 draw_info, |
351 &result)) { | 349 &result)) { |
352 content::BrowserThread::PostTask( | 350 browser_view_renderer_.DidDrawGL(result); |
353 content::BrowserThread::UI, | |
354 FROM_HERE, | |
355 base::Bind(&AwContents::DidDrawGL, ui_thread_weak_ptr_, result)); | |
356 } | 351 } |
357 } | 352 } |
358 | 353 |
359 void AwContents::DidDrawGL(const DrawGLResult& result) { | |
360 browser_view_renderer_.DidDrawGL(result); | |
361 } | |
362 | |
363 namespace { | 354 namespace { |
364 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message, | 355 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message, |
365 bool has_images) { | 356 bool has_images) { |
366 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(), | 357 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(), |
367 has_images, | 358 has_images, |
368 message.obj()); | 359 message.obj()); |
369 } | 360 } |
370 } // namespace | 361 } // namespace |
371 | 362 |
372 void AwContents::DocumentHasImages(JNIEnv* env, jobject obj, jobject message) { | 363 void AwContents::DocumentHasImages(JNIEnv* env, jobject obj, jobject message) { |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 return; | 1088 return; |
1098 | 1089 |
1099 browser_view_renderer_.TrimMemory(level, visible); | 1090 browser_view_renderer_.TrimMemory(level, visible); |
1100 } | 1091 } |
1101 | 1092 |
1102 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1093 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1103 g_should_download_favicons = true; | 1094 g_should_download_favicons = true; |
1104 } | 1095 } |
1105 | 1096 |
1106 } // namespace android_webview | 1097 } // namespace android_webview |
OLD | NEW |