Commit 55d3c92a authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Don't use WebLockOrientationCallback::OnSuccess() with arguments.

Blink doesn't use the arguments anymore, the promise is always resolved
with undefined.

BUG=162827

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284412 0039d316-1c4b-4281-b951-d872f2087c98
parent ea273f3d
......@@ -71,17 +71,8 @@ void ScreenOrientationDispatcherHost::NotifyLockSuccess(int request_id) {
if (!render_frame_host)
return;
DCHECK(web_contents()->GetRenderViewHost());
RenderWidgetHost* rwh = web_contents()->GetRenderViewHost();
blink::WebScreenInfo screen_info;
rwh->GetWebScreenInfo(&screen_info);
render_frame_host->Send(new ScreenOrientationMsg_LockSuccess(
render_frame_host->GetRoutingID(),
request_id,
screen_info.orientationAngle,
screen_info.orientationType));
render_frame_host->GetRoutingID(), request_id));
ResetCurrentLock();
}
......
......@@ -34,13 +34,11 @@ IPC_MESSAGE_CONTROL1(ScreenOrientationMsg_OrientationChange,
blink::WebScreenOrientationType /* orientation */ )
// The browser process' response to a ScreenOrientationHostMsg_LockRequest when
// the lock actually succeeded. The message includes the new |angle| and |type|
// of orientation. The |request_id| passed when receiving the request is passed
// back so the renderer process can associate the response to the right request.
IPC_MESSAGE_ROUTED3(ScreenOrientationMsg_LockSuccess,
int, /* request_id */
unsigned, /* angle */
blink::WebScreenOrientationType /* type */)
// the lock actually succeeded. The |request_id| passed when receiving the
// request is passed back so the renderer process can associate the response to
// the right request.
IPC_MESSAGE_ROUTED1(ScreenOrientationMsg_LockSuccess,
int /* request_id */)
// The browser process' response to a ScreenOrientationHostMsg_LockRequest when
// the lock actually failed. The message includes the |error| type. The
......
......@@ -31,15 +31,12 @@ bool ScreenOrientationDispatcher::OnMessageReceived(
return handled;
}
void ScreenOrientationDispatcher::OnLockSuccess(
int request_id,
unsigned angle,
blink::WebScreenOrientationType orientation) {
void ScreenOrientationDispatcher::OnLockSuccess(int request_id) {
blink::WebLockOrientationCallback* callback =
pending_callbacks_.Lookup(request_id);
if (!callback)
return;
callback->onSuccess(angle, orientation);
callback->onSuccess();
pending_callbacks_.Remove(request_id);
}
......
......@@ -41,9 +41,7 @@ class CONTENT_EXPORT ScreenOrientationDispatcher :
blink::WebLockOrientationCallback* callback) OVERRIDE;
virtual void unlockOrientation() OVERRIDE;
void OnLockSuccess(int request_id,
unsigned angle,
blink::WebScreenOrientationType orientation);
void OnLockSuccess(int request_id);
void OnLockError(int request_id,
blink::WebLockOrientationError error);
......
......@@ -32,19 +32,14 @@ class MockLockOrientationCallback :
bool succeeded_;
bool failed_;
unsigned angle_;
blink::WebScreenOrientationType orientation_;
blink::WebLockOrientationError error_;
};
explicit MockLockOrientationCallback(LockOrientationResultHolder* results)
: results_(results) {}
virtual void onSuccess(unsigned angle,
blink::WebScreenOrientationType orientation) {
virtual void onSuccess() {
results_->succeeded_ = true;
results_->angle_ = angle;
results_->orientation_ = orientation;
}
virtual void onError(blink::WebLockOrientationError error) {
......@@ -170,38 +165,20 @@ TEST_F(ScreenOrientationDispatcherTest, LockRequest_Error) {
}
// Test that when a LockSuccess message is received, the request is set as
// succeeded with the correct values.
// succeeded.
TEST_F(ScreenOrientationDispatcherTest, LockRequest_Success) {
struct ScreenOrientationInformation {
unsigned angle;
blink::WebScreenOrientationType type;
} orientations[] = {
{ 0, blink::WebScreenOrientationPortraitPrimary },
{ 0, blink::WebScreenOrientationLandscapePrimary },
{ 90, blink::WebScreenOrientationPortraitSecondary },
{ 90, blink::WebScreenOrientationLandscapePrimary }
};
int orientationsCount = 4;
for (int i = 0; i < orientationsCount; ++i) {
MockLockOrientationCallback::LockOrientationResultHolder callback_results;
LockOrientation(blink::WebScreenOrientationLockPortraitPrimary,
new MockLockOrientationCallback(&callback_results));
MockLockOrientationCallback::LockOrientationResultHolder callback_results;
LockOrientation(blink::WebScreenOrientationLockPortraitPrimary,
new MockLockOrientationCallback(&callback_results));
int request_id = GetFirstLockRequestIdFromSink();
OnMessageReceived(ScreenOrientationMsg_LockSuccess(routing_id(),
request_id,
orientations[i].angle,
orientations[i].type));
int request_id = GetFirstLockRequestIdFromSink();
OnMessageReceived(ScreenOrientationMsg_LockSuccess(routing_id(),
request_id));
EXPECT_TRUE(callback_results.succeeded_);
EXPECT_FALSE(callback_results.failed_);
EXPECT_EQ(orientations[i].angle, callback_results.angle_);
EXPECT_EQ(orientations[i].type, callback_results.orientation_);
EXPECT_TRUE(callback_results.succeeded_);
EXPECT_FALSE(callback_results.failed_);
sink().ClearMessages();
}
sink().ClearMessages();
}
// Test an edge case: a LockSuccess is received but it matches no pending
......@@ -212,11 +189,8 @@ TEST_F(ScreenOrientationDispatcherTest, SuccessForUnknownRequest) {
new MockLockOrientationCallback(&callback_results));
int request_id = GetFirstLockRequestIdFromSink();
OnMessageReceived(ScreenOrientationMsg_LockSuccess(
routing_id(),
request_id + 1,
90,
blink::WebScreenOrientationLandscapePrimary));
OnMessageReceived(ScreenOrientationMsg_LockSuccess(routing_id(),
request_id + 1));
EXPECT_FALSE(callback_results.succeeded_);
EXPECT_FALSE(callback_results.failed_);
......@@ -256,11 +230,8 @@ TEST_F(ScreenOrientationDispatcherTest, RaceScenario) {
// callback_results1 must be rejected, tested in CancelPending_DoubleLock.
OnMessageReceived(ScreenOrientationMsg_LockSuccess(
routing_id(),
request_id1,
0,
blink::WebScreenOrientationPortraitPrimary));
OnMessageReceived(ScreenOrientationMsg_LockSuccess(routing_id(),
request_id1));
// First request is still rejected.
EXPECT_FALSE(callback_results1.succeeded_);
......
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