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

Unified Diff: base/mac/foundation_util.mm

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « base/mac/foundation_util.h ('k') | base/mac/libdispatch_task_runner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/foundation_util.mm
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index 4e9b2248874c33959e40cceb0157099c6759b522..2895b66381259f727928798ac6f34fd4b90b8253 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -26,6 +26,8 @@ namespace mac {
namespace {
+bool g_cached_am_i_bundled_called = false;
+bool g_cached_am_i_bundled_value = false;
bool g_override_am_i_bundled = false;
bool g_override_am_i_bundled_value = false;
@@ -48,12 +50,15 @@ 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())
+ if (!g_cached_am_i_bundled_called) {
+ g_cached_am_i_bundled_called = true;
+ g_cached_am_i_bundled_value = UncachedAmIBundled();
+ }
+ DCHECK_EQ(g_cached_am_i_bundled_value, 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;
+ return g_cached_am_i_bundled_value;
}
void SetOverrideAmIBundled(bool value) {
@@ -66,6 +71,10 @@ void SetOverrideAmIBundled(bool value) {
g_override_am_i_bundled_value = value;
}
+BASE_EXPORT void ClearAmIBundledCache() {
+ g_cached_am_i_bundled_called = false;
+}
+
bool IsBackgroundOnlyProcess() {
// This function really does want to examine NSBundle's idea of the main
// bundle dictionary. It needs to look at the actual running .app's
« no previous file with comments | « base/mac/foundation_util.h ('k') | base/mac/libdispatch_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698