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

Side by Side Diff: components/test_runner/mock_screen_orientation_client.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Make changes requested by danakj, fix a few more headers Created 4 years 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
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 "components/test_runner/mock_screen_orientation_client.h" 5 #include "components/test_runner/mock_screen_orientation_client.h"
6 6
7 #include <memory>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
11 #include "third_party/WebKit/public/web/WebLocalFrame.h" 13 #include "third_party/WebKit/public/web/WebLocalFrame.h"
12 14
13 namespace test_runner { 15 namespace test_runner {
14 16
15 MockScreenOrientationClient::MockScreenOrientationClient() 17 MockScreenOrientationClient::MockScreenOrientationClient()
16 : main_frame_(NULL), 18 : main_frame_(NULL),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return current_lock_ == 110 return current_lock_ ==
109 blink::WebScreenOrientationLockLandscapeSecondary || 111 blink::WebScreenOrientationLockLandscapeSecondary ||
110 current_lock_ == blink::WebScreenOrientationLockLandscape; 112 current_lock_ == blink::WebScreenOrientationLockLandscape;
111 default: 113 default:
112 return false; 114 return false;
113 } 115 }
114 } 116 }
115 117
116 void MockScreenOrientationClient::lockOrientation( 118 void MockScreenOrientationClient::lockOrientation(
117 blink::WebScreenOrientationLockType orientation, 119 blink::WebScreenOrientationLockType orientation,
118 blink::WebLockOrientationCallback* callback) { 120 std::unique_ptr<blink::WebLockOrientationCallback> callback) {
119 base::ThreadTaskRunnerHandle::Get()->PostTask( 121 base::ThreadTaskRunnerHandle::Get()->PostTask(
120 FROM_HERE, base::Bind(&MockScreenOrientationClient::UpdateLockSync, 122 FROM_HERE,
121 base::Unretained(this), orientation, callback)); 123 base::Bind(&MockScreenOrientationClient::UpdateLockSync,
124 base::Unretained(this), orientation, base::Passed(&callback)));
122 } 125 }
123 126
124 void MockScreenOrientationClient::unlockOrientation() { 127 void MockScreenOrientationClient::unlockOrientation() {
125 base::ThreadTaskRunnerHandle::Get()->PostTask( 128 base::ThreadTaskRunnerHandle::Get()->PostTask(
126 FROM_HERE, base::Bind(&MockScreenOrientationClient::ResetLockSync, 129 FROM_HERE, base::Bind(&MockScreenOrientationClient::ResetLockSync,
127 base::Unretained(this))); 130 base::Unretained(this)));
128 } 131 }
129 132
130 void MockScreenOrientationClient::UpdateLockSync( 133 void MockScreenOrientationClient::UpdateLockSync(
131 blink::WebScreenOrientationLockType lock, 134 blink::WebScreenOrientationLockType lock,
132 blink::WebLockOrientationCallback* callback) { 135 std::unique_ptr<blink::WebLockOrientationCallback> callback) {
133 DCHECK(lock != blink::WebScreenOrientationLockDefault); 136 DCHECK(lock != blink::WebScreenOrientationLockDefault);
134 current_lock_ = lock; 137 current_lock_ = lock;
135 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) 138 if (!IsOrientationAllowedByCurrentLock(current_orientation_))
136 UpdateScreenOrientation(SuitableOrientationForCurrentLock()); 139 UpdateScreenOrientation(SuitableOrientationForCurrentLock());
137 callback->onSuccess(); 140 callback->onSuccess();
138 delete callback;
139 } 141 }
140 142
141 void MockScreenOrientationClient::ResetLockSync() { 143 void MockScreenOrientationClient::ResetLockSync() {
142 bool will_screen_orientation_need_updating = 144 bool will_screen_orientation_need_updating =
143 !IsOrientationAllowedByCurrentLock(device_orientation_); 145 !IsOrientationAllowedByCurrentLock(device_orientation_);
144 current_lock_ = blink::WebScreenOrientationLockDefault; 146 current_lock_ = blink::WebScreenOrientationLockDefault;
145 if (will_screen_orientation_need_updating) 147 if (will_screen_orientation_need_updating)
146 UpdateScreenOrientation(device_orientation_); 148 UpdateScreenOrientation(device_orientation_);
147 } 149 }
148 150
149 blink::WebScreenOrientationType 151 blink::WebScreenOrientationType
150 MockScreenOrientationClient::SuitableOrientationForCurrentLock() { 152 MockScreenOrientationClient::SuitableOrientationForCurrentLock() {
151 switch (current_lock_) { 153 switch (current_lock_) {
152 case blink::WebScreenOrientationLockPortraitSecondary: 154 case blink::WebScreenOrientationLockPortraitSecondary:
153 return blink::WebScreenOrientationPortraitSecondary; 155 return blink::WebScreenOrientationPortraitSecondary;
154 case blink::WebScreenOrientationLockLandscapePrimary: 156 case blink::WebScreenOrientationLockLandscapePrimary:
155 case blink::WebScreenOrientationLockLandscape: 157 case blink::WebScreenOrientationLockLandscape:
156 return blink::WebScreenOrientationLandscapePrimary; 158 return blink::WebScreenOrientationLandscapePrimary;
157 case blink::WebScreenOrientationLockLandscapeSecondary: 159 case blink::WebScreenOrientationLockLandscapeSecondary:
158 return blink::WebScreenOrientationLandscapePrimary; 160 return blink::WebScreenOrientationLandscapePrimary;
159 default: 161 default:
160 return blink::WebScreenOrientationPortraitPrimary; 162 return blink::WebScreenOrientationPortraitPrimary;
161 } 163 }
162 } 164 }
163 165
164 } // namespace test_runner 166 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/mock_screen_orientation_client.h ('k') | content/browser/cache_storage/cache_storage_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698