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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 273523007: Dispatch geolocation IPCs on the UI thread. Aside from simplifying the code to avoid a lot of threa… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix android Created 6 years, 7 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
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 "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 ui::ViewAndroid* view_android, 217 ui::ViewAndroid* view_android,
218 ui::WindowAndroid* window_android, 218 ui::WindowAndroid* window_android,
219 jobject java_bridge_retained_object_set) 219 jobject java_bridge_retained_object_set)
220 : WebContentsObserver(web_contents), 220 : WebContentsObserver(web_contents),
221 java_ref_(env, obj), 221 java_ref_(env, obj),
222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
223 root_layer_(cc::SolidColorLayer::Create()), 223 root_layer_(cc::SolidColorLayer::Create()),
224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), 224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()),
225 view_android_(view_android), 225 view_android_(view_android),
226 window_android_(window_android), 226 window_android_(window_android),
227 device_orientation_(0), 227 device_orientation_(0) {
228 geolocation_needs_pause_(false) {
229 CHECK(web_contents) << 228 CHECK(web_contents) <<
230 "A ContentViewCoreImpl should be created with a valid WebContents."; 229 "A ContentViewCoreImpl should be created with a valid WebContents.";
231 230
232 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); 231 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj));
233 gfx::Size physical_size( 232 gfx::Size physical_size(
234 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), 233 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
235 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); 234 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
236 root_layer_->SetBounds(physical_size); 235 root_layer_->SetBounds(physical_size);
237 root_layer_->SetIsDrawable(true); 236 root_layer_->SetIsDrawable(true);
238 237
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 web_contents_->GetRenderViewHost()); 324 web_contents_->GetRenderViewHost());
326 if (new_pid != old_pid) { 325 if (new_pid != old_pid) {
327 // Notify the Java side of the change of the current renderer process. 326 // Notify the Java side of the change of the current renderer process.
328 JNIEnv* env = AttachCurrentThread(); 327 JNIEnv* env = AttachCurrentThread();
329 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 328 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
330 if (!obj.is_null()) { 329 if (!obj.is_null()) {
331 Java_ContentViewCore_onRenderProcessSwap(env, obj.obj()); 330 Java_ContentViewCore_onRenderProcessSwap(env, obj.obj());
332 } 331 }
333 } 332 }
334 SetFocusInternal(HasFocus()); 333 SetFocusInternal(HasFocus());
335 if (geolocation_needs_pause_)
336 PauseOrResumeGeolocation(true);
337 break; 334 break;
338 } 335 }
339 case NOTIFICATION_RENDERER_PROCESS_CREATED: { 336 case NOTIFICATION_RENDERER_PROCESS_CREATED: {
340 // Notify the Java side of the current renderer process. 337 // Notify the Java side of the current renderer process.
341 RenderProcessHost* source_process_host = 338 RenderProcessHost* source_process_host =
342 Source<RenderProcessHost>(source).ptr(); 339 Source<RenderProcessHost>(source).ptr();
343 RenderProcessHost* current_process_host = 340 RenderProcessHost* current_process_host =
344 web_contents_->GetRenderViewHost()->GetProcess(); 341 web_contents_->GetRenderViewHost()->GetProcess();
345 342
346 if (source_process_host == current_process_host) { 343 if (source_process_host == current_process_host) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 PauseVideo(); 408 PauseVideo();
412 } 409 }
413 410
414 void ContentViewCoreImpl::PauseVideo() { 411 void ContentViewCoreImpl::PauseVideo() {
415 RenderViewHost* host = web_contents_->GetRenderViewHost(); 412 RenderViewHost* host = web_contents_->GetRenderViewHost();
416 if (host) 413 if (host)
417 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID())); 414 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID()));
418 } 415 }
419 416
420 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { 417 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) {
421 geolocation_needs_pause_ = should_pause; 418 web_contents_->geolocation_dispatcher_host()->PauseOrResume(should_pause);
422 RenderViewHostImpl* rvh =
423 static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
424 if (rvh) {
425 scoped_refptr<GeolocationDispatcherHost> geolocation_dispatcher =
426 static_cast<RenderProcessHostImpl*>(
427 web_contents_->GetRenderProcessHost())->
428 geolocation_dispatcher_host();
429 if (geolocation_dispatcher.get()) {
430 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
431 base::Bind(&GeolocationDispatcherHost::PauseOrResume,
432 geolocation_dispatcher,
433 rvh->GetRoutingID(),
434 should_pause));
435 geolocation_needs_pause_ = false;
436 }
437 }
438 } 419 }
439 420
440 // All positions and sizes are in CSS pixels. 421 // All positions and sizes are in CSS pixels.
441 // Note that viewport_width/height is a best effort based. 422 // Note that viewport_width/height is a best effort based.
442 // ContentViewCore has the actual information about the physical viewport size. 423 // ContentViewCore has the actual information about the physical viewport size.
443 void ContentViewCoreImpl::UpdateFrameInfo( 424 void ContentViewCoreImpl::UpdateFrameInfo(
444 const gfx::Vector2dF& scroll_offset, 425 const gfx::Vector2dF& scroll_offset,
445 float page_scale_factor, 426 float page_scale_factor,
446 const gfx::Vector2dF& page_scale_factor_limits, 427 const gfx::Vector2dF& page_scale_factor_limits,
447 const gfx::SizeF& content_size, 428 const gfx::SizeF& content_size,
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 reinterpret_cast<ui::WindowAndroid*>(window_android), 1670 reinterpret_cast<ui::WindowAndroid*>(window_android),
1690 retained_objects_set); 1671 retained_objects_set);
1691 return reinterpret_cast<intptr_t>(view); 1672 return reinterpret_cast<intptr_t>(view);
1692 } 1673 }
1693 1674
1694 bool RegisterContentViewCore(JNIEnv* env) { 1675 bool RegisterContentViewCore(JNIEnv* env) {
1695 return RegisterNativesImpl(env); 1676 return RegisterNativesImpl(env);
1696 } 1677 }
1697 1678
1698 } // namespace content 1679 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698