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

Side by Side Diff: content/common/mac/app_nap_activity.mm

Issue 2913883002: [Mac] Wrap NSUserActivity begin/end so that it can be called from common files (Closed)
Patch Set: CL comments Created 3 years, 6 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
« no previous file with comments | « content/common/mac/app_nap_activity.h ('k') | content/common/mac/app_nap_activity_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « content/common/mac/app_nap_activity.h ('k') | content/common/mac/app_nap_activity_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698