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

Side by Side Diff: content/shell/renderer/test_runner/mock_screen_orientation_client.cc

Issue 426923004: Fix a test-only leak in MockScreenOrientationClient. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" 5 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "third_party/WebKit/public/web/WebFrame.h" 10 #include "third_party/WebKit/public/web/WebFrame.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 void MockScreenOrientationClient::UpdateLockSync( 127 void MockScreenOrientationClient::UpdateLockSync(
128 blink::WebScreenOrientationLockType lock, 128 blink::WebScreenOrientationLockType lock,
129 blink::WebLockOrientationCallback* callback) { 129 blink::WebLockOrientationCallback* callback) {
130 DCHECK(lock != blink::WebScreenOrientationLockDefault); 130 DCHECK(lock != blink::WebScreenOrientationLockDefault);
131 current_lock_ = lock; 131 current_lock_ = lock;
132 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) 132 if (!IsOrientationAllowedByCurrentLock(current_orientation_))
133 UpdateScreenOrientation(SuitableOrientationForCurrentLock()); 133 UpdateScreenOrientation(SuitableOrientationForCurrentLock());
134 callback->onSuccess(); 134 callback->onSuccess();
135 delete callback;
135 } 136 }
136 137
137 void MockScreenOrientationClient::ResetLockSync() { 138 void MockScreenOrientationClient::ResetLockSync() {
138 bool will_screen_orientation_need_updating = 139 bool will_screen_orientation_need_updating =
139 !IsOrientationAllowedByCurrentLock(device_orientation_); 140 !IsOrientationAllowedByCurrentLock(device_orientation_);
140 current_lock_ = blink::WebScreenOrientationLockDefault; 141 current_lock_ = blink::WebScreenOrientationLockDefault;
141 if (will_screen_orientation_need_updating) 142 if (will_screen_orientation_need_updating)
142 UpdateScreenOrientation(device_orientation_); 143 UpdateScreenOrientation(device_orientation_);
143 } 144 }
144 145
145 blink::WebScreenOrientationType 146 blink::WebScreenOrientationType
146 MockScreenOrientationClient::SuitableOrientationForCurrentLock() { 147 MockScreenOrientationClient::SuitableOrientationForCurrentLock() {
147 switch (current_lock_) { 148 switch (current_lock_) {
148 case blink::WebScreenOrientationLockPortraitSecondary: 149 case blink::WebScreenOrientationLockPortraitSecondary:
149 return blink::WebScreenOrientationPortraitSecondary; 150 return blink::WebScreenOrientationPortraitSecondary;
150 case blink::WebScreenOrientationLockLandscapePrimary: 151 case blink::WebScreenOrientationLockLandscapePrimary:
151 case blink::WebScreenOrientationLockLandscape: 152 case blink::WebScreenOrientationLockLandscape:
152 return blink::WebScreenOrientationLandscapePrimary; 153 return blink::WebScreenOrientationLandscapePrimary;
153 case blink::WebScreenOrientationLockLandscapeSecondary: 154 case blink::WebScreenOrientationLockLandscapeSecondary:
154 return blink::WebScreenOrientationLandscapePrimary; 155 return blink::WebScreenOrientationLandscapePrimary;
155 default: 156 default:
156 return blink::WebScreenOrientationPortraitPrimary; 157 return blink::WebScreenOrientationPortraitPrimary;
157 } 158 }
158 } 159 }
159 160
160 } // namespace content 161 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698