Index: content/common/mac/activity.h |
diff --git a/content/common/mac/activity.h b/content/common/mac/activity.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2ac2896377f6c5976c467ea28119c511cacaa983 |
--- /dev/null |
+++ b/content/common/mac/activity.h |
@@ -0,0 +1,41 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_COMMON_MAC_ACTIVITY_H |
+#define CONTENT_COMMON_MAC_ACTIVITY_H |
+ |
+#include <memory> |
+ |
+#include "base/macros.h" |
+#include "content/common/content_export.h" |
+ |
+namespace mac { |
Robert Sesek
2017/05/31 18:11:26
nit: blank lines surrounding the inside of the nam
Robert Sesek
2017/05/31 18:11:26
use |namespace content|
lgrey
2017/05/31 21:28:11
Done.
lgrey
2017/05/31 21:28:11
Done.
|
+// Can't import scoped_nsobject here, so wrap it. |
+class AssertionWrapper; |
+ |
+// A wrapper around the macOS "activity" system, which is required to |
+// make renderers eligible for AppNap. |
+// |
+// When doing work, processes are expected to begin an activity, receiving |
+// an opaque token called an "assertion". On finishing, they end the activity. |
+// When a process has no outstanding assertions, it becomes eligible for |
+// AppNap. |
+class CONTENT_EXPORT Activity { |
Robert Sesek
2017/05/31 18:11:26
"Activity" is a bit broad of a name. What about "A
lgrey
2017/05/31 21:28:12
Done.
|
+ public: |
+ Activity(); |
+ // Begin an activity and store the provided token. |
+ void Begin(); |
Robert Sesek
2017/05/31 18:11:26
nit: blank line after
lgrey
2017/05/31 21:28:11
Done.
|
+ // End the activity represented by |assertion_|. |
+ void End(); |
+ ~Activity(); |
Robert Sesek
2017/05/31 18:11:26
Put this after the ctor.
lgrey
2017/05/31 21:28:12
Done.
|
+ |
+ private: |
+ // An opaque token provided by the OS on beginning an activity. |
+ std::unique_ptr<AssertionWrapper> assertion_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Activity); |
+}; |
+} // namespace mac |
+ |
+#endif // CONTENT_COMMON_MAC_ACTIVITY_H |