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 #ifndef CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H |
| 6 #define CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "content/common/content_export.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 // Can't import scoped_nsobject here, so wrap it. |
| 16 struct AssertionWrapper; |
| 17 |
| 18 // A wrapper around the macOS "activity" system, which is required to |
| 19 // make renderers eligible for AppNap. |
| 20 // |
| 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. |
| 23 // When a process has no outstanding assertions, it becomes eligible for |
| 24 // AppNap. |
| 25 class CONTENT_EXPORT AppNapActivity { |
| 26 public: |
| 27 AppNapActivity(); |
| 28 ~AppNapActivity(); |
| 29 |
| 30 // Begin an activity and store the provided token. |
| 31 void Begin(); |
| 32 |
| 33 // End the activity represented by |assertion_|. |
| 34 void End(); |
| 35 |
| 36 private: |
| 37 // An opaque token provided by the OS on beginning an activity. |
| 38 std::unique_ptr<AssertionWrapper> assertion_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(AppNapActivity); |
| 41 }; |
| 42 |
| 43 } // namespace content |
| 44 |
| 45 #endif // CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H |
OLD | NEW |