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

Unified Diff: content/renderer/screen_orientation/mock_screen_orientation_controller.cc

Issue 300063012: Make async methods UpdateLock() and ResetLock() in MockScreenOrientationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated by comments Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/screen_orientation/mock_screen_orientation_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/screen_orientation/mock_screen_orientation_controller.cc
diff --git a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
index d16bc74e38d484a85ae12d069d94b877f7bbdace..bbff907dda565e8793d8b3539f8bbe4f78feb353 100644
--- a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
+++ b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
@@ -4,7 +4,9 @@
#include "content/renderer/screen_orientation/mock_screen_orientation_controller.h"
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationListener.h"
namespace content {
@@ -14,6 +16,12 @@ MockScreenOrientationController::MockScreenOrientationController()
device_orientation_(blink::WebScreenOrientationPortraitPrimary),
current_orientation_(blink::WebScreenOrientationPortraitPrimary),
listener_(NULL) {
+ // Since MockScreenOrientationController is held by LazyInstance reference,
+ // add this ref for it.
+ AddRef();
+}
+
+MockScreenOrientationController::~MockScreenOrientationController() {
}
void MockScreenOrientationController::SetListener(
@@ -29,6 +37,12 @@ void MockScreenOrientationController::ResetData() {
void MockScreenOrientationController::UpdateLock(
blink::WebScreenOrientationLockType lock) {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MockScreenOrientationController::UpdateLockSync, this, lock));
+}
+void MockScreenOrientationController::UpdateLockSync(
+ blink::WebScreenOrientationLockType lock) {
DCHECK(lock != blink::WebScreenOrientationLockDefault);
current_lock_ = lock;
if (!IsOrientationAllowedByCurrentLock(current_orientation_))
@@ -36,6 +50,12 @@ void MockScreenOrientationController::UpdateLock(
}
void MockScreenOrientationController::ResetLock() {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MockScreenOrientationController::ResetLockSync, this));
+}
+
+void MockScreenOrientationController::ResetLockSync() {
bool will_screen_orientation_need_updating =
!IsOrientationAllowedByCurrentLock(device_orientation_);
current_lock_ = blink::WebScreenOrientationLockDefault;
« no previous file with comments | « content/renderer/screen_orientation/mock_screen_orientation_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698