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

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

Issue 2914913002: [Mac] Enable AppNap for renderers (Closed)
Patch Set: Add comment for magic numbers 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/child/child_thread_impl.cc ('k') | content/common/mac/app_nap_activity.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 #ifndef CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H 5 #ifndef CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
6 #define CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H 6 #define CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 // Can't import scoped_nsobject here, so wrap it. 15 // Can't import scoped_nsobject here, so wrap it.
16 struct AssertionWrapper; 16 struct AssertionWrapper;
17 17
18 // A wrapper around the macOS "activity" system, which is required to 18 // A wrapper around the macOS "activity" system, which is required to
19 // make renderers eligible for AppNap. 19 // make renderers eligible for AppNap.
20 // 20 //
21 // When doing work, processes are expected to begin an activity, receiving 21 // When doing work, processes are expected to begin an activity, receiving
22 // an opaque token called an "assertion". On finishing, they end the activity. 22 // an opaque token called an "assertion". On finishing, they end the activity.
23 // When a process has no outstanding assertions, it becomes eligible for 23 // When a process has no outstanding assertions, it becomes eligible for
24 // AppNap. 24 // AppNap.
25 class CONTENT_EXPORT AppNapActivity { 25 class CONTENT_EXPORT AppNapActivity {
26 public: 26 public:
27 AppNapActivity(); 27 AppNapActivity();
28 ~AppNapActivity(); 28 ~AppNapActivity();
29 29
30 // Because there's no NSApplication in renderers, do some housekeeping
31 // to become eligible for App Nap.
32 static void InitializeAppNapSupport();
33
30 // Begin an activity and store the provided token. 34 // Begin an activity and store the provided token.
31 void Begin(); 35 void Begin();
32 36
33 // End the activity represented by |assertion_|. 37 // End the activity represented by |assertion_|.
34 void End(); 38 void End();
35 39
36 private: 40 private:
37 // An opaque token provided by the OS on beginning an activity. 41 // An opaque token provided by the OS on beginning an activity.
38 std::unique_ptr<AssertionWrapper> assertion_; 42 std::unique_ptr<AssertionWrapper> assertion_;
39 43
40 DISALLOW_COPY_AND_ASSIGN(AppNapActivity); 44 DISALLOW_COPY_AND_ASSIGN(AppNapActivity);
41 }; 45 };
42 46
43 } // namespace content 47 } // namespace content
44 48
45 #endif // CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H 49 #endif // CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.cc ('k') | content/common/mac/app_nap_activity.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698