perf: cache whether or not ELECTRON_DEBUG_NOTIFICATIONS env var is set (#45143)
* perf: cache whether or not ELECTRON_DEBUG_NOTIFICATIONS env var is set * chore: remove unused #include
This commit is contained in:
parent
59ed1db9a2
commit
062d14e553
7 changed files with 12 additions and 12 deletions
|
@ -44,7 +44,7 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
|||
[notification_ setInformativeText:base::SysUTF16ToNSString(options.msg)];
|
||||
[notification_ setIdentifier:identifier];
|
||||
|
||||
if (getenv("ELECTRON_DEBUG_NOTIFICATIONS")) {
|
||||
if (electron::debug_notifications) {
|
||||
LOG(INFO) << "Notification created (" << [identifier UTF8String] << ")";
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ void CocoaNotification::NotificationDismissed() {
|
|||
}
|
||||
|
||||
void CocoaNotification::LogAction(const char* action) {
|
||||
if (getenv("ELECTRON_DEBUG_NOTIFICATIONS") && notification_) {
|
||||
if (electron::debug_notifications && notification_) {
|
||||
NSString* identifier = [notification_ valueForKey:@"identifier"];
|
||||
DCHECK(identifier);
|
||||
LOG(INFO) << "Notification " << action << " (" << [identifier UTF8String]
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
didActivateNotification:(NSUserNotification*)notif {
|
||||
auto* notification = presenter_->GetNotification(notif);
|
||||
|
||||
if (getenv("ELECTRON_DEBUG_NOTIFICATIONS")) {
|
||||
if (electron::debug_notifications) {
|
||||
LOG(INFO) << "Notification activated (" << [notif.identifier UTF8String]
|
||||
<< ")";
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ CocoaNotification* NotificationPresenterMac::GetNotification(
|
|||
return native_notification;
|
||||
}
|
||||
|
||||
if (getenv("ELECTRON_DEBUG_NOTIFICATIONS")) {
|
||||
if (electron::debug_notifications) {
|
||||
LOG(INFO) << "Could not find notification for "
|
||||
<< [ns_notification.identifier UTF8String];
|
||||
}
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
|
||||
#include "shell/browser/notifications/notification.h"
|
||||
|
||||
#include "base/environment.h"
|
||||
#include "shell/browser/notifications/notification_delegate.h"
|
||||
#include "shell/browser/notifications/notification_presenter.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
const bool debug_notifications =
|
||||
base::Environment::Create()->HasVar("ELECTRON_DEBUG_NOTIFICATIONS");
|
||||
|
||||
NotificationOptions::NotificationOptions() = default;
|
||||
NotificationOptions::~NotificationOptions() = default;
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace electron {
|
||||
|
||||
extern const bool debug_notifications;
|
||||
|
||||
class NotificationDelegate;
|
||||
class NotificationPresenter;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/environment.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/hash/md5.h"
|
||||
#include "base/logging.h"
|
||||
|
@ -27,10 +26,6 @@ namespace electron {
|
|||
|
||||
namespace {
|
||||
|
||||
bool IsDebuggingNotifications() {
|
||||
return base::Environment::Create()->HasVar("ELECTRON_DEBUG_NOTIFICATIONS");
|
||||
}
|
||||
|
||||
bool SaveIconToPath(const SkBitmap& bitmap, const base::FilePath& path) {
|
||||
std::optional<std::vector<uint8_t>> png_data =
|
||||
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false);
|
||||
|
@ -50,7 +45,7 @@ std::unique_ptr<NotificationPresenter> NotificationPresenter::Create() {
|
|||
if (!presenter->Init())
|
||||
return {};
|
||||
|
||||
if (IsDebuggingNotifications())
|
||||
if (electron::debug_notifications)
|
||||
LOG(INFO) << "Successfully created Windows notifications presenter";
|
||||
|
||||
return presenter;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <shlobj.h>
|
||||
#include <wrl\wrappers\corewrappers.h>
|
||||
|
||||
#include "base/environment.h"
|
||||
#include "base/hash/hash.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/strcat.h"
|
||||
|
@ -66,7 +65,7 @@ namespace {
|
|||
constexpr wchar_t kGroup[] = L"Notifications";
|
||||
|
||||
void DebugLog(std::string_view log_msg) {
|
||||
if (base::Environment::Create()->HasVar("ELECTRON_DEBUG_NOTIFICATIONS"))
|
||||
if (electron::debug_notifications)
|
||||
LOG(INFO) << log_msg;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue