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