Commit e06379e6 authored by Wenbin Zhang's avatar Wenbin Zhang Committed by Chromium LUCI CQ

Revert "Cache Mac channel information"

This reverts commit aa20f9b8.

Reason for revert: Mac builders on perf waterfall are failing after this CL:
https://ci.chromium.org/p/chrome/builders/ci/mac-builder-perf

Original change's description:
> Cache Mac channel information
>
> Soon, with TargetChannel, an instance of Chrome on the disk
> might be upgraded to an instance of Chrome of a different
> channel. Cache the channel information on startup, so that
> even if it's changed, the channel information of the current
> running instance is available.
>
> Fixed: 1163159
> Change-Id: Ie9ffd98325a0da335778206709f94ea5591e9af0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2618041
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Commit-Queue: Avi Drissman <avi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#841840}

TBR=avi@chromium.org,mark@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ib6095e36b6c9964693607cfeba5b06e3acd1c42f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2620609Reviewed-by: default avatarWenbin Zhang <wenbinzhang@google.com>
Commit-Queue: Wenbin Zhang <wenbinzhang@google.com>
Cr-Commit-Position: refs/heads/master@{#841924}
parent 9da1d76d
......@@ -578,10 +578,6 @@ void ChromeMainDelegate::PostEarlyInitialization(bool is_running_tests) {
#if defined(OS_ANDROID)
UmaSessionStats::OnStartup();
#endif
#if defined(OS_MAC)
chrome::CacheChannelInfo();
#endif
}
bool ChromeMainDelegate::ShouldCreateFeatureList() {
......
......@@ -42,12 +42,6 @@ std::string GetChannelName();
version_info::Channel GetChannel();
#if defined(OS_MAC)
// Because the channel information on the Mac is baked into the Info.plist file,
// and that file may change during an update, this function must be called
// early in startup to cache the channel info so that the correct channel info
// can be returned later.
void CacheChannelInfo();
// Maps the name of the channel to version_info::Channel, always returning
// Channel::UNKNOWN for unbranded builds. For branded builds defaults to
// Channel::STABLE, if channel is empty, else matches the name and returns
......
......@@ -7,19 +7,14 @@
#import <Foundation/Foundation.h>
#include "base/mac/bundle_locations.h"
#include "base/macros.h"
#include "base/no_destructor.h"
#include "base/strings/sys_string_conversions.h"
#include "build/branding_buildflags.h"
#include "components/version_info/version_info.h"
namespace chrome {
namespace {
std::string ChannelName() {
std::string GetChannelName() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
static const base::NoDestructor<std::string> channel([] {
// Use the main Chrome application bundle and not the framework bundle.
// Keystone keys don't live in the framework.
NSBundle* bundle = base::mac::OuterBundle();
......@@ -47,23 +42,34 @@ std::string ChannelName() {
channel = [channel substringFromIndex:[@"universal-" length]];
if ([channel isEqual:@"beta"] || [channel isEqual:@"dev"] ||
[channel isEqual:@"canary"]) {
// Do nothing.
// do nothing.
} else {
channel = @"unknown";
}
}
return base::SysNSStringToUTF8(channel);
}());
return *channel;
#else
return std::string();
#endif
}
bool SideBySideCapable() {
version_info::Channel GetChannelByName(const std::string& channel) {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
if (channel.empty())
return version_info::Channel::STABLE;
if (channel == "beta")
return version_info::Channel::BETA;
if (channel == "dev")
return version_info::Channel::DEV;
if (channel == "canary")
return version_info::Channel::CANARY;
#endif
return version_info::Channel::UNKNOWN;
}
bool IsSideBySideCapable() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
static const base::NoDestructor<bool> capable([] {
// Use the main Chrome application bundle and not the framework bundle.
// Keystone keys don't live in the framework.
NSBundle* bundle = base::mac::OuterBundle();
......@@ -84,44 +90,13 @@ bool SideBySideCapable() {
// beta/dev/canary Chrome is separate, and it can run side-by-side to the
// stable Chrome.
return [bundle objectForInfoDictionaryKey:@"CrProductDirName"];
}());
return *capable;
#else
return true;
#endif
}
} // namespace
void CacheChannelInfo() {
ignore_result(ChannelName());
ignore_result(SideBySideCapable());
}
std::string GetChannelName() {
return ChannelName();
}
version_info::Channel GetChannelByName(const std::string& channel) {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
if (channel.empty())
return version_info::Channel::STABLE;
if (channel == "beta")
return version_info::Channel::BETA;
if (channel == "dev")
return version_info::Channel::DEV;
if (channel == "canary")
return version_info::Channel::CANARY;
#endif
return version_info::Channel::UNKNOWN;
}
bool IsSideBySideCapable() {
return SideBySideCapable();
}
version_info::Channel GetChannel() {
return GetChannelByName(ChannelName());
return GetChannelByName(GetChannelName());
}
} // namespace chrome
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment