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

Unified Diff: base/mac_util.mm

Issue 4947002: Mac: Let browser_tests run in bundled mode for their whole lifetime. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: test Created 10 years, 1 month 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 | « base/mac_util.h ('k') | chrome/common/pepper_plugin_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac_util.mm
diff --git a/base/mac_util.mm b/base/mac_util.mm
index 4e6b1054a5e4c1cda3d3ccc1e94e5e60e148eecf..9610d37d4282ed45408776e731280fcc77d1b5b2 100644
--- a/base/mac_util.mm
+++ b/base/mac_util.mm
@@ -145,8 +145,14 @@ bool FSRefFromPath(const std::string& path, FSRef* ref) {
return status == noErr;
}
+static bool g_override_am_i_bundled = false;
+static bool g_override_am_i_bundled_value = false;
+
// Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled
-bool AmIBundled() {
+static bool UncachedAmIBundled() {
+ if (g_override_am_i_bundled)
+ return g_override_am_i_bundled_value;
+
ProcessSerialNumber psn = {0, kCurrentProcess};
FSRef fsref;
@@ -167,6 +173,23 @@ bool AmIBundled() {
return info.nodeFlags & kFSNodeIsDirectoryMask;
}
+bool AmIBundled() {
+ // If the return value is not cached, this function will return different
+ // values depending on when it's called. This confuses some client code, see
+ // http://crbug.com/63183 .
+ static bool result = UncachedAmIBundled();
+ DCHECK_EQ(result, UncachedAmIBundled())
+ << "The return value of AmIBundled() changed. This will confuse tests. "
+ << "Call SetAmIBundled() override manually if your test binary "
+ << "delay-loads the framework.";
+ return result;
+}
+
+void SetOverrideAmIBundled(bool value) {
+ g_override_am_i_bundled = true;
+ g_override_am_i_bundled_value = value;
+}
+
bool IsBackgroundOnlyProcess() {
// This function really does want to examine NSBundle's idea of the main
// bundle dictionary, and not the overriden MainAppBundle. It needs to look
« no previous file with comments | « base/mac_util.h ('k') | chrome/common/pepper_plugin_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698