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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to content namespace. Update usages. Update extract_actions tool. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/browser/renderer_host/render_widget_host.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "content/browser/accessibility/browser_accessibility_state.h" 16 #include "content/browser/accessibility/browser_accessibility_state.h"
17 #include "content/browser/gpu/gpu_process_host.h" 17 #include "content/browser/gpu/gpu_process_host.h"
18 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 18 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
19 #include "content/browser/renderer_host/backing_store.h" 19 #include "content/browser/renderer_host/backing_store.h"
20 #include "content/browser/renderer_host/backing_store_manager.h" 20 #include "content/browser/renderer_host/backing_store_manager.h"
21 #include "content/browser/renderer_host/render_process_host_impl.h" 21 #include "content/browser/renderer_host/render_process_host_impl.h"
22 #include "content/browser/renderer_host/render_widget_helper.h" 22 #include "content/browser/renderer_host/render_widget_helper.h"
23 #include "content/browser/renderer_host/render_widget_host_view.h" 23 #include "content/browser/renderer_host/render_widget_host_view.h"
24 #include "content/browser/user_metrics.h"
25 #include "content/common/gpu/gpu_messages.h" 24 #include "content/common/gpu/gpu_messages.h"
26 #include "content/public/browser/notification_service.h"
27 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
28 #include "content/public/browser/native_web_keyboard_event.h" 26 #include "content/public/browser/native_web_keyboard_event.h"
27 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/notification_types.h" 28 #include "content/public/browser/notification_types.h"
29 #include "content/public/browser/user_metrics.h"
30 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
31 #include "content/public/common/result_codes.h" 31 #include "content/public/common/result_codes.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h"
33 #include "ui/base/keycodes/keyboard_codes.h" 33 #include "ui/base/keycodes/keyboard_codes.h"
34 #include "webkit/glue/webcursor.h" 34 #include "webkit/glue/webcursor.h"
35 #include "webkit/glue/webpreferences.h" 35 #include "webkit/glue/webpreferences.h"
36 #include "webkit/plugins/npapi/webplugin.h" 36 #include "webkit/plugins/npapi/webplugin.h"
37 37
38 using base::Time; 38 using base::Time;
39 using base::TimeDelta; 39 using base::TimeDelta;
40 using base::TimeTicks; 40 using base::TimeTicks;
41 41 using content::UserMetricsAction;
42 using WebKit::WebGestureEvent; 42 using WebKit::WebGestureEvent;
43 using WebKit::WebInputEvent; 43 using WebKit::WebInputEvent;
44 using WebKit::WebKeyboardEvent; 44 using WebKit::WebKeyboardEvent;
45 using WebKit::WebMouseEvent; 45 using WebKit::WebMouseEvent;
46 using WebKit::WebMouseWheelEvent; 46 using WebKit::WebMouseWheelEvent;
47 using WebKit::WebTextDirection; 47 using WebKit::WebTextDirection;
48 48
49 // How long to (synchronously) wait for the renderer to respond with a 49 // How long to (synchronously) wait for the renderer to respond with a
50 // PaintRect message, when our backing-store is invalid, before giving up and 50 // PaintRect message, when our backing-store is invalid, before giving up and
51 // returning a null or incorrectly sized backing-store from GetBackingStore. 51 // returning a null or incorrectly sized backing-store from GetBackingStore.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 IPC_MESSAGE_HANDLER(ViewHostMsg_CreatePluginContainer, 238 IPC_MESSAGE_HANDLER(ViewHostMsg_CreatePluginContainer,
239 OnMsgCreatePluginContainer) 239 OnMsgCreatePluginContainer)
240 IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyPluginContainer, 240 IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyPluginContainer,
241 OnMsgDestroyPluginContainer) 241 OnMsgDestroyPluginContainer)
242 #endif 242 #endif
243 IPC_MESSAGE_UNHANDLED(handled = false) 243 IPC_MESSAGE_UNHANDLED(handled = false)
244 IPC_END_MESSAGE_MAP_EX() 244 IPC_END_MESSAGE_MAP_EX()
245 245
246 if (!msg_is_ok) { 246 if (!msg_is_ok) {
247 // The message de-serialization failed. Kill the renderer process. 247 // The message de-serialization failed. Kill the renderer process.
248 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH")); 248 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH"));
249 process()->ReceivedBadMessage(); 249 process()->ReceivedBadMessage();
250 } 250 }
251 return handled; 251 return handled;
252 } 252 }
253 253
254 bool RenderWidgetHost::Send(IPC::Message* msg) { 254 bool RenderWidgetHost::Send(IPC::Message* msg) {
255 return process_->Send(msg); 255 return process_->Send(msg);
256 } 256 }
257 257
258 void RenderWidgetHost::WasHidden() { 258 void RenderWidgetHost::WasHidden() {
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 DCHECK(!params.bitmap_rect.IsEmpty()); 1024 DCHECK(!params.bitmap_rect.IsEmpty());
1025 const size_t size = params.bitmap_rect.height() * 1025 const size_t size = params.bitmap_rect.height() *
1026 params.bitmap_rect.width() * 4; 1026 params.bitmap_rect.width() * 4;
1027 TransportDIB* dib = process_->GetTransportDIB(params.bitmap); 1027 TransportDIB* dib = process_->GetTransportDIB(params.bitmap);
1028 1028
1029 // If gpu process does painting, scroll_rect and copy_rects are always empty 1029 // If gpu process does painting, scroll_rect and copy_rects are always empty
1030 // and backing store is never used. 1030 // and backing store is never used.
1031 if (dib) { 1031 if (dib) {
1032 if (dib->size() < size) { 1032 if (dib->size() < size) {
1033 DLOG(WARNING) << "Transport DIB too small for given rectangle"; 1033 DLOG(WARNING) << "Transport DIB too small for given rectangle";
1034 UserMetrics::RecordAction( 1034 content::RecordAction(
1035 UserMetricsAction("BadMessageTerminate_RWH1")); 1035 UserMetricsAction("BadMessageTerminate_RWH1"));
1036 process()->ReceivedBadMessage(); 1036 process()->ReceivedBadMessage();
1037 } else { 1037 } else {
1038 // Scroll the backing store. 1038 // Scroll the backing store.
1039 if (!params.scroll_rect.IsEmpty()) { 1039 if (!params.scroll_rect.IsEmpty()) {
1040 ScrollBackingStoreRect(params.dx, params.dy, 1040 ScrollBackingStoreRect(params.dx, params.dy,
1041 params.scroll_rect, 1041 params.scroll_rect,
1042 params.view_size); 1042 params.view_size);
1043 } 1043 }
1044 1044
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1147
1148 // Log the time delta for processing an input event. 1148 // Log the time delta for processing an input event.
1149 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 1149 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
1150 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); 1150 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta);
1151 1151
1152 // Cancel pending hung renderer checks since the renderer is responsive. 1152 // Cancel pending hung renderer checks since the renderer is responsive.
1153 StopHangMonitorTimeout(); 1153 StopHangMonitorTimeout();
1154 1154
1155 int type = static_cast<int>(event_type); 1155 int type = static_cast<int>(event_type);
1156 if (type < WebInputEvent::Undefined) { 1156 if (type < WebInputEvent::Undefined) {
1157 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); 1157 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2"));
1158 process()->ReceivedBadMessage(); 1158 process()->ReceivedBadMessage();
1159 } else if (type == WebInputEvent::MouseMove) { 1159 } else if (type == WebInputEvent::MouseMove) {
1160 mouse_move_pending_ = false; 1160 mouse_move_pending_ = false;
1161 1161
1162 // now, we can send the next mouse move event 1162 // now, we can send the next mouse move event
1163 if (next_mouse_move_.get()) { 1163 if (next_mouse_move_.get()) {
1164 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); 1164 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove);
1165 ForwardMouseEvent(*next_mouse_move_); 1165 ForwardMouseEvent(*next_mouse_move_);
1166 } 1166 }
1167 } else if (WebInputEvent::isKeyboardEventType(type)) { 1167 } else if (WebInputEvent::isKeyboardEventType(type)) {
(...skipping 24 matching lines...) Expand all
1192 coalesced_mouse_wheel_events_.pop_front(); 1192 coalesced_mouse_wheel_events_.pop_front();
1193 ForwardWheelEvent(next_wheel_event); 1193 ForwardWheelEvent(next_wheel_event);
1194 } 1194 }
1195 1195
1196 if (!processed && !is_hidden_ && view_) 1196 if (!processed && !is_hidden_ && view_)
1197 view_->UnhandledWheelEvent(current_wheel_event_); 1197 view_->UnhandledWheelEvent(current_wheel_event_);
1198 } 1198 }
1199 1199
1200 void RenderWidgetHost::OnMsgFocus() { 1200 void RenderWidgetHost::OnMsgFocus() {
1201 // Only RenderViewHost can deal with that message. 1201 // Only RenderViewHost can deal with that message.
1202 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); 1202 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH4"));
1203 process()->ReceivedBadMessage(); 1203 process()->ReceivedBadMessage();
1204 } 1204 }
1205 1205
1206 void RenderWidgetHost::OnMsgBlur() { 1206 void RenderWidgetHost::OnMsgBlur() {
1207 // Only RenderViewHost can deal with that message. 1207 // Only RenderViewHost can deal with that message.
1208 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH5")); 1208 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH5"));
1209 process()->ReceivedBadMessage(); 1209 process()->ReceivedBadMessage();
1210 } 1210 }
1211 1211
1212 void RenderWidgetHost::OnMsgSetCursor(const WebCursor& cursor) { 1212 void RenderWidgetHost::OnMsgSetCursor(const WebCursor& cursor) {
1213 if (!view_) { 1213 if (!view_) {
1214 return; 1214 return;
1215 } 1215 }
1216 view_->UpdateCursor(cursor); 1216 view_->UpdateCursor(cursor);
1217 } 1217 }
1218 1218
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 Send(new ViewMsg_ScrollFocusedEditableNodeIntoRect(routing_id(), rect)); 1449 Send(new ViewMsg_ScrollFocusedEditableNodeIntoRect(routing_id(), rect));
1450 } 1450 }
1451 1451
1452 void RenderWidgetHost::SelectRange(const gfx::Point& start, 1452 void RenderWidgetHost::SelectRange(const gfx::Point& start,
1453 const gfx::Point& end) { 1453 const gfx::Point& end) {
1454 Send(new ViewMsg_SelectRange(routing_id(), start, end)); 1454 Send(new ViewMsg_SelectRange(routing_id(), start, end));
1455 } 1455 }
1456 1456
1457 void RenderWidgetHost::Undo() { 1457 void RenderWidgetHost::Undo() {
1458 Send(new ViewMsg_Undo(routing_id())); 1458 Send(new ViewMsg_Undo(routing_id()));
1459 UserMetrics::RecordAction(UserMetricsAction("Undo")); 1459 content::RecordAction(UserMetricsAction("Undo"));
1460 } 1460 }
1461 1461
1462 void RenderWidgetHost::Redo() { 1462 void RenderWidgetHost::Redo() {
1463 Send(new ViewMsg_Redo(routing_id())); 1463 Send(new ViewMsg_Redo(routing_id()));
1464 UserMetrics::RecordAction(UserMetricsAction("Redo")); 1464 content::RecordAction(UserMetricsAction("Redo"));
1465 } 1465 }
1466 1466
1467 void RenderWidgetHost::Cut() { 1467 void RenderWidgetHost::Cut() {
1468 Send(new ViewMsg_Cut(routing_id())); 1468 Send(new ViewMsg_Cut(routing_id()));
1469 UserMetrics::RecordAction(UserMetricsAction("Cut")); 1469 content::RecordAction(UserMetricsAction("Cut"));
1470 } 1470 }
1471 1471
1472 void RenderWidgetHost::Copy() { 1472 void RenderWidgetHost::Copy() {
1473 Send(new ViewMsg_Copy(routing_id())); 1473 Send(new ViewMsg_Copy(routing_id()));
1474 UserMetrics::RecordAction(UserMetricsAction("Copy")); 1474 content::RecordAction(UserMetricsAction("Copy"));
1475 } 1475 }
1476 1476
1477 void RenderWidgetHost::CopyToFindPboard() { 1477 void RenderWidgetHost::CopyToFindPboard() {
1478 #if defined(OS_MACOSX) 1478 #if defined(OS_MACOSX)
1479 // Windows/Linux don't have the concept of a find pasteboard. 1479 // Windows/Linux don't have the concept of a find pasteboard.
1480 Send(new ViewMsg_CopyToFindPboard(routing_id())); 1480 Send(new ViewMsg_CopyToFindPboard(routing_id()));
1481 UserMetrics::RecordAction(UserMetricsAction("CopyToFindPboard")); 1481 content::RecordAction(UserMetricsAction("CopyToFindPboard"));
1482 #endif 1482 #endif
1483 } 1483 }
1484 1484
1485 void RenderWidgetHost::Paste() { 1485 void RenderWidgetHost::Paste() {
1486 Send(new ViewMsg_Paste(routing_id())); 1486 Send(new ViewMsg_Paste(routing_id()));
1487 UserMetrics::RecordAction(UserMetricsAction("Paste")); 1487 content::RecordAction(UserMetricsAction("Paste"));
1488 } 1488 }
1489 1489
1490 void RenderWidgetHost::PasteAndMatchStyle() { 1490 void RenderWidgetHost::PasteAndMatchStyle() {
1491 Send(new ViewMsg_PasteAndMatchStyle(routing_id())); 1491 Send(new ViewMsg_PasteAndMatchStyle(routing_id()));
1492 UserMetrics::RecordAction(UserMetricsAction("PasteAndMatchStyle")); 1492 content::RecordAction(UserMetricsAction("PasteAndMatchStyle"));
1493 } 1493 }
1494 1494
1495 void RenderWidgetHost::Delete() { 1495 void RenderWidgetHost::Delete() {
1496 Send(new ViewMsg_Delete(routing_id())); 1496 Send(new ViewMsg_Delete(routing_id()));
1497 UserMetrics::RecordAction(UserMetricsAction("DeleteSelection")); 1497 content::RecordAction(UserMetricsAction("DeleteSelection"));
1498 } 1498 }
1499 1499
1500 void RenderWidgetHost::SelectAll() { 1500 void RenderWidgetHost::SelectAll() {
1501 Send(new ViewMsg_SelectAll(routing_id())); 1501 Send(new ViewMsg_SelectAll(routing_id()));
1502 UserMetrics::RecordAction(UserMetricsAction("SelectAll")); 1502 content::RecordAction(UserMetricsAction("SelectAll"));
1503 } 1503 }
1504 bool RenderWidgetHost::GotResponseToLockMouseRequest(bool allowed) { 1504 bool RenderWidgetHost::GotResponseToLockMouseRequest(bool allowed) {
1505 if (!allowed) { 1505 if (!allowed) {
1506 RejectMouseLockOrUnlockIfNecessary(); 1506 RejectMouseLockOrUnlockIfNecessary();
1507 return false; 1507 return false;
1508 } else { 1508 } else {
1509 if (!pending_mouse_lock_request_) { 1509 if (!pending_mouse_lock_request_) {
1510 // This is possible, e.g., the plugin sends us an unlock request before 1510 // This is possible, e.g., the plugin sends us an unlock request before
1511 // the user allows to lock to mouse. 1511 // the user allows to lock to mouse.
1512 return false; 1512 return false;
(...skipping 17 matching lines...) Expand all
1530 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); 1530 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id));
1531 } 1531 }
1532 1532
1533 // static 1533 // static
1534 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id, 1534 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id,
1535 int gpu_host_id) { 1535 int gpu_host_id) {
1536 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); 1536 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id);
1537 if (ui_shim) 1537 if (ui_shim)
1538 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); 1538 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id));
1539 } 1539 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698