base::AmIBundled from base/mac_util behaves trickily for binaries like browser_tests, which at the beginning are "normal", not-bundled libraries, but then load the Chrome bundle.
We use base::AmIBundled in base/base_paths_mac. With the current caching in PathService all works fine, but this is by accident. When we turn off or modify caching, we start getting wrong values for DIR_SOURCE_ROOT, because the code thinks it is bundled (AmIBundled returns true), but the right path is for the unbundled binary.
Any suggestions how to fix this trickyness? The rationale is that things should return same results when the caching is off.
Here's a more detailed description:
1. Start browser_tests. AmIBundled returns false. DIR_SOURCE_ROOT is based on the un-bundled path, and is correct.
2. Load the Chrome bundle. AmIBundled will start returning true, but all is fine because DIR_SOURCE_ROOT is cached by PathService.
Now when we turn off the cache (what actually happens is that my patch - now reverted - drops the PathService cache when PathService::Override is called), in step 2. we're going to start getting a broken path for DIR_SOURCE_ROOT.