Skip to content

Commit

Permalink
Use WebLockOrientationError instead of WebLockOrientationCallbackErro…
Browse files Browse the repository at this point in the history
…rType.

This is the Chromium side of https://codereview.chromium.org/332493003/

BUG=162827
TBR=jam@chromium.org (for content/common/DEPS)

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279073 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mlamouri@chromium.org committed Jun 23, 2014
1 parent e753c05 commit 30d7d44
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void ScreenOrientationDispatcherHost::OnLockRequest(
render_frame_host->Send(new ScreenOrientationMsg_LockError(
render_frame_host->GetRoutingID(),
request_id,
blink::WebLockOrientationCallback::ErrorTypeNotAvailable));
blink::WebLockOrientationErrorNotAvailable));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion content/common/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include_rules = [
"+third_party/WebKit/public/platform/WebIDBCursor.h",
"+third_party/WebKit/public/platform/WebIDBDatabase.h",
"+third_party/WebKit/public/platform/WebIDBTypes.h",
"+third_party/WebKit/public/platform/WebLockOrientationCallback.h",
"+third_party/WebKit/public/platform/WebLockOrientationError.h",
"+third_party/WebKit/public/platform/WebReferrerPolicy.h",
"+third_party/WebKit/public/platform/WebScreenOrientationLockType.h",
"+third_party/WebKit/public/platform/WebScreenOrientationType.h",
Expand Down
10 changes: 5 additions & 5 deletions content/common/screen_orientation_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "content/common/content_export.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/WebKit/public/platform/WebLockOrientationCallback.h"
#include "third_party/WebKit/public/platform/WebLockOrientationError.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationType.h"

Expand All @@ -23,9 +23,9 @@ IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScreenOrientationLockType,
blink::WebScreenOrientationLockDefault,
blink::WebScreenOrientationLockPortrait)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(
blink::WebLockOrientationCallback::ErrorType,
blink::WebLockOrientationCallback::ErrorTypeNotAvailable,
blink::WebLockOrientationCallback::ErrorTypeCanceled)
blink::WebLockOrientationError,
blink::WebLockOrientationErrorNotAvailable,
blink::WebLockOrientationErrorCanceled)

// The browser process informs the renderer process that the screen orientation
// has changed. |orientation| contains the new screen orientation in degrees.
Expand All @@ -48,7 +48,7 @@ IPC_MESSAGE_ROUTED3(ScreenOrientationMsg_LockSuccess,
// process can associate the response to the right request.
IPC_MESSAGE_ROUTED2(ScreenOrientationMsg_LockError,
int, /* request_id */
blink::WebLockOrientationCallback::ErrorType /* error */);
blink::WebLockOrientationError /* error */);

// The renderer process requests the browser process to lock the screen
// orientation to the specified |orientations|. The request contains a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ void ScreenOrientationDispatcher::OnLockSuccess(
}

void ScreenOrientationDispatcher::OnLockError(
int request_id,
blink::WebLockOrientationCallback::ErrorType error) {
int request_id, blink::WebLockOrientationError error) {
blink::WebLockOrientationCallback* callback =
pending_callbacks_.Lookup(request_id);
if (!callback)
Expand All @@ -57,8 +56,7 @@ void ScreenOrientationDispatcher::OnLockError(
void ScreenOrientationDispatcher::CancelPendingLocks() {
for (CallbackMap::Iterator<blink::WebLockOrientationCallback>
iterator(&pending_callbacks_); !iterator.IsAtEnd(); iterator.Advance()) {
iterator.GetCurrentValue()->onError(
blink::WebLockOrientationCallback::ErrorTypeCanceled);
iterator.GetCurrentValue()->onError(blink::WebLockOrientationErrorCanceled);
pending_callbacks_.Remove(iterator.GetCurrentKey());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CONTENT_EXPORT ScreenOrientationDispatcher :
unsigned angle,
blink::WebScreenOrientationType orientation);
void OnLockError(int request_id,
blink::WebLockOrientationCallback::ErrorType error);
blink::WebLockOrientationError error);

void CancelPendingLocks();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MockLockOrientationCallback :
bool failed_;
unsigned angle_;
blink::WebScreenOrientationType orientation_;
blink::WebLockOrientationCallback::ErrorType error_;
blink::WebLockOrientationError error_;
};

explicit MockLockOrientationCallback(LockOrientationResultHolder* results)
Expand All @@ -47,8 +47,7 @@ class MockLockOrientationCallback :
results_->orientation_ = orientation;
}

virtual void onError(
blink::WebLockOrientationCallback::ErrorType error) {
virtual void onError(blink::WebLockOrientationError error) {
results_->failed_ = true;
results_->error_ = error;
}
Expand Down Expand Up @@ -124,8 +123,7 @@ TEST_F(ScreenOrientationDispatcherTest, CancelPending_Unlocking) {

EXPECT_FALSE(callback_results.succeeded_);
EXPECT_TRUE(callback_results.failed_);
EXPECT_EQ(blink::WebLockOrientationCallback::ErrorTypeCanceled,
callback_results.error_);
EXPECT_EQ(blink::WebLockOrientationErrorCanceled, callback_results.error_);
}

// Test that calling lockOrientation() twice cancel the first lockOrientation().
Expand All @@ -141,20 +139,19 @@ TEST_F(ScreenOrientationDispatcherTest, CancelPending_DoubleLock) {

EXPECT_FALSE(callback_results.succeeded_);
EXPECT_TRUE(callback_results.failed_);
EXPECT_EQ(blink::WebLockOrientationCallback::ErrorTypeCanceled,
callback_results.error_);
EXPECT_EQ(blink::WebLockOrientationErrorCanceled, callback_results.error_);
}

// Test that when a LockError message is received, the request is set as failed
// with the correct values.
TEST_F(ScreenOrientationDispatcherTest, LockRequest_Error) {
std::list<blink::WebLockOrientationCallback::ErrorType> errors;
errors.push_back(blink::WebLockOrientationCallback::ErrorTypeNotAvailable);
std::list<blink::WebLockOrientationError> errors;
errors.push_back(blink::WebLockOrientationErrorNotAvailable);
errors.push_back(
blink::WebLockOrientationCallback::ErrorTypeFullScreenRequired);
errors.push_back(blink::WebLockOrientationCallback::ErrorTypeCanceled);
blink::WebLockOrientationErrorFullScreenRequired);
errors.push_back(blink::WebLockOrientationErrorCanceled);

for (std::list<blink::WebLockOrientationCallback::ErrorType>::const_iterator
for (std::list<blink::WebLockOrientationError>::const_iterator
it = errors.begin(); it != errors.end(); ++it) {
MockLockOrientationCallback::LockOrientationResultHolder callback_results;
LockOrientation(blink::WebScreenOrientationLockPortraitPrimary,
Expand Down Expand Up @@ -234,9 +231,7 @@ TEST_F(ScreenOrientationDispatcherTest, ErrorForUnknownRequest) {

int request_id = GetFirstLockRequestIdFromSink();
OnMessageReceived(ScreenOrientationMsg_LockError(
routing_id(),
request_id + 1,
blink::WebLockOrientationCallback::ErrorTypeCanceled));
routing_id(), request_id + 1, blink::WebLockOrientationErrorCanceled));

EXPECT_FALSE(callback_results.succeeded_);
EXPECT_FALSE(callback_results.failed_);
Expand Down Expand Up @@ -270,8 +265,7 @@ TEST_F(ScreenOrientationDispatcherTest, RaceScenario) {
// First request is still rejected.
EXPECT_FALSE(callback_results1.succeeded_);
EXPECT_TRUE(callback_results1.failed_);
EXPECT_EQ(blink::WebLockOrientationCallback::ErrorTypeCanceled,
callback_results1.error_);
EXPECT_EQ(blink::WebLockOrientationErrorCanceled, callback_results1.error_);

// Second request is still pending.
EXPECT_FALSE(callback_results2.succeeded_);
Expand Down

0 comments on commit 30d7d44

Please sign in to comment.