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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 12746009: Revert 189969 "Add RenderWidgetHost::GetSnapshotFromRenderer met..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1450/src/
Patch Set: Created 7 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "cc/output/compositor_frame.h" 20 #include "cc/output/compositor_frame.h"
21 #include "cc/output/compositor_frame_ack.h" 21 #include "cc/output/compositor_frame_ack.h"
22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
23 #include "content/browser/gpu/gpu_process_host.h" 23 #include "content/browser/gpu/gpu_process_host.h"
24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
25 #include "content/browser/gpu/gpu_surface_tracker.h" 25 #include "content/browser/gpu/gpu_surface_tracker.h"
26 #include "content/browser/renderer_host/backing_store.h" 26 #include "content/browser/renderer_host/backing_store.h"
27 #include "content/browser/renderer_host/backing_store_manager.h" 27 #include "content/browser/renderer_host/backing_store_manager.h"
28 #include "content/browser/renderer_host/dip_util.h"
29 #include "content/browser/renderer_host/gesture_event_filter.h" 28 #include "content/browser/renderer_host/gesture_event_filter.h"
30 #include "content/browser/renderer_host/overscroll_controller.h" 29 #include "content/browser/renderer_host/overscroll_controller.h"
31 #include "content/browser/renderer_host/render_process_host_impl.h" 30 #include "content/browser/renderer_host/render_process_host_impl.h"
32 #include "content/browser/renderer_host/render_view_host_impl.h" 31 #include "content/browser/renderer_host/render_view_host_impl.h"
33 #include "content/browser/renderer_host/render_widget_helper.h" 32 #include "content/browser/renderer_host/render_widget_helper.h"
34 #include "content/browser/renderer_host/render_widget_host_delegate.h" 33 #include "content/browser/renderer_host/render_widget_host_delegate.h"
35 #include "content/browser/renderer_host/touch_event_queue.h" 34 #include "content/browser/renderer_host/touch_event_queue.h"
36 #include "content/browser/renderer_host/touchpad_tap_suppression_controller.h" 35 #include "content/browser/renderer_host/touchpad_tap_suppression_controller.h"
37 #include "content/common/accessibility_messages.h" 36 #include "content/common/accessibility_messages.h"
38 #include "content/common/content_constants_internal.h" 37 #include "content/common/content_constants_internal.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 384 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
386 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 385 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
387 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, 386 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup,
388 OnShowDisambiguationPopup) 387 OnShowDisambiguationPopup)
389 #if defined(OS_WIN) 388 #if defined(OS_WIN)
390 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, 389 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated,
391 OnWindowlessPluginDummyWindowCreated) 390 OnWindowlessPluginDummyWindowCreated)
392 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed, 391 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed,
393 OnWindowlessPluginDummyWindowDestroyed) 392 OnWindowlessPluginDummyWindowDestroyed)
394 #endif 393 #endif
395 IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnSnapshot)
396 IPC_MESSAGE_UNHANDLED(handled = false) 394 IPC_MESSAGE_UNHANDLED(handled = false)
397 IPC_END_MESSAGE_MAP_EX() 395 IPC_END_MESSAGE_MAP_EX()
398 396
399 if (!handled && view_ && view_->OnMessageReceived(msg)) 397 if (!handled && view_ && view_->OnMessageReceived(msg))
400 return true; 398 return true;
401 399
402 if (!msg_is_ok) { 400 if (!msg_is_ok) {
403 // The message de-serialization failed. Kill the renderer process. 401 // The message de-serialization failed. Kill the renderer process.
404 RecordAction(UserMetricsAction("BadMessageTerminate_RWH")); 402 RecordAction(UserMetricsAction("BadMessageTerminate_RWH"));
405 GetProcess()->ReceivedBadMessage(); 403 GetProcess()->ReceivedBadMessage();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 view_->SetIsLoading(is_loading); 566 view_->SetIsLoading(is_loading);
569 } 567 }
570 568
571 void RenderWidgetHostImpl::CopyFromBackingStore( 569 void RenderWidgetHostImpl::CopyFromBackingStore(
572 const gfx::Rect& src_subrect, 570 const gfx::Rect& src_subrect,
573 const gfx::Size& accelerated_dst_size, 571 const gfx::Size& accelerated_dst_size,
574 const base::Callback<void(bool, const SkBitmap&)>& callback) { 572 const base::Callback<void(bool, const SkBitmap&)>& callback) {
575 if (view_ && is_accelerated_compositing_active_) { 573 if (view_ && is_accelerated_compositing_active_) {
576 TRACE_EVENT0("browser", 574 TRACE_EVENT0("browser",
577 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); 575 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface");
578 gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ? 576 gfx::Rect copy_rect = src_subrect.IsEmpty() ?
579 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; 577 gfx::Rect(view_->GetViewBounds().size()) : src_subrect;
580 view_->CopyFromCompositingSurface(accelerated_copy_rect, 578 view_->CopyFromCompositingSurface(copy_rect,
581 accelerated_dst_size, 579 accelerated_dst_size,
582 callback); 580 callback);
583 return; 581 return;
584 } 582 }
585 583
586 BackingStore* backing_store = GetBackingStore(false); 584 BackingStore* backing_store = GetBackingStore(false);
587 if (!backing_store) { 585 if (!backing_store) {
588 callback.Run(false, SkBitmap()); 586 callback.Run(false, SkBitmap());
589 return; 587 return;
590 } 588 }
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 else 1242 else
1245 RenderWidgetHostViewPort::GetDefaultScreenInfo(result); 1243 RenderWidgetHostViewPort::GetDefaultScreenInfo(result);
1246 } 1244 }
1247 1245
1248 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { 1246 void RenderWidgetHostImpl::NotifyScreenInfoChanged() {
1249 WebKit::WebScreenInfo screen_info; 1247 WebKit::WebScreenInfo screen_info;
1250 GetWebScreenInfo(&screen_info); 1248 GetWebScreenInfo(&screen_info);
1251 Send(new ViewMsg_ScreenInfoChanged(GetRoutingID(), screen_info)); 1249 Send(new ViewMsg_ScreenInfoChanged(GetRoutingID(), screen_info));
1252 } 1250 }
1253 1251
1254 void RenderWidgetHostImpl::GetSnapshotFromRenderer(
1255 const gfx::Rect& src_subrect,
1256 const base::Callback<void(bool, const SkBitmap&)>& callback) {
1257 TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer");
1258 pending_snapshots_.push(callback);
1259
1260 gfx::Rect copy_rect = src_subrect.IsEmpty() ?
1261 gfx::Rect(view_->GetViewBounds().size()) : src_subrect;
1262
1263 gfx::Rect copy_rect_in_pixel = ConvertRectToPixel(view_, copy_rect);
1264 Send(new ViewMsg_Snapshot(GetRoutingID(), copy_rect_in_pixel));
1265 }
1266
1267 void RenderWidgetHostImpl::OnSnapshot(bool success,
1268 const SkBitmap& bitmap) {
1269 if (pending_snapshots_.size() == 0) {
1270 LOG(ERROR) << "RenderWidgetHostImpl::OnSnapshot: "
1271 "Received a snapshot that was not requested.";
1272 return;
1273 }
1274
1275 base::Callback<void(bool, const SkBitmap&)> callback =
1276 pending_snapshots_.front();
1277 pending_snapshots_.pop();
1278
1279 if (!success) {
1280 callback.Run(success, SkBitmap());
1281 return;
1282 }
1283
1284 callback.Run(success, bitmap);
1285 }
1286
1287 void RenderWidgetHostImpl::UpdateVSyncParameters(base::TimeTicks timebase, 1252 void RenderWidgetHostImpl::UpdateVSyncParameters(base::TimeTicks timebase,
1288 base::TimeDelta interval) { 1253 base::TimeDelta interval) {
1289 Send(new ViewMsg_UpdateVSyncParameters(GetRoutingID(), timebase, interval)); 1254 Send(new ViewMsg_UpdateVSyncParameters(GetRoutingID(), timebase, interval));
1290 } 1255 }
1291 1256
1292 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, 1257 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status,
1293 int exit_code) { 1258 int exit_code) {
1294 // Clearing this flag causes us to re-create the renderer when recovering 1259 // Clearing this flag causes us to re-create the renderer when recovering
1295 // from a crashed renderer. 1260 // from a crashed renderer.
1296 renderer_initialized_ = false; 1261 renderer_initialized_ = false;
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 return; 2424 return;
2460 2425
2461 OnRenderAutoResized(new_size); 2426 OnRenderAutoResized(new_size);
2462 } 2427 }
2463 2428
2464 void RenderWidgetHostImpl::DetachDelegate() { 2429 void RenderWidgetHostImpl::DetachDelegate() {
2465 delegate_ = NULL; 2430 delegate_ = NULL;
2466 } 2431 }
2467 2432
2468 } // namespace content 2433 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698