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

Side by Side Diff: content/renderer/screen_orientation/screen_orientation_dispatcher.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Rebase 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 "content/renderer/screen_orientation/screen_orientation_dispatcher.h" 5 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h"
6 6
7 #include <memory>
danakj 2016/11/30 00:34:01 this file wants utility for move() rather than mem
rlanday 2016/11/30 15:52:01 Oops...looks like git cl lint's flagging a couple
danakj 2016/11/30 19:25:06 Ya we don't reeally have include-what-you-use tho
8
7 #include "content/public/common/associated_interface_provider.h" 9 #include "content/public/common/associated_interface_provider.h"
8 #include "content/public/renderer/render_frame.h" 10 #include "content/public/renderer/render_frame.h"
9 11
10 namespace content { 12 namespace content {
11 13
12 using ::blink::mojom::ScreenOrientationLockResult; 14 using ::blink::mojom::ScreenOrientationLockResult;
13 15
14 ScreenOrientationDispatcher::ScreenOrientationDispatcher( 16 ScreenOrientationDispatcher::ScreenOrientationDispatcher(
15 RenderFrame* render_frame) 17 RenderFrame* render_frame)
16 : RenderFrameObserver(render_frame) { 18 : RenderFrameObserver(render_frame) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void ScreenOrientationDispatcher::CancelPendingLocks() { 60 void ScreenOrientationDispatcher::CancelPendingLocks() {
59 for (CallbackMap::Iterator<blink::WebLockOrientationCallback> 61 for (CallbackMap::Iterator<blink::WebLockOrientationCallback>
60 iterator(&pending_callbacks_); !iterator.IsAtEnd(); iterator.Advance()) { 62 iterator(&pending_callbacks_); !iterator.IsAtEnd(); iterator.Advance()) {
61 iterator.GetCurrentValue()->onError(blink::WebLockOrientationErrorCanceled); 63 iterator.GetCurrentValue()->onError(blink::WebLockOrientationErrorCanceled);
62 pending_callbacks_.Remove(iterator.GetCurrentKey()); 64 pending_callbacks_.Remove(iterator.GetCurrentKey());
63 } 65 }
64 } 66 }
65 67
66 void ScreenOrientationDispatcher::lockOrientation( 68 void ScreenOrientationDispatcher::lockOrientation(
67 blink::WebScreenOrientationLockType orientation, 69 blink::WebScreenOrientationLockType orientation,
68 blink::WebLockOrientationCallback* callback) { 70 std::unique_ptr<blink::WebLockOrientationCallback> callback) {
69 CancelPendingLocks(); 71 CancelPendingLocks();
70 72
71 int request_id = pending_callbacks_.Add(callback); 73 int request_id = pending_callbacks_.Add(std::move(callback));
72 EnsureScreenOrientationService(); 74 EnsureScreenOrientationService();
73 screen_orientation_->LockOrientation( 75 screen_orientation_->LockOrientation(
74 orientation, 76 orientation,
75 base::Bind(&ScreenOrientationDispatcher::OnLockOrientationResult, 77 base::Bind(&ScreenOrientationDispatcher::OnLockOrientationResult,
76 base::Unretained(this), request_id)); 78 base::Unretained(this), request_id));
77 } 79 }
78 80
79 void ScreenOrientationDispatcher::unlockOrientation() { 81 void ScreenOrientationDispatcher::unlockOrientation() {
80 CancelPendingLocks(); 82 CancelPendingLocks();
81 EnsureScreenOrientationService(); 83 EnsureScreenOrientationService();
82 screen_orientation_->UnlockOrientation(); 84 screen_orientation_->UnlockOrientation();
83 } 85 }
84 86
85 void ScreenOrientationDispatcher::EnsureScreenOrientationService() { 87 void ScreenOrientationDispatcher::EnsureScreenOrientationService() {
86 if (!screen_orientation_) { 88 if (!screen_orientation_) {
87 render_frame()->GetRemoteAssociatedInterfaces()->GetInterface( 89 render_frame()->GetRemoteAssociatedInterfaces()->GetInterface(
88 &screen_orientation_); 90 &screen_orientation_);
89 } 91 }
90 } 92 }
91 93
92 int ScreenOrientationDispatcher::GetRequestIdForTests() { 94 int ScreenOrientationDispatcher::GetRequestIdForTests() {
93 if (pending_callbacks_.IsEmpty()) 95 if (pending_callbacks_.IsEmpty())
94 return -1; 96 return -1;
95 CallbackMap::Iterator<blink::WebLockOrientationCallback> iterator( 97 CallbackMap::Iterator<blink::WebLockOrientationCallback> iterator(
96 &pending_callbacks_); 98 &pending_callbacks_);
97 return iterator.GetCurrentKey(); 99 return iterator.GetCurrentKey();
98 } 100 }
99 101
100 } // namespace content 102 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698