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

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

Issue 2044783002: Prevent display going to sleep while taking a screenshot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: impl -> public Created 4 years, 6 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "skia/ext/platform_canvas.h" 75 #include "skia/ext/platform_canvas.h"
76 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 76 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
77 #include "ui/events/event.h" 77 #include "ui/events/event.h"
78 #include "ui/events/keycodes/keyboard_codes.h" 78 #include "ui/events/keycodes/keyboard_codes.h"
79 #include "ui/gfx/geometry/size_conversions.h" 79 #include "ui/gfx/geometry/size_conversions.h"
80 #include "ui/gfx/geometry/vector2d_conversions.h" 80 #include "ui/gfx/geometry/vector2d_conversions.h"
81 #include "ui/gfx/skbitmap_operations.h" 81 #include "ui/gfx/skbitmap_operations.h"
82 #include "ui/snapshot/snapshot.h" 82 #include "ui/snapshot/snapshot.h"
83 83
84 #if defined(OS_MACOSX) 84 #if defined(OS_MACOSX)
85 #include "content/public/browser/power_save_blocker.h"
86 #include "content/public/browser/power_save_blocker_factory.h"
85 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 87 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
86 #endif 88 #endif
87 89
88 using base::Time; 90 using base::Time;
89 using base::TimeDelta; 91 using base::TimeDelta;
90 using base::TimeTicks; 92 using base::TimeTicks;
91 using blink::WebGestureEvent; 93 using blink::WebGestureEvent;
92 using blink::WebInputEvent; 94 using blink::WebInputEvent;
93 using blink::WebKeyboardEvent; 95 using blink::WebKeyboardEvent;
94 using blink::WebMouseEvent; 96 using blink::WebMouseEvent;
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 1267
1266 // The resize message (which may not happen immediately) will carry with it 1268 // The resize message (which may not happen immediately) will carry with it
1267 // the screen info as well as the new size (if the screen has changed scale 1269 // the screen info as well as the new size (if the screen has changed scale
1268 // factor). 1270 // factor).
1269 WasResized(); 1271 WasResized();
1270 } 1272 }
1271 1273
1272 void RenderWidgetHostImpl::GetSnapshotFromBrowser( 1274 void RenderWidgetHostImpl::GetSnapshotFromBrowser(
1273 const GetSnapshotFromBrowserCallback& callback) { 1275 const GetSnapshotFromBrowserCallback& callback) {
1274 int id = next_browser_snapshot_id_++; 1276 int id = next_browser_snapshot_id_++;
1277
1278 #if defined(OS_MACOSX)
1279 // MacOS version of underlying GrabViewSnapshot() blocks while
1280 // display/GPU are in a power-saving mode, so make sure display
1281 // does not go to sleep for the duration of reading a snapshot.
1282 if (pending_browser_snapshots_.empty()) {
1283 DCHECK(!power_save_blocker_);
1284 power_save_blocker_.reset(
1285 CreatePowerSaveBlocker(
1286 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
1287 PowerSaveBlocker::kReasonOther, "GetSnapshot")
1288 .release());
1289 }
1290 #endif
1275 pending_browser_snapshots_.insert(std::make_pair(id, callback)); 1291 pending_browser_snapshots_.insert(std::make_pair(id, callback));
1276 Send(new ViewMsg_ForceRedraw(GetRoutingID(), id)); 1292 Send(new ViewMsg_ForceRedraw(GetRoutingID(), id));
1277 } 1293 }
1278 1294
1279 const NativeWebKeyboardEvent* 1295 const NativeWebKeyboardEvent*
1280 RenderWidgetHostImpl::GetLastKeyboardEvent() const { 1296 RenderWidgetHostImpl::GetLastKeyboardEvent() const {
1281 return input_router_->GetLastKeyboardEvent(); 1297 return input_router_->GetLastKeyboardEvent();
1282 } 1298 }
1283 1299
1284 void RenderWidgetHostImpl::OnSelectionChanged(const base::string16& text, 1300 void RenderWidgetHostImpl::OnSelectionChanged(const base::string16& text,
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 // to be implicitly complete, and returned the same snapshot data. 2133 // to be implicitly complete, and returned the same snapshot data.
2118 PendingSnapshotMap::iterator it = pending_browser_snapshots_.begin(); 2134 PendingSnapshotMap::iterator it = pending_browser_snapshots_.begin();
2119 while (it != pending_browser_snapshots_.end()) { 2135 while (it != pending_browser_snapshots_.end()) {
2120 if (it->first <= snapshot_id) { 2136 if (it->first <= snapshot_id) {
2121 it->second.Run(data, size); 2137 it->second.Run(data, size);
2122 pending_browser_snapshots_.erase(it++); 2138 pending_browser_snapshots_.erase(it++);
2123 } else { 2139 } else {
2124 ++it; 2140 ++it;
2125 } 2141 }
2126 } 2142 }
2143 #if defined(OS_MACOSX)
2144 if (pending_browser_snapshots_.empty())
2145 power_save_blocker_.reset();
2146 #endif
2127 } 2147 }
2128 2148
2129 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync( 2149 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync(
2130 int snapshot_id, 2150 int snapshot_id,
2131 scoped_refptr<base::RefCountedBytes> png_data) { 2151 scoped_refptr<base::RefCountedBytes> png_data) {
2132 if (png_data.get()) 2152 if (png_data.get())
2133 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size()); 2153 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size());
2134 else 2154 else
2135 OnSnapshotDataReceived(snapshot_id, NULL, 0); 2155 OnSnapshotDataReceived(snapshot_id, NULL, 0);
2136 } 2156 }
(...skipping 28 matching lines...) Expand all
2165 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2185 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2166 } 2186 }
2167 2187
2168 BrowserAccessibilityManager* 2188 BrowserAccessibilityManager*
2169 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2189 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2170 return delegate_ ? 2190 return delegate_ ?
2171 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2191 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2172 } 2192 }
2173 2193
2174 } // namespace content 2194 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698