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

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: sync 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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "cc/layers/layer.h" 17 #include "cc/layers/layer.h"
18 #include "cc/layers/solid_color_layer.h" 18 #include "cc/layers/solid_color_layer.h"
19 #include "cc/output/begin_frame_args.h" 19 #include "cc/output/begin_frame_args.h"
20 #include "content/browser/android/gesture_event_type.h" 20 #include "content/browser/android/gesture_event_type.h"
21 #include "content/browser/android/interstitial_page_delegate_android.h" 21 #include "content/browser/android/interstitial_page_delegate_android.h"
22 #include "content/browser/android/load_url_params.h" 22 #include "content/browser/android/load_url_params.h"
23 #include "content/browser/frame_host/interstitial_page_impl.h" 23 #include "content/browser/frame_host/interstitial_page_impl.h"
24 #include "content/browser/frame_host/navigation_controller_impl.h" 24 #include "content/browser/frame_host/navigation_controller_impl.h"
25 #include "content/browser/frame_host/navigation_entry_impl.h" 25 #include "content/browser/frame_host/navigation_entry_impl.h"
26 #include "content/browser/geolocation/geolocation_dispatcher_host.h"
26 #include "content/browser/media/android/browser_media_player_manager.h" 27 #include "content/browser/media/android/browser_media_player_manager.h"
27 #include "content/browser/renderer_host/compositor_impl_android.h" 28 #include "content/browser/renderer_host/compositor_impl_android.h"
28 #include "content/browser/renderer_host/input/motion_event_android.h" 29 #include "content/browser/renderer_host/input/motion_event_android.h"
29 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " 30 #include "content/browser/renderer_host/input/web_input_event_builders_android.h "
30 #include "content/browser/renderer_host/input/web_input_event_util.h" 31 #include "content/browser/renderer_host/input/web_input_event_util.h"
31 #include "content/browser/renderer_host/java/java_bound_object.h" 32 #include "content/browser/renderer_host/java/java_bound_object.h"
32 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" 33 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h"
33 #include "content/browser/renderer_host/render_view_host_impl.h" 34 #include "content/browser/renderer_host/render_view_host_impl.h"
34 #include "content/browser/renderer_host/render_widget_host_impl.h" 35 #include "content/browser/renderer_host/render_widget_host_impl.h"
35 #include "content/browser/renderer_host/render_widget_host_view_android.h" 36 #include "content/browser/renderer_host/render_widget_host_view_android.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ui::WindowAndroid* window_android, 219 ui::WindowAndroid* window_android,
219 jobject java_bridge_retained_object_set) 220 jobject java_bridge_retained_object_set)
220 : WebContentsObserver(web_contents), 221 : WebContentsObserver(web_contents),
221 java_ref_(env, obj), 222 java_ref_(env, obj),
222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 223 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
223 root_layer_(cc::SolidColorLayer::Create()), 224 root_layer_(cc::SolidColorLayer::Create()),
224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), 225 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()),
225 view_android_(view_android), 226 view_android_(view_android),
226 window_android_(window_android), 227 window_android_(window_android),
227 device_orientation_(0), 228 device_orientation_(0),
228 geolocation_needs_pause_(false),
229 accessibility_enabled_(false) { 229 accessibility_enabled_(false) {
230 CHECK(web_contents) << 230 CHECK(web_contents) <<
231 "A ContentViewCoreImpl should be created with a valid WebContents."; 231 "A ContentViewCoreImpl should be created with a valid WebContents.";
232 232
233 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); 233 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj));
234 gfx::Size physical_size( 234 gfx::Size physical_size(
235 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), 235 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
236 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); 236 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
237 root_layer_->SetBounds(physical_size); 237 root_layer_->SetBounds(physical_size);
238 root_layer_->SetIsDrawable(true); 238 root_layer_->SetIsDrawable(true);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 web_contents_->GetRenderViewHost()); 326 web_contents_->GetRenderViewHost());
327 if (new_pid != old_pid) { 327 if (new_pid != old_pid) {
328 // Notify the Java side of the change of the current renderer process. 328 // Notify the Java side of the change of the current renderer process.
329 JNIEnv* env = AttachCurrentThread(); 329 JNIEnv* env = AttachCurrentThread();
330 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 330 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
331 if (!obj.is_null()) { 331 if (!obj.is_null()) {
332 Java_ContentViewCore_onRenderProcessSwap(env, obj.obj()); 332 Java_ContentViewCore_onRenderProcessSwap(env, obj.obj());
333 } 333 }
334 } 334 }
335 SetFocusInternal(HasFocus()); 335 SetFocusInternal(HasFocus());
336 if (geolocation_needs_pause_)
337 PauseOrResumeGeolocation(true);
338 336
339 SetAccessibilityEnabledInternal(accessibility_enabled_); 337 SetAccessibilityEnabledInternal(accessibility_enabled_);
340 break; 338 break;
341 } 339 }
342 case NOTIFICATION_RENDERER_PROCESS_CREATED: { 340 case NOTIFICATION_RENDERER_PROCESS_CREATED: {
343 // Notify the Java side of the current renderer process. 341 // Notify the Java side of the current renderer process.
344 RenderProcessHost* source_process_host = 342 RenderProcessHost* source_process_host =
345 Source<RenderProcessHost>(source).ptr(); 343 Source<RenderProcessHost>(source).ptr();
346 RenderProcessHost* current_process_host = 344 RenderProcessHost* current_process_host =
347 web_contents_->GetRenderViewHost()->GetProcess(); 345 web_contents_->GetRenderViewHost()->GetProcess();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 PauseVideo(); 412 PauseVideo();
415 } 413 }
416 414
417 void ContentViewCoreImpl::PauseVideo() { 415 void ContentViewCoreImpl::PauseVideo() {
418 RenderViewHost* host = web_contents_->GetRenderViewHost(); 416 RenderViewHost* host = web_contents_->GetRenderViewHost();
419 if (host) 417 if (host)
420 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID())); 418 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID()));
421 } 419 }
422 420
423 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { 421 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) {
424 geolocation_needs_pause_ = should_pause; 422 web_contents_->geolocation_dispatcher_host()->PauseOrResume(should_pause);
425 RenderViewHostImpl* rvh =
426 static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
427 if (rvh) {
428 scoped_refptr<GeolocationDispatcherHost> geolocation_dispatcher =
429 static_cast<RenderProcessHostImpl*>(
430 web_contents_->GetRenderProcessHost())->
431 geolocation_dispatcher_host();
432 if (geolocation_dispatcher.get()) {
433 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
434 base::Bind(&GeolocationDispatcherHost::PauseOrResume,
435 geolocation_dispatcher,
436 rvh->GetRoutingID(),
437 should_pause));
438 geolocation_needs_pause_ = false;
439 }
440 }
441 } 423 }
442 424
443 // All positions and sizes are in CSS pixels. 425 // All positions and sizes are in CSS pixels.
444 // Note that viewport_width/height is a best effort based. 426 // Note that viewport_width/height is a best effort based.
445 // ContentViewCore has the actual information about the physical viewport size. 427 // ContentViewCore has the actual information about the physical viewport size.
446 void ContentViewCoreImpl::UpdateFrameInfo( 428 void ContentViewCoreImpl::UpdateFrameInfo(
447 const gfx::Vector2dF& scroll_offset, 429 const gfx::Vector2dF& scroll_offset,
448 float page_scale_factor, 430 float page_scale_factor,
449 const gfx::Vector2dF& page_scale_factor_limits, 431 const gfx::Vector2dF& page_scale_factor_limits,
450 const gfx::SizeF& content_size, 432 const gfx::SizeF& content_size,
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 reinterpret_cast<ui::WindowAndroid*>(window_android), 1661 reinterpret_cast<ui::WindowAndroid*>(window_android),
1680 retained_objects_set); 1662 retained_objects_set);
1681 return reinterpret_cast<intptr_t>(view); 1663 return reinterpret_cast<intptr_t>(view);
1682 } 1664 }
1683 1665
1684 bool RegisterContentViewCore(JNIEnv* env) { 1666 bool RegisterContentViewCore(JNIEnv* env) {
1685 return RegisterNativesImpl(env); 1667 return RegisterNativesImpl(env);
1686 } 1668 }
1687 1669
1688 } // namespace content 1670 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/geolocation/geolocation_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698