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

Unified Diff: content/common/mac/app_nap_activity.h

Issue 2913883002: [Mac] Wrap NSUserActivity begin/end so that it can be called from common files (Closed)
Patch Set: Whitespace Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/mac/app_nap_activity.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mac/app_nap_activity.h
diff --git a/content/common/mac/app_nap_activity.h b/content/common/mac/app_nap_activity.h
new file mode 100644
index 0000000000000000000000000000000000000000..c07f9ee8941d548b4eb30d27046909fd8724c371
--- /dev/null
+++ b/content/common/mac/app_nap_activity.h
@@ -0,0 +1,45 @@
+// 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_APP_NAP_ACTIVITY_H
+#define CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
+
+#include <memory>
+
+#include "base/macros.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+// Can't import scoped_nsobject here, so wrap it.
+struct 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 AppNapActivity {
+ public:
+ AppNapActivity();
+ ~AppNapActivity();
+
+ // Begin an activity and store the provided token.
+ void Begin();
+
+ // End the activity represented by |assertion_|.
+ void End();
+
+ private:
+ // An opaque token provided by the OS on beginning an activity.
+ std::unique_ptr<AssertionWrapper> assertion_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppNapActivity);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/mac/app_nap_activity.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698