Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/common/mac/app_nap_activity.h" | |
| 6 | |
| 7 #import <Foundation/Foundation.h> | |
| 8 | |
| 9 #include "base/mac/scoped_nsobject.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 namespace { | |
| 14 NSString* const kActivityReason = @"Process foregrounded"; | |
| 15 const NSActivityOptions kActivityOptions = | |
| 16 (NSActivityUserInitiatedAllowingIdleSystemSleep | | |
| 17 NSActivityLatencyCritical) & | |
| 18 ~(NSActivitySuddenTerminationDisabled | | |
| 19 NSActivityAutomaticTerminationDisabled); | |
| 20 | |
| 21 } // namespace | |
| 22 | |
| 23 struct AssertionWrapper { | |
| 24 public: | |
|
Robert Sesek
2017/05/31 22:21:56
struct members are public by default, so you can o
lgrey
2017/06/01 15:51:10
Done.
| |
| 25 base::scoped_nsobject<id> obj_; | |
|
Robert Sesek
2017/05/31 22:21:56
You can also omit trailing _ on public struct memb
lgrey
2017/06/01 15:51:10
Done.
| |
| 26 }; | |
| 27 | |
| 28 AppNapActivity::AppNapActivity() { | |
| 29 assertion_.reset(new AssertionWrapper()); | |
| 30 }; | |
| 31 | |
| 32 AppNapActivity::~AppNapActivity() { | |
| 33 DCHECK(!assertion_->obj_.get()); | |
| 34 }; | |
| 35 | |
| 36 void AppNapActivity::Begin() { | |
| 37 DCHECK(!assertion_->obj_.get()); | |
| 38 id assertion = | |
| 39 [[NSProcessInfo processInfo] beginActivityWithOptions:kActivityOptions | |
| 40 reason:kActivityReason]; | |
| 41 assertion_->obj_.reset([assertion retain]); | |
| 42 } | |
| 43 | |
| 44 void AppNapActivity::End() { | |
| 45 id assertion = assertion_->obj_.autorelease(); | |
| 46 DCHECK(assertion); | |
| 47 [[NSProcessInfo processInfo] endActivity:assertion]; | |
| 48 } | |
|
Robert Sesek
2017/05/31 22:21:56
nit: blank line after
lgrey
2017/06/01 15:51:10
Done.
| |
| 49 } // namespace content | |
| OLD | NEW |