Commit 82df0404 authored by vkuzkokov's avatar vkuzkokov Committed by Commit bot

Remove window.chrome.gpuBenchmarking.beginWindowSnapshotPNG

Extracted part 3 of
https://codereview.chromium.org/190693002/

BUG=242405

Review URL: https://codereview.chromium.org/914183002

Cr-Commit-Position: refs/heads/master@{#320910}
parent 55801f24
......@@ -2000,12 +2000,6 @@ void RenderWidgetHostImpl::DetachDelegate() {
void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) {
ui::LatencyInfo::LatencyComponent window_snapshot_component;
if (latency_info.FindLatency(ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT,
GetLatencyComponentId(),
&window_snapshot_component)) {
WindowOldSnapshotReachedScreen(
static_cast<int>(window_snapshot_component.sequence_number));
}
if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
GetLatencyComponentId(),
&window_snapshot_component)) {
......@@ -2034,59 +2028,6 @@ void RenderWidgetHostImpl::DidReceiveRendererFrame() {
view_->DidReceiveRendererFrame();
}
void RenderWidgetHostImpl::WindowSnapshotAsyncCallback(
int routing_id,
int snapshot_id,
gfx::Size snapshot_size,
scoped_refptr<base::RefCountedBytes> png_data) {
if (!png_data.get()) {
std::vector<unsigned char> png_vector;
Send(new ViewMsg_WindowSnapshotCompleted(
routing_id, snapshot_id, gfx::Size(), png_vector));
return;
}
Send(new ViewMsg_WindowSnapshotCompleted(
routing_id, snapshot_id, snapshot_size, png_data->data()));
}
void RenderWidgetHostImpl::WindowOldSnapshotReachedScreen(int snapshot_id) {
DCHECK(base::MessageLoopForUI::IsCurrent());
std::vector<unsigned char> png;
// This feature is behind the kEnableGpuBenchmarking command line switch
// because it poses security concerns and should only be used for testing.
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(cc::switches::kEnableGpuBenchmarking)) {
Send(new ViewMsg_WindowSnapshotCompleted(
GetRoutingID(), snapshot_id, gfx::Size(), png));
return;
}
gfx::Rect view_bounds = GetView()->GetViewBounds();
gfx::Rect snapshot_bounds(view_bounds.size());
gfx::Size snapshot_size = snapshot_bounds.size();
if (ui::GrabViewSnapshot(
GetView()->GetNativeView(), &png, snapshot_bounds)) {
Send(new ViewMsg_WindowSnapshotCompleted(
GetRoutingID(), snapshot_id, snapshot_size, png));
return;
}
ui::GrabViewSnapshotAsync(
GetView()->GetNativeView(),
snapshot_bounds,
base::ThreadTaskRunnerHandle::Get(),
base::Bind(&RenderWidgetHostImpl::WindowSnapshotAsyncCallback,
weak_factory_.GetWeakPtr(),
GetRoutingID(),
snapshot_id,
snapshot_size));
}
void RenderWidgetHostImpl::WindowSnapshotReachedScreen(int snapshot_id) {
DCHECK(base::MessageLoopForUI::IsCurrent());
......@@ -2145,7 +2086,6 @@ void RenderWidgetHostImpl::CompositorFrameDrawn(
++b) {
if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT ||
b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
b->first.first == ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
b->first.first == ui::TAB_SHOW_COMPONENT) {
// Matches with GetLatencyComponentId
int routing_id = b->first.second & 0xffffffff;
......
......@@ -480,12 +480,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// Don't check whether we expected a resize ack during layout tests.
static void DisableResizeAckCheckForTesting();
void WindowSnapshotAsyncCallback(
int routing_id,
int snapshot_id,
gfx::Size snapshot_size,
scoped_refptr<base::RefCountedBytes> png_data);
InputRouter* input_router() { return input_router_.get(); }
// Get the BrowserAccessibilityManager for the root of the frame tree,
......@@ -689,8 +683,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// which may get in recursive loops).
void DelayedAutoResized();
void WindowOldSnapshotReachedScreen(int snapshot_id);
void WindowSnapshotReachedScreen(int snapshot_id);
void OnSnapshotDataReceived(int snapshot_id,
......
......@@ -259,8 +259,7 @@ void AddLatencyInfoComponentIds(LatencyInfo* latency,
auto lc = latency->latency_components.begin();
while (lc != latency->latency_components.end()) {
ui::LatencyComponentType component_type = lc->first.first;
if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
component_type == ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT) {
if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) {
// Generate a new component entry with the correct component ID
auto key = std::make_pair(component_type, latency_component_id);
new_components[key] = lc->second;
......
......@@ -925,12 +925,6 @@ IPC_MESSAGE_CONTROL1(ViewMsg_TempCrashWithData,
IPC_MESSAGE_ROUTED1(ViewMsg_ReleaseDisambiguationPopupBitmap,
cc::SharedBitmapId /* id */)
// Notifies the renderer that a snapshot has been retrieved.
IPC_MESSAGE_ROUTED3(ViewMsg_WindowSnapshotCompleted,
int /* snapshot_id */,
gfx::Size /* size */,
std::vector<unsigned char> /* png */)
// Fetches complete rendered content of a web page as plain text.
IPC_MESSAGE_ROUTED0(ViewMsg_GetRenderedText)
......
......@@ -264,50 +264,6 @@ void OnMicroBenchmarkCompleted(
}
}
void OnSnapshotCompleted(CallbackAndContext* callback_and_context,
const gfx::Size& size,
const std::vector<unsigned char>& png) {
v8::Isolate* isolate = callback_and_context->isolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::Context> context = callback_and_context->GetContext();
v8::Context::Scope context_scope(context);
WebLocalFrame* frame = WebLocalFrame::frameForContext(context);
if (frame) {
v8::Handle<v8::Value> result;
if (!size.IsEmpty()) {
v8::Handle<v8::Object> result_object;
result_object = v8::Object::New(isolate);
result_object->Set(v8::String::NewFromUtf8(isolate, "width"),
v8::Number::New(isolate, size.width()));
result_object->Set(v8::String::NewFromUtf8(isolate, "height"),
v8::Number::New(isolate, size.height()));
std::string base64_png;
base::Base64Encode(
base::StringPiece(reinterpret_cast<const char*>(&*png.begin()),
png.size()),
&base64_png);
result_object->Set(v8::String::NewFromUtf8(isolate, "data"),
v8::String::NewFromUtf8(isolate,
base64_png.c_str(),
v8::String::kNormalString,
base64_png.size()));
result = result_object;
} else {
result = v8::Null(isolate);
}
v8::Handle<v8::Value> argv[] = {result};
frame->callFunctionEvenIfScriptDisabled(
callback_and_context->GetCallback(), v8::Object::New(isolate), 1, argv);
}
}
void OnSyntheticGestureCompleted(CallbackAndContext* callback_and_context) {
v8::Isolate* isolate = callback_and_context->isolate();
v8::HandleScope scope(isolate);
......@@ -488,8 +444,6 @@ gin::ObjectTemplateBuilder GpuBenchmarking::GetObjectTemplateBuilder(
.SetValue("newPinchInterface", true)
.SetMethod("pinchBy", &GpuBenchmarking::PinchBy)
.SetMethod("tap", &GpuBenchmarking::Tap)
.SetMethod("beginWindowSnapshotPNG",
&GpuBenchmarking::BeginWindowSnapshotPNG)
.SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache)
.SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark)
.SetMethod("sendMessageToMicroBenchmark",
......@@ -829,22 +783,6 @@ bool GpuBenchmarking::Tap(gin::Arguments* args) {
return true;
}
void GpuBenchmarking::BeginWindowSnapshotPNG(
v8::Isolate* isolate,
v8::Handle<v8::Function> callback) {
GpuBenchmarkingContext context;
if (!context.Init(false))
return;
scoped_refptr<CallbackAndContext> callback_and_context =
new CallbackAndContext(isolate,
callback,
context.web_frame()->mainWorldScriptContext());
context.render_view_impl()->GetWindowSnapshot(
base::Bind(&OnSnapshotCompleted, callback_and_context));
}
void GpuBenchmarking::ClearImageCache() {
WebImageCache::clear();
}
......
......@@ -50,8 +50,6 @@ class GpuBenchmarking : public gin::Wrappable<GpuBenchmarking> {
bool ScrollBounce(gin::Arguments* args);
bool PinchBy(gin::Arguments* args);
bool Tap(gin::Arguments* args);
void BeginWindowSnapshotPNG(v8::Isolate* isolate,
v8::Handle<v8::Function> callback);
void ClearImageCache();
int RunMicroBenchmark(gin::Arguments* args);
bool SendMessageToMicroBenchmark(int id, v8::Handle<v8::Object> message);
......
......@@ -660,7 +660,6 @@ RenderViewImpl::RenderViewImpl(const ViewMsg_New_Params& params)
#endif
enumeration_completion_id_(0),
session_storage_namespace_id_(params.session_storage_namespace_id),
next_snapshot_id_(0),
page_scale_factor_is_one_(true),
debug_info_(params.debug_info) {
}
......@@ -1341,8 +1340,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
OnReleaseDisambiguationPopupBitmap)
IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
OnWindowSnapshotCompleted)
IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
#if defined(OS_ANDROID)
......@@ -1502,21 +1499,6 @@ bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) {
return Send(message);
}
void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) {
int id = next_snapshot_id_++;
pending_snapshots_.insert(std::make_pair(id, callback));
ui::LatencyInfo latency_info;
latency_info.AddLatencyNumber(ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT,
0,
id);
scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor;
if (RenderWidgetCompositor* rwc = compositor()) {
latency_info_swap_promise_monitor =
rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info).Pass();
}
ScheduleCompositeWithForcedRedraw();
}
void RenderViewImpl::OnForceRedraw(int id) {
ui::LatencyInfo latency_info;
if (id) {
......@@ -1532,22 +1514,6 @@ void RenderViewImpl::OnForceRedraw(int id) {
ScheduleCompositeWithForcedRedraw();
}
void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id,
const gfx::Size& size, const std::vector<unsigned char>& png) {
// Any pending snapshots with a lower ID than the one received are considered
// to be implicitly complete, and returned the same snapshot data.
PendingSnapshotMap::iterator it = pending_snapshots_.begin();
while(it != pending_snapshots_.end()) {
if (it->first <= snapshot_id) {
it->second.Run(size, png);
pending_snapshots_.erase(it++);
} else {
++it;
}
}
}
// blink::WebViewClient ------------------------------------------------------
WebView* RenderViewImpl::createView(WebLocalFrame* creator,
......
......@@ -287,13 +287,6 @@ class CONTENT_EXPORT RenderViewImpl
// supported PPAPI plugins.
bool HasIMETextFocus();
// Callback for use with GetWindowSnapshot.
typedef base::Callback<void(
const gfx::Size&, const std::vector<unsigned char>&)>
WindowSnapshotCallback;
void GetWindowSnapshot(const WindowSnapshotCallback& callback);
// Dispatches the current navigation state to the browser. Called on a
// periodic timer so we don't send too many messages.
void SyncNavigationState();
......@@ -685,8 +678,6 @@ class CONTENT_EXPORT RenderViewImpl
void OnResetPageScale();
void OnZoom(PageZoom zoom);
void OnEnableViewSourceMode();
void OnWindowSnapshotCompleted(const int snapshot_id,
const gfx::Size& size, const std::vector<unsigned char>& png);
void OnForceRedraw(int request_id);
void OnSelectWordAroundCaret();
#if defined(OS_ANDROID)
......@@ -1026,11 +1017,6 @@ class CONTENT_EXPORT RenderViewImpl
// Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
scoped_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
// State associated with the GetWindowSnapshot function.
int next_snapshot_id_;
typedef std::map<int, WindowSnapshotCallback> PendingSnapshotMap;
PendingSnapshotMap pending_snapshots_;
// This field stores drag/drop related info for the event that is currently
// being handled. If the current event results in starting a drag/drop
// session, this info is sent to the browser along with other drag/drop info.
......
......@@ -29,7 +29,6 @@ const char* GetComponentName(ui::LatencyComponentType type) {
CASE_TYPE(INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT);
CASE_TYPE(INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT);
CASE_TYPE(WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT);
CASE_TYPE(WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT);
CASE_TYPE(TAB_SHOW_COMPONENT);
CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT);
CASE_TYPE(INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT);
......
......@@ -47,10 +47,6 @@ enum LatencyComponentType {
// Frame number when a window snapshot was requested. The snapshot
// is taken when the rendering results actually reach the screen.
WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
// Frame number for a snapshot requested via
// gpuBenchmarking.beginWindowSnapshotPNG
// TODO(vkuzkokov): remove when patch adding this hits Stable
WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT,
// Timestamp when a tab is requested to be shown.
TAB_SHOW_COMPONENT,
// Timestamp when the frame is swapped in renderer.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment