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

Side by Side Diff: content/browser/wake_lock/wake_lock_service_context.cc

Issue 1609923002: Fix remaining incompatibilities between scoped_ptr and unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser/wake_lock/wake_lock_service_context.h" 5 #include "content/browser/wake_lock/wake_lock_service_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 void WakeLockServiceContext::CancelWakeLock(int render_process_id, 50 void WakeLockServiceContext::CancelWakeLock(int render_process_id,
51 int render_frame_id) { 51 int render_frame_id) {
52 DCHECK_CURRENTLY_ON(BrowserThread::UI); 52 DCHECK_CURRENTLY_ON(BrowserThread::UI);
53 frames_requesting_lock_.erase( 53 frames_requesting_lock_.erase(
54 std::pair<int, int>(render_process_id, render_frame_id)); 54 std::pair<int, int>(render_process_id, render_frame_id));
55 UpdateWakeLock(); 55 UpdateWakeLock();
56 } 56 }
57 57
58 bool WakeLockServiceContext::HasWakeLockForTests() const { 58 bool WakeLockServiceContext::HasWakeLockForTests() const {
59 return wake_lock_; 59 return !!wake_lock_;
60 } 60 }
61 61
62 void WakeLockServiceContext::CreateWakeLock() { 62 void WakeLockServiceContext::CreateWakeLock() {
63 DCHECK(!wake_lock_); 63 DCHECK(!wake_lock_);
64 wake_lock_ = PowerSaveBlocker::Create( 64 wake_lock_ = PowerSaveBlocker::Create(
65 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, 65 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
66 PowerSaveBlocker::kReasonOther, "Wake Lock API"); 66 PowerSaveBlocker::kReasonOther, "Wake Lock API");
67 67
68 #if defined(OS_ANDROID) && !defined(USE_AURA) 68 #if defined(OS_ANDROID) && !defined(USE_AURA)
69 // On Android, additionaly associate the blocker with this WebContents. 69 // On Android, additionaly associate the blocker with this WebContents.
(...skipping 13 matching lines...) Expand all
83 if (!frames_requesting_lock_.empty()) { 83 if (!frames_requesting_lock_.empty()) {
84 if (!wake_lock_) 84 if (!wake_lock_)
85 CreateWakeLock(); 85 CreateWakeLock();
86 } else { 86 } else {
87 if (wake_lock_) 87 if (wake_lock_)
88 RemoveWakeLock(); 88 RemoveWakeLock();
89 } 89 }
90 } 90 }
91 91
92 } // namespace content 92 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698