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

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

Issue 23694031: Fix race conditions in window snapshot code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing further feedback, added stress test for snapshots Created 7 years, 2 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_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "content/public/common/drop_data.h" 60 #include "content/public/common/drop_data.h"
61 #include "content/public/common/result_codes.h" 61 #include "content/public/common/result_codes.h"
62 #include "content/public/common/url_constants.h" 62 #include "content/public/common/url_constants.h"
63 #include "content/public/common/url_utils.h" 63 #include "content/public/common/url_utils.h"
64 #include "net/base/net_util.h" 64 #include "net/base/net_util.h"
65 #include "net/url_request/url_request_context_getter.h" 65 #include "net/url_request/url_request_context_getter.h"
66 #include "third_party/skia/include/core/SkBitmap.h" 66 #include "third_party/skia/include/core/SkBitmap.h"
67 #include "ui/gfx/image/image_skia.h" 67 #include "ui/gfx/image/image_skia.h"
68 #include "ui/gfx/native_widget_types.h" 68 #include "ui/gfx/native_widget_types.h"
69 #include "ui/shell_dialogs/selected_file_info.h" 69 #include "ui/shell_dialogs/selected_file_info.h"
70 #include "ui/snapshot/snapshot.h"
71 #include "webkit/browser/fileapi/isolated_context.h" 70 #include "webkit/browser/fileapi/isolated_context.h"
72 71
73 #if defined(OS_MACOSX) 72 #if defined(OS_MACOSX)
74 #include "content/browser/renderer_host/popup_menu_helper_mac.h" 73 #include "content/browser/renderer_host/popup_menu_helper_mac.h"
75 #elif defined(OS_ANDROID) 74 #elif defined(OS_ANDROID)
76 #include "content/browser/media/android/browser_media_player_manager.h" 75 #include "content/browser/media/android/browser_media_player_manager.h"
77 #endif 76 #endif
78 77
79 using base::TimeDelta; 78 using base::TimeDelta;
80 using WebKit::WebConsoleMessage; 79 using WebKit::WebConsoleMessage;
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) 983 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
985 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) 984 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
986 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK) 985 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK)
987 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) 986 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK)
988 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) 987 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK)
989 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) 988 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged)
990 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, 989 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged,
991 OnSelectionBoundsChanged) 990 OnSelectionBoundsChanged)
992 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) 991 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse)
993 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) 992 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
994 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowSnapshot, OnGetWindowSnapshot)
995 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, 993 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
996 OnRequestDesktopNotificationPermission) 994 OnRequestDesktopNotificationPermission)
997 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, 995 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
998 OnShowDesktopNotification) 996 OnShowDesktopNotification)
999 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, 997 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
1000 OnCancelDesktopNotification) 998 OnCancelDesktopNotification)
1001 #if defined(OS_MACOSX) || defined(OS_ANDROID) 999 #if defined(OS_MACOSX) || defined(OS_ANDROID)
1002 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) 1000 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
1003 #endif 1001 #endif
1004 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) 1002 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser)
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 1983
1986 void RenderViewHostImpl::OnDomOperationResponse( 1984 void RenderViewHostImpl::OnDomOperationResponse(
1987 const std::string& json_string, int automation_id) { 1985 const std::string& json_string, int automation_id) {
1988 DomOperationNotificationDetails details(json_string, automation_id); 1986 DomOperationNotificationDetails details(json_string, automation_id);
1989 NotificationService::current()->Notify( 1987 NotificationService::current()->Notify(
1990 NOTIFICATION_DOM_OPERATION_RESPONSE, 1988 NOTIFICATION_DOM_OPERATION_RESPONSE,
1991 Source<RenderViewHost>(this), 1989 Source<RenderViewHost>(this),
1992 Details<DomOperationNotificationDetails>(&details)); 1990 Details<DomOperationNotificationDetails>(&details));
1993 } 1991 }
1994 1992
1995 void RenderViewHostImpl::OnGetWindowSnapshot(const int snapshot_id) {
1996 std::vector<unsigned char> png;
1997
1998 // This feature is behind the kEnableGpuBenchmarking command line switch
1999 // because it poses security concerns and should only be used for testing.
2000 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
2001 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) {
2002 gfx::Rect view_bounds = GetView()->GetViewBounds();
2003 gfx::Rect snapshot_bounds(view_bounds.size());
2004 gfx::Size snapshot_size = snapshot_bounds.size();
2005
2006 if (ui::GrabViewSnapshot(GetView()->GetNativeView(),
2007 &png, snapshot_bounds)) {
2008 Send(new ViewMsg_WindowSnapshotCompleted(
2009 GetRoutingID(), snapshot_id, snapshot_size, png));
2010 return;
2011 }
2012 }
2013
2014 Send(new ViewMsg_WindowSnapshotCompleted(
2015 GetRoutingID(), snapshot_id, gfx::Size(), png));
2016 }
2017
2018 #if defined(OS_MACOSX) || defined(OS_ANDROID) 1993 #if defined(OS_MACOSX) || defined(OS_ANDROID)
2019 void RenderViewHostImpl::OnShowPopup( 1994 void RenderViewHostImpl::OnShowPopup(
2020 const ViewHostMsg_ShowPopup_Params& params) { 1995 const ViewHostMsg_ShowPopup_Params& params) {
2021 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); 1996 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
2022 if (view) { 1997 if (view) {
2023 view->ShowPopupMenu(params.bounds, 1998 view->ShowPopupMenu(params.bounds,
2024 params.item_height, 1999 params.item_height,
2025 params.item_font_size, 2000 params.item_font_size,
2026 params.selected_item, 2001 params.selected_item,
2027 params.popup_items, 2002 params.popup_items,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); 2037 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
2063 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); 2038 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin();
2064 file != file_paths.end(); ++file) { 2039 file != file_paths.end(); ++file) {
2065 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) 2040 if (!policy->CanReadFile(GetProcess()->GetID(), *file))
2066 return false; 2041 return false;
2067 } 2042 }
2068 return true; 2043 return true;
2069 } 2044 }
2070 2045
2071 } // namespace content 2046 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698