Remove some ScopedNSAutoreleasePool usage.
This touches a lot of ancient code that trips the presubmit, so skip the presubmit. BUG=772489 Change-Id: Ifea8ca3bd1ebb92eaa47421a6000ae70a25fe3e5 No-Presubmit: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783211 Commit-Queue: Avi Drissman <avi@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org> Reviewed-by: Yuwei Huang <yuweih@chromium.org> Reviewed-by: Miguel Casas <mcasas@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#694364}
This commit is contained in:
base
ios
mac
bind_objc_block_unittest.mmfoundation_util_unittest.mmobjc_release_properties_unittest.mmscoped_nsautorelease_pool.hscoped_nsobject.hscoped_nsobject_unittest.mm
system
test
chrome
app
app_shim
browser
common
test
tools
build
components
content
browser
renderer_host
common
printing
remoting
rlz/mac/lib
services
ui
base
test
views
controls
test
widget
@@ -5,7 +5,6 @@
|
||||
#import "base/ios/crb_protocol_observers.h"
|
||||
#include "base/ios/weak_nsobject.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "testing/gtest_mac.h"
|
||||
@@ -122,11 +121,10 @@ TEST_F(CRBProtocolObserversTest, WeakReference) {
|
||||
|
||||
[observers_ addObserver:partial_observer_];
|
||||
|
||||
{
|
||||
// Need an autorelease pool here, because
|
||||
// -[CRBProtocolObservers forwardInvocation:] creates a temporary
|
||||
// autoreleased array that holds all the observers.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
[observers_ requiredMethod];
|
||||
EXPECT_TRUE([partial_observer_ requiredMethodInvoked]);
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "base/ios/weak_nsobject.h"
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
|
||||
namespace {
|
||||
@@ -34,9 +33,9 @@ WeakContainer::~WeakContainer() {}
|
||||
+ (scoped_refptr<base::WeakContainer>)containerForObject:(id)object {
|
||||
if (object == nil)
|
||||
return nullptr;
|
||||
// The autoreleasePool is needed here as the call to objc_getAssociatedObject
|
||||
// The autoreleasepool is needed here as the call to objc_getAssociatedObject
|
||||
// returns an autoreleased object which is better released sooner than later.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
CRBWeakNSProtocolSentinel* sentinel =
|
||||
objc_getAssociatedObject(object, &sentinelObserverKey_);
|
||||
if (!sentinel) {
|
||||
@@ -51,6 +50,7 @@ WeakContainer::~WeakContainer() {}
|
||||
DCHECK_EQ(2u, [sentinel retainCount]);
|
||||
}
|
||||
return [sentinel container];
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithContainer:(scoped_refptr<base::WeakContainer>)container {
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/callback_helpers.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "build/build_config.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "testing/gtest_mac.h"
|
||||
@@ -108,8 +107,7 @@ TEST(BindObjcBlockTest, TestSixArguments) {
|
||||
TEST(BindObjcBlockTest, TestBlockMoveable) {
|
||||
base::OnceClosure c;
|
||||
__block BOOL invoked_block = NO;
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
@autoreleasepool {
|
||||
c = base::BindOnce(base::RetainBlock(^(std::unique_ptr<BOOL> v) {
|
||||
invoked_block = *v;
|
||||
}),
|
||||
@@ -139,8 +137,7 @@ TEST(BindObjcBlockTest, TestBlockDeallocation) {
|
||||
|
||||
TEST(BindObjcBlockTest, TestBlockReleased) {
|
||||
base::WeakNSObject<NSObject> weak_nsobject;
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
@autoreleasepool {
|
||||
NSObject* nsobject = [[[NSObject alloc] init] autorelease];
|
||||
weak_nsobject.reset(nsobject);
|
||||
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/format_macros.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "build/build_config.h"
|
||||
@@ -162,14 +161,13 @@ TEST(FoundationUtilTest, CFCast) {
|
||||
}
|
||||
|
||||
TEST(FoundationUtilTest, ObjCCast) {
|
||||
ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
id test_array = @[];
|
||||
id test_array_mutable = [NSMutableArray array];
|
||||
id test_data = [NSData data];
|
||||
id test_data_mutable = [NSMutableData dataWithCapacity:10];
|
||||
id test_date = [NSDate date];
|
||||
id test_dict = @{ @"meaning" : @42 };
|
||||
id test_dict = @{@"meaning" : @42};
|
||||
id test_dict_mutable = [NSMutableDictionary dictionaryWithCapacity:10];
|
||||
id test_number = @42;
|
||||
id test_null = [NSNull null];
|
||||
@@ -239,11 +237,9 @@ TEST(FoundationUtilTest, ObjCCast) {
|
||||
|
||||
// ObjCCastStrict: correct cast results in correct pointer being returned.
|
||||
EXPECT_EQ(test_array, ObjCCastStrict<NSArray>(test_array));
|
||||
EXPECT_EQ(test_array_mutable,
|
||||
ObjCCastStrict<NSArray>(test_array_mutable));
|
||||
EXPECT_EQ(test_array_mutable, ObjCCastStrict<NSArray>(test_array_mutable));
|
||||
EXPECT_EQ(test_data, ObjCCastStrict<NSData>(test_data));
|
||||
EXPECT_EQ(test_data_mutable,
|
||||
ObjCCastStrict<NSData>(test_data_mutable));
|
||||
EXPECT_EQ(test_data_mutable, ObjCCastStrict<NSData>(test_data_mutable));
|
||||
EXPECT_EQ(test_date, ObjCCastStrict<NSDate>(test_date));
|
||||
EXPECT_EQ(test_dict, ObjCCastStrict<NSDictionary>(test_dict));
|
||||
EXPECT_EQ(test_dict_mutable,
|
||||
@@ -251,13 +247,10 @@ TEST(FoundationUtilTest, ObjCCast) {
|
||||
EXPECT_EQ(test_number, ObjCCastStrict<NSNumber>(test_number));
|
||||
EXPECT_EQ(test_null, ObjCCastStrict<NSNull>(test_null));
|
||||
EXPECT_EQ(test_set, ObjCCastStrict<NSSet>(test_set));
|
||||
EXPECT_EQ(test_set_mutable,
|
||||
ObjCCastStrict<NSSet>(test_set_mutable));
|
||||
EXPECT_EQ(test_set_mutable, ObjCCastStrict<NSSet>(test_set_mutable));
|
||||
EXPECT_EQ(test_str, ObjCCastStrict<NSString>(test_str));
|
||||
EXPECT_EQ(test_str_const,
|
||||
ObjCCastStrict<NSString>(test_str_const));
|
||||
EXPECT_EQ(test_str_mutable,
|
||||
ObjCCastStrict<NSString>(test_str_mutable));
|
||||
EXPECT_EQ(test_str_const, ObjCCastStrict<NSString>(test_str_const));
|
||||
EXPECT_EQ(test_str_mutable, ObjCCastStrict<NSString>(test_str_mutable));
|
||||
|
||||
// ObjCCastStrict: Giving a nil provides a nil.
|
||||
EXPECT_FALSE(ObjCCastStrict<NSArray>(nil));
|
||||
@@ -268,6 +261,7 @@ TEST(FoundationUtilTest, ObjCCast) {
|
||||
EXPECT_FALSE(ObjCCastStrict<NSNumber>(nil));
|
||||
EXPECT_FALSE(ObjCCastStrict<NSSet>(nil));
|
||||
EXPECT_FALSE(ObjCCastStrict<NSString>(nil));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(FoundationUtilTest, GetValueFromDictionary) {
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include "base/mac/objc_release_properties.h"
|
||||
#include "base/stl_util.h"
|
||||
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
@@ -268,9 +267,7 @@ TEST(ObjCReleasePropertiesTest, SesameStreet) {
|
||||
// Make sure that worked before things get more involved.
|
||||
EXPECT_EQ(3, ah_ah_ah);
|
||||
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
test_object.baseCvcRetain = [CountVonCount countVonCount];
|
||||
test_object.baseCvcCopy = [CountVonCount countVonCount];
|
||||
test_object.baseCvcAssign = baseAssign;
|
||||
@@ -324,9 +321,7 @@ TEST(ObjCReleasePropertiesTest, SesameStreet) {
|
||||
// readonly.
|
||||
EXPECT_EQ(6, ah_ah_ah);
|
||||
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
// Put things back to how they were.
|
||||
test_object.baseCvcRetain = [CountVonCount countVonCount];
|
||||
test_object.baseCvcCopy = [CountVonCount countVonCount];
|
||||
|
@@ -21,6 +21,8 @@ namespace mac {
|
||||
// sends it a -drain message when destroyed. This allows an autorelease pool to
|
||||
// be maintained in ordinary C++ code without bringing in any direct Objective-C
|
||||
// dependency.
|
||||
//
|
||||
// Use only in C++ code; use @autoreleasepool in Obj-C(++) code.
|
||||
|
||||
class BASE_EXPORT ScopedNSAutoreleasePool {
|
||||
public:
|
||||
|
@@ -36,11 +36,10 @@ namespace base {
|
||||
// scoped_nsprotocol<> has the same behavior as scoped_nsobject, but can be used
|
||||
// with protocols.
|
||||
//
|
||||
// scoped_nsobject<> is not to be used for NSAutoreleasePools. For
|
||||
// NSAutoreleasePools use ScopedNSAutoreleasePool from
|
||||
// scoped_nsautorelease_pool.h instead.
|
||||
// We check for bad uses of scoped_nsobject and NSAutoreleasePool at compile
|
||||
// time with a template specialization (see below).
|
||||
// scoped_nsobject<> is not to be used for NSAutoreleasePools. For C++ code use
|
||||
// NSAutoreleasePool; for Objective-C(++) code use @autoreleasepool instead. We
|
||||
// check for bad uses of scoped_nsobject and NSAutoreleasePool at compile time
|
||||
// with a template specialization (see below).
|
||||
//
|
||||
// If Automatic Reference Counting (aka ARC) is enabled then the ownership
|
||||
// policy is not controllable by the user as ARC make it really difficult to
|
||||
@@ -187,7 +186,7 @@ class scoped_nsobject : public scoped_nsprotocol<NST*> {
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
static_assert(std::is_same<NST, NSAutoreleasePool>::value == false,
|
||||
"Use ScopedNSAutoreleasePool instead");
|
||||
"Use @autoreleasepool instead");
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@@ -24,8 +23,7 @@ TEST(ScopedNSObjectTest, ScopedNSObject) {
|
||||
base::scoped_nsobject<NSObject> p3 = p1;
|
||||
ASSERT_EQ(p1.get(), p3.get());
|
||||
ASSERT_EQ(2u, [p1 retainCount]);
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
p3 = p1;
|
||||
}
|
||||
ASSERT_EQ(p1.get(), p3.get());
|
||||
@@ -46,8 +44,7 @@ TEST(ScopedNSObjectTest, ScopedNSObject) {
|
||||
|
||||
base::scoped_nsobject<NSObject> p6 = p1;
|
||||
ASSERT_EQ(3u, [p6 retainCount]);
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
p6.autorelease();
|
||||
ASSERT_EQ(nil, p6.get());
|
||||
ASSERT_EQ(3u, [p1 retainCount]);
|
||||
|
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/process/process_metrics.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@@ -43,9 +42,10 @@ std::string SysInfo::OperatingSystemName() {
|
||||
static dispatch_once_t get_system_name_once;
|
||||
static std::string* system_name;
|
||||
dispatch_once(&get_system_name_once, ^{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
system_name = new std::string(
|
||||
SysNSStringToUTF8([[UIDevice currentDevice] systemName]));
|
||||
}
|
||||
});
|
||||
// Examples of returned value: 'iPhone OS' on iPad 5.1.1
|
||||
// and iPhone 5.1.1.
|
||||
@@ -57,9 +57,10 @@ std::string SysInfo::OperatingSystemVersion() {
|
||||
static dispatch_once_t get_system_version_once;
|
||||
static std::string* system_version;
|
||||
dispatch_once(&get_system_version_once, ^{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
system_version = new std::string(
|
||||
SysNSStringToUTF8([[UIDevice currentDevice] systemVersion]));
|
||||
}
|
||||
});
|
||||
return *system_version;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ std::string SysInfo::OperatingSystemVersion() {
|
||||
void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
|
||||
int32_t* minor_version,
|
||||
int32_t* bugfix_version) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
std::string system_version = OperatingSystemVersion();
|
||||
if (!system_version.empty()) {
|
||||
// Try to parse out the version numbers from the string.
|
||||
@@ -81,6 +82,7 @@ void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
|
||||
if (num_read < 3)
|
||||
*bugfix_version = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
// The iOS watchdog timer will kill an app that doesn't spin the main event
|
||||
@@ -22,11 +21,11 @@ class IOSRunLoopListener : public testing::EmptyTestEventListener {
|
||||
};
|
||||
|
||||
void IOSRunLoopListener::OnTestEnd(const testing::TestInfo& test_info) {
|
||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
||||
|
||||
@autoreleasepool {
|
||||
// At the end of the test, spin the default loop for a moment.
|
||||
NSDate* stop_date = [NSDate dateWithTimeIntervalSinceNow:0.001];
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:stop_date];
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "base/debug/debugger.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/message_loop/message_pump.h"
|
||||
#include "base/message_loop/message_pump_default.h"
|
||||
@@ -209,11 +208,12 @@ void RunTestsFromIOSApp() {
|
||||
static bool ran_hook = false;
|
||||
if (!ran_hook) {
|
||||
ran_hook = true;
|
||||
mac::ScopedNSAutoreleasePool pool;
|
||||
int exit_status = UIApplicationMain(g_argc, g_argv, nil,
|
||||
@"ChromeUnitTestDelegate");
|
||||
@autoreleasepool {
|
||||
int exit_status =
|
||||
UIApplicationMain(g_argc, g_argv, nil, @"ChromeUnitTestDelegate");
|
||||
exit(exit_status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "base/logging.h"
|
||||
#import "base/mac/bundle_locations.h"
|
||||
#import "base/mac/foundation_util.h"
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "chrome/common/chrome_constants.h"
|
||||
@@ -20,19 +19,18 @@
|
||||
#include "content/public/common/content_paths.h"
|
||||
|
||||
void SetUpBundleOverrides() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
base::mac::SetOverrideFrameworkBundlePath(chrome::GetFrameworkBundlePath());
|
||||
|
||||
NSBundle* base_bundle = chrome::OuterAppBundle();
|
||||
base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]);
|
||||
|
||||
base::FilePath child_exe_path =
|
||||
chrome::GetFrameworkBundlePath()
|
||||
.Append("Helpers")
|
||||
.Append(chrome::kHelperProcessExecutablePath);
|
||||
chrome::GetFrameworkBundlePath().Append("Helpers").Append(
|
||||
chrome::kHelperProcessExecutablePath);
|
||||
|
||||
// On the Mac, the child executable lives at a predefined location within
|
||||
// the app bundle's versioned directory.
|
||||
base::PathService::Override(content::CHILD_PROCESS_EXE, child_exe_path);
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#import "base/mac/launch_services_util.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@@ -38,8 +37,7 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
||||
using base::mac::CFCastStrict;
|
||||
using base::mac::NSToCFCast;
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
||||
|
||||
@autoreleasepool {
|
||||
// Get the current main bundle, i.e., that of the app loader that's running.
|
||||
NSBundle* app_bundle = [NSBundle mainBundle];
|
||||
CHECK(app_bundle) << "couldn't get loader bundle";
|
||||
@@ -172,8 +170,8 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
app_mode::kLaunchedByChromeProcessId)) {
|
||||
// Pass --app-shim-error to have Chrome rebuild this shim.
|
||||
// If Chrome has rebuilt this shim once already, then rebuilding doesn't fix
|
||||
// the problem, so don't try again.
|
||||
// If Chrome has rebuilt this shim once already, then rebuilding doesn't
|
||||
// fix the problem, so don't try again.
|
||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
app_mode::kLaunchedAfterRebuild)) {
|
||||
command_line.AppendSwitchPath(app_mode::kAppShimError,
|
||||
@@ -182,14 +180,15 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
||||
} else {
|
||||
// If the shim was launched directly (instead of by Chrome), first ask
|
||||
// Chrome to launch the app. Chrome will launch the shim again, the same
|
||||
// error will occur and be handled above. This approach allows the app to be
|
||||
// started without blocking on fixing the shim and guarantees that the
|
||||
// error will occur and be handled above. This approach allows the app to
|
||||
// be started without blocking on fixing the shim and guarantees that the
|
||||
// profile is loaded when Chrome receives --app-shim-error.
|
||||
command_line.AppendSwitchPath(switches::kProfileDirectory, profile_dir);
|
||||
command_line.AppendSwitchASCII(switches::kAppId, app_mode_id);
|
||||
}
|
||||
// Launch the executable directly since base::mac::OpenApplicationWithPath
|
||||
// doesn't pass command line arguments if the application is already running.
|
||||
// doesn't pass command line arguments if the application is already
|
||||
// running.
|
||||
if (!base::LaunchProcess(command_line, base::LaunchOptions()).IsValid()) {
|
||||
LOG(ERROR) << "Could not launch Chrome: "
|
||||
<< command_line.GetCommandLineString();
|
||||
@@ -197,6 +196,7 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/mac_logging.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_pump_type.h"
|
||||
#include "base/run_loop.h"
|
||||
@@ -73,7 +72,7 @@ void PostRepeatingDelayedTask() {
|
||||
int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
||||
base::CommandLine::Init(info->argc, info->argv);
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
||||
@autoreleasepool {
|
||||
base::AtExitManager exit_manager;
|
||||
chrome::RegisterPathProvider();
|
||||
|
||||
@@ -86,11 +85,11 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
||||
ChromeCrashReporterClient::Create();
|
||||
crash_reporter::InitializeCrashpad(true, "app_shim");
|
||||
|
||||
// Calculate the preferred locale used by Chrome.
|
||||
// We can't use l10n_util::OverrideLocaleWithCocoaLocale() because it calls
|
||||
// [base::mac::OuterBundle() preferredLocalizations] which gets localizations
|
||||
// from the bundle of the running app (i.e. it is equivalent to
|
||||
// [[NSBundle mainBundle] preferredLocalizations]) instead of the target
|
||||
// Calculate the preferred locale used by Chrome. We can't use
|
||||
// l10n_util::OverrideLocaleWithCocoaLocale() because it calls
|
||||
// [base::mac::OuterBundle() preferredLocalizations] which gets
|
||||
// localizations from the bundle of the running app (i.e. it is equivalent
|
||||
// to [[NSBundle mainBundle] preferredLocalizations]) instead of the target
|
||||
// bundle.
|
||||
NSArray* preferred_languages = [NSLocale preferredLanguages];
|
||||
NSArray* supported_languages = [base::mac::OuterBundle() localizations];
|
||||
@@ -125,7 +124,7 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
||||
// Launch the IO thread.
|
||||
base::Thread::Options io_thread_options;
|
||||
io_thread_options.message_pump_type = base::MessagePumpType::IO;
|
||||
base::Thread *io_thread = new base::Thread("CrAppShimIO");
|
||||
base::Thread* io_thread = new base::Thread("CrAppShimIO");
|
||||
io_thread->StartWithOptions(io_thread_options);
|
||||
|
||||
mojo::core::Init();
|
||||
@@ -138,7 +137,8 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
||||
[AppShimApplication sharedApplication];
|
||||
CHECK([NSApp isKindOfClass:[AppShimApplication class]]);
|
||||
|
||||
base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
|
||||
base::SingleThreadTaskExecutor main_task_executor(
|
||||
base::MessagePumpType::UI);
|
||||
ui::WindowResizeHelperMac::Get()->Init(main_task_executor.task_runner());
|
||||
base::PlatformThread::SetName("CrAppShimMain");
|
||||
|
||||
@@ -163,4 +163,5 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
||||
AppShimController controller(controller_params);
|
||||
base::RunLoop().Run();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@
|
||||
#include "base/mac/scoped_authorizationref.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_ioobject.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/sdk_forward_declarations.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/stl_util.h"
|
||||
@@ -407,18 +406,15 @@ DiskImageStatus IsAppRunningFromReadOnlyDiskImage(
|
||||
}
|
||||
|
||||
bool MaybeInstallFromDiskImage() {
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
|
||||
@autoreleasepool {
|
||||
std::string dmg_bsd_device_name;
|
||||
if (IsAppRunningFromReadOnlyDiskImage(&dmg_bsd_device_name) !=
|
||||
DiskImageStatusTrue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NSArray* application_directories =
|
||||
NSSearchPathForDirectoriesInDomains(NSApplicationDirectory,
|
||||
NSLocalDomainMask,
|
||||
YES);
|
||||
NSArray* application_directories = NSSearchPathForDirectoriesInDomains(
|
||||
NSApplicationDirectory, NSLocalDomainMask, YES);
|
||||
if ([application_directories count] == 0) {
|
||||
LOG(ERROR) << "NSSearchPathForDirectoriesInDomains: "
|
||||
<< "no local application directories";
|
||||
@@ -464,10 +460,8 @@ bool MaybeInstallFromDiskImage() {
|
||||
// authentication fails. In either case, try to install without privilege
|
||||
// escalation.
|
||||
|
||||
if (!InstallFromDiskImage(authorization.release(),
|
||||
installer_path,
|
||||
source_path,
|
||||
target_path)) {
|
||||
if (!InstallFromDiskImage(authorization.release(), installer_path,
|
||||
source_path, target_path)) {
|
||||
ShowErrorDialog();
|
||||
return false;
|
||||
}
|
||||
@@ -485,6 +479,7 @@ bool MaybeInstallFromDiskImage() {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/mac_logging.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@@ -111,9 +110,10 @@ class PerformBridge : public base::RefCountedThreadSafe<PerformBridge> {
|
||||
|
||||
// Happens on a WorkerPool thread.
|
||||
void Run() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
[target_ performSelector:sel_ withObject:arg_];
|
||||
}
|
||||
}
|
||||
|
||||
base::scoped_nsobject<id> target_;
|
||||
SEL sel_;
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include "base/files/scoped_file.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/mac_logging.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
@@ -266,8 +265,7 @@ void RelauncherSynchronizeWithParent() {
|
||||
namespace internal {
|
||||
|
||||
int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
// CommandLine rearranges the order of the arguments returned by
|
||||
// main_parameters.argv(), rendering it impossible to determine which
|
||||
// arguments originally came before kRelauncherArgSeparator and which came
|
||||
@@ -346,7 +344,6 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
relaunch_executable.assign(arg);
|
||||
seen_relaunch_executable = true;
|
||||
} else {
|
||||
|
||||
NSString* arg_string = base::SysUTF8ToNSString(arg);
|
||||
if (!arg_string) {
|
||||
LOG(ERROR) << "base::SysUTF8ToNSString failed for " << arg;
|
||||
@@ -362,7 +359,8 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// If an update is staged but not yet installed, wait for it to be installed.
|
||||
// If an update is staged but not yet installed, wait for it to be
|
||||
// installed.
|
||||
if (wait_for_staged_update) {
|
||||
base::scoped_nsobject<CrStagingKeyWatcher> watcher(
|
||||
[[CrStagingKeyWatcher alloc] initWithPollingTime:0.5]);
|
||||
@@ -374,7 +372,7 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
NSDictionary* configuration =
|
||||
@{NSWorkspaceLaunchConfigurationArguments : (relaunch_args.get())};
|
||||
|
||||
NSRunningApplication *application = [[NSWorkspace sharedWorkspace]
|
||||
NSRunningApplication* application = [[NSWorkspace sharedWorkspace]
|
||||
launchApplicationAtURL:url
|
||||
options:NSWorkspaceLaunchDefault |
|
||||
NSWorkspaceLaunchWithErrorPresentation |
|
||||
@@ -397,6 +395,7 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include "base/base_paths.h"
|
||||
#include "base/logging.h"
|
||||
#import "base/mac/foundation_util.h"
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/memory/free_deleter.h"
|
||||
#include "base/path_service.h"
|
||||
#include "build/build_config.h"
|
||||
@@ -24,8 +23,7 @@ namespace {
|
||||
// implementation of chrome::OuterAppBundle(), which should be the only
|
||||
// caller.
|
||||
NSBundle* OuterAppBundleInternal() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
if (!base::mac::AmIBundled()) {
|
||||
// If unbundled (as in a test), there's no app bundle.
|
||||
return nil;
|
||||
@@ -42,14 +40,16 @@ NSBundle* OuterAppBundleInternal() {
|
||||
base::FilePath outer_app_dir =
|
||||
framework_path.DirName().DirName().DirName().DirName().DirName();
|
||||
const char* outer_app_dir_c = outer_app_dir.value().c_str();
|
||||
NSString* outer_app_dir_ns = [NSString stringWithUTF8String:outer_app_dir_c];
|
||||
NSString* outer_app_dir_ns =
|
||||
[NSString stringWithUTF8String:outer_app_dir_c];
|
||||
|
||||
return [[NSBundle bundleWithPath:outer_app_dir_ns] retain];
|
||||
}
|
||||
}
|
||||
|
||||
char* ProductDirNameForBundle(NSBundle* chrome_bundle) {
|
||||
@autoreleasepool {
|
||||
const char* product_dir_name = NULL;
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
NSString* product_dir_name_ns =
|
||||
[chrome_bundle objectForInfoDictionaryKey:@"CrProductDirName"];
|
||||
@@ -66,6 +66,7 @@ char* ProductDirNameForBundle(NSBundle* chrome_bundle) {
|
||||
// Leaked, but the only caller initializes a static with this result, so it
|
||||
// only happens once, and that's OK.
|
||||
return strdup(product_dir_name);
|
||||
}
|
||||
}
|
||||
|
||||
// ProductDirName returns the name of the directory inside
|
||||
|
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@@ -100,7 +99,7 @@ bool Launchd::RestartJob(Domain domain,
|
||||
Type type,
|
||||
CFStringRef name,
|
||||
CFStringRef cf_session_type) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
NSURL* url = GetPlistURL(domain, type, name);
|
||||
NSString* ns_path = [url path];
|
||||
ns_path = SanitizeShellArgument(ns_path);
|
||||
@@ -116,8 +115,8 @@ bool Launchd::RestartJob(Domain domain,
|
||||
argv.push_back("/bin/bash");
|
||||
argv.push_back("--noprofile");
|
||||
argv.push_back("-c");
|
||||
std::string command = base::StringPrintf(
|
||||
"/bin/launchctl unload -S %s %s;"
|
||||
std::string command =
|
||||
base::StringPrintf("/bin/launchctl unload -S %s %s;"
|
||||
"/bin/launchctl load -S %s %s;",
|
||||
[ns_session_type UTF8String], file_path,
|
||||
[ns_session_type UTF8String], file_path);
|
||||
@@ -126,29 +125,32 @@ bool Launchd::RestartJob(Domain domain,
|
||||
base::LaunchOptions options;
|
||||
options.new_process_group = true;
|
||||
return base::LaunchProcess(argv, options).IsValid();
|
||||
}
|
||||
}
|
||||
|
||||
CFMutableDictionaryRef Launchd::CreatePlistFromFile(Domain domain,
|
||||
Type type,
|
||||
CFStringRef name) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
NSURL* ns_url = GetPlistURL(domain, type, name);
|
||||
NSMutableDictionary* plist =
|
||||
[[NSMutableDictionary alloc] initWithContentsOfURL:ns_url];
|
||||
return base::mac::NSToCFCast(plist);
|
||||
}
|
||||
}
|
||||
|
||||
bool Launchd::WritePlistToFile(Domain domain,
|
||||
Type type,
|
||||
CFStringRef name,
|
||||
CFDictionaryRef dict) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
NSURL* ns_url = GetPlistURL(domain, type, name);
|
||||
return [base::mac::CFToNSCast(dict) writeToURL:ns_url atomically:YES];
|
||||
}
|
||||
}
|
||||
|
||||
bool Launchd::DeletePlist(Domain domain, Type type, CFStringRef name) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
NSURL* ns_url = GetPlistURL(domain, type, name);
|
||||
NSError* err = nil;
|
||||
if (![[NSFileManager defaultManager] removeItemAtPath:[ns_url path]
|
||||
@@ -159,4 +161,5 @@ bool Launchd::DeletePlist(Domain domain, Type type, CFStringRef name) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/path_service.h"
|
||||
@@ -37,10 +36,11 @@ namespace {
|
||||
#define kServiceProcessSessionType "Aqua"
|
||||
|
||||
CFStringRef CopyServiceProcessLaunchDName() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
NSBundle* bundle = base::mac::FrameworkBundle();
|
||||
return CFStringCreateCopy(kCFAllocatorDefault,
|
||||
base::mac::NSToCFCast([bundle bundleIdentifier]));
|
||||
}
|
||||
}
|
||||
|
||||
NSString* GetServiceProcessLaunchDLabel() {
|
||||
@@ -105,8 +105,9 @@ bool ForceServiceProcessShutdown(const std::string& /* version */,
|
||||
|
||||
bool ServiceProcessState::GetServiceProcessData(std::string* version,
|
||||
base::ProcessId* pid) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
std::string label = base::SysNSStringToUTF8(GetServiceProcessLaunchDLabel());
|
||||
@autoreleasepool {
|
||||
std::string label =
|
||||
base::SysNSStringToUTF8(GetServiceProcessLaunchDLabel());
|
||||
mac::services::JobInfo info;
|
||||
if (!Launchd::GetInstance()->GetJobInfo(label, &info))
|
||||
return false;
|
||||
@@ -143,6 +144,7 @@ bool ServiceProcessState::GetServiceProcessData(std::string* version,
|
||||
*pid = info.pid ? *info.pid : -1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ServiceProcessState::Initialize() {
|
||||
@@ -211,17 +213,14 @@ mac::services::JobOptions GetServiceProcessJobOptions(
|
||||
|
||||
CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
|
||||
bool for_auto_launch) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
NSString* program =
|
||||
base::SysUTF8ToNSString(cmd_line->GetProgram().value());
|
||||
@autoreleasepool {
|
||||
NSString* program = base::SysUTF8ToNSString(cmd_line->GetProgram().value());
|
||||
|
||||
std::vector<std::string> args = cmd_line->argv();
|
||||
NSMutableArray* ns_args = [NSMutableArray arrayWithCapacity:args.size()];
|
||||
|
||||
for (std::vector<std::string>::iterator iter = args.begin();
|
||||
iter < args.end();
|
||||
++iter) {
|
||||
iter < args.end(); ++iter) {
|
||||
[ns_args addObject:base::SysUTF8ToNSString(*iter)];
|
||||
}
|
||||
|
||||
@@ -239,7 +238,7 @@ CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
|
||||
// relaunch the service automatically in any other case than exiting
|
||||
// cleanly with a 0 return code.
|
||||
NSDictionary* keep_alive =
|
||||
@{ @LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT : @NO };
|
||||
@{@LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT : @NO};
|
||||
NSDictionary* auto_launchd_plist = @{
|
||||
@LAUNCH_JOBKEY_RUNATLOAD : @YES,
|
||||
@LAUNCH_JOBKEY_KEEPALIVE : keep_alive,
|
||||
@@ -248,6 +247,7 @@ CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
|
||||
[launchd_plist addEntriesFromDictionary:auto_launchd_plist];
|
||||
}
|
||||
return reinterpret_cast<CFDictionaryRef>(launchd_plist);
|
||||
}
|
||||
}
|
||||
|
||||
// Writes the launchd property list into the user's LaunchAgents directory,
|
||||
@@ -272,8 +272,7 @@ bool ServiceProcessState::RemoveFromAutoRun() {
|
||||
}
|
||||
|
||||
bool ServiceProcessState::StateData::WatchExecutable() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
base::FilePath executable_path = base::FilePath(job_info.program);
|
||||
std::unique_ptr<ExecFilePathWatcherCallback> callback(
|
||||
new ExecFilePathWatcherCallback);
|
||||
@@ -282,14 +281,14 @@ bool ServiceProcessState::StateData::WatchExecutable() {
|
||||
return false;
|
||||
}
|
||||
if (!executable_watcher.Watch(
|
||||
executable_path,
|
||||
false,
|
||||
executable_path, false,
|
||||
base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged,
|
||||
base::Owned(callback.release())))) {
|
||||
DLOG(ERROR) << "executable_watcher.watch " << executable_path.value();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ExecFilePathWatcherCallback::Init(const base::FilePath& path) {
|
||||
@@ -306,7 +305,7 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
||||
return;
|
||||
}
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
bool needs_shutdown = false;
|
||||
bool needs_restart = false;
|
||||
bool good_bundle = false;
|
||||
@@ -315,8 +314,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
||||
NSURL* bundle_url = [[[executable_fsref_ URLByDeletingLastPathComponent]
|
||||
URLByDeletingLastPathComponent] URLByDeletingLastPathComponent];
|
||||
if (bundle_url) {
|
||||
base::ScopedCFTypeRef<CFBundleRef> bundle(
|
||||
CFBundleCreate(kCFAllocatorDefault, base::mac::NSToCFCast(bundle_url)));
|
||||
base::ScopedCFTypeRef<CFBundleRef> bundle(CFBundleCreate(
|
||||
kCFAllocatorDefault, base::mac::NSToCFCast(bundle_url)));
|
||||
good_bundle = CFBundleGetIdentifier(bundle) != NULL;
|
||||
}
|
||||
|
||||
@@ -355,8 +354,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
||||
base::ScopedCFTypeRef<CFStringRef> name(CopyServiceProcessLaunchDName());
|
||||
if (needs_restart) {
|
||||
base::ScopedCFTypeRef<CFMutableDictionaryRef> plist(
|
||||
Launchd::GetInstance()->CreatePlistFromFile(
|
||||
Launchd::User, Launchd::Agent, name));
|
||||
Launchd::GetInstance()->CreatePlistFromFile(Launchd::User,
|
||||
Launchd::Agent, name));
|
||||
if (plist.get()) {
|
||||
NSMutableDictionary* ns_plist = base::mac::CFToNSCast(plist);
|
||||
NSURL* new_path = [executable_fsref_ filePathURL];
|
||||
@@ -367,10 +366,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
||||
[ns_plist[@LAUNCH_JOBKEY_PROGRAMARGUMENTS] mutableCopy]);
|
||||
args[0] = ns_new_path;
|
||||
ns_plist[@LAUNCH_JOBKEY_PROGRAMARGUMENTS] = args;
|
||||
if (!Launchd::GetInstance()->WritePlistToFile(Launchd::User,
|
||||
Launchd::Agent,
|
||||
name,
|
||||
plist)) {
|
||||
if (!Launchd::GetInstance()->WritePlistToFile(
|
||||
Launchd::User, Launchd::Agent, name, plist)) {
|
||||
DLOG(ERROR) << "Unable to rewrite plist.";
|
||||
needs_shutdown = true;
|
||||
}
|
||||
@@ -388,10 +385,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
||||
// Then deal with the process.
|
||||
CFStringRef session_type = CFSTR(kServiceProcessSessionType);
|
||||
if (needs_restart) {
|
||||
if (!Launchd::GetInstance()->RestartJob(Launchd::User,
|
||||
Launchd::Agent,
|
||||
name,
|
||||
session_type)) {
|
||||
if (!Launchd::GetInstance()->RestartJob(Launchd::User, Launchd::Agent,
|
||||
name, session_type)) {
|
||||
DLOG(ERROR) << "RestartLaunchdJob";
|
||||
needs_shutdown = true;
|
||||
}
|
||||
@@ -406,4 +401,5 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "chrome/test/base/in_process_browser_test.h"
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "chrome/browser/devtools/devtools_window.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
@@ -18,19 +17,18 @@ void InProcessBrowserTest::OpenDevToolsWindow(
|
||||
content::WebContents* web_contents) {
|
||||
// Opening a Devtools Window can cause AppKit to throw objects into the
|
||||
// autorelease pool. Flush the pool when this function returns.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents));
|
||||
DevToolsWindow::OpenDevToolsWindow(web_contents);
|
||||
ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents));
|
||||
}
|
||||
}
|
||||
|
||||
Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
|
||||
const GURL& url) {
|
||||
// Opening an incognito window can cause AppKit to throw objects into the
|
||||
// autorelease pool. Flush the pool when this function returns.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
chrome::OpenURLOffTheRecord(profile, url);
|
||||
Browser* browser =
|
||||
chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false);
|
||||
@@ -38,6 +36,7 @@ Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
|
||||
browser->tab_strip_model()->GetActiveWebContents());
|
||||
observer.Wait();
|
||||
return browser;
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a browser with a single tab (about:blank), waits for the tab to
|
||||
@@ -45,18 +44,17 @@ Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
|
||||
Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
|
||||
// Making a browser window can cause AppKit to throw objects into the
|
||||
// autorelease pool. Flush the pool when this function returns.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
Browser* browser = new Browser(Browser::CreateParams(profile, true));
|
||||
AddBlankTabAndShow(browser);
|
||||
return browser;
|
||||
}
|
||||
}
|
||||
|
||||
Browser* InProcessBrowserTest::CreateIncognitoBrowser(Profile* profile) {
|
||||
// Making a browser window can cause AppKit to throw objects into the
|
||||
// autorelease pool. Flush the pool when this function returns.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
// Use active profile if default nullptr was passed.
|
||||
if (!profile)
|
||||
profile = browser()->profile();
|
||||
@@ -66,27 +64,28 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser(Profile* profile) {
|
||||
Browser::CreateParams(profile->GetOffTheRecordProfile(), true));
|
||||
AddBlankTabAndShow(incognito);
|
||||
return incognito;
|
||||
}
|
||||
}
|
||||
|
||||
Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) {
|
||||
// Making a browser window can cause AppKit to throw objects into the
|
||||
// autorelease pool. Flush the pool when this function returns.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
Browser* browser =
|
||||
new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile, true));
|
||||
AddBlankTabAndShow(browser);
|
||||
return browser;
|
||||
}
|
||||
}
|
||||
|
||||
Browser* InProcessBrowserTest::CreateBrowserForApp(const std::string& app_name,
|
||||
Profile* profile) {
|
||||
// Making a browser window can cause AppKit to throw objects into the
|
||||
// autorelease pool. Flush the pool when this function returns.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
Browser* browser = new Browser(Browser::CreateParams::CreateForApp(
|
||||
app_name, false /* trusted_source */, gfx::Rect(), profile, true));
|
||||
AddBlankTabAndShow(browser);
|
||||
return browser;
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "base/i18n/message_formatter.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@@ -154,8 +153,7 @@ const char kAppType_Helper[] = "helper"; // Helper app
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* const argv[]) {
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
|
||||
@autoreleasepool {
|
||||
const char* version_file_path = NULL;
|
||||
const char* grit_output_dir = NULL;
|
||||
const char* branding_strings_name = NULL;
|
||||
@@ -338,4 +336,5 @@ int main(int argc, char* const argv[]) {
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -7,24 +7,24 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "components/history/core/test/thumbnail-inl.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
namespace history {
|
||||
|
||||
gfx::Image CreateGoogleThumbnailForTest() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
// -[NSData dataWithBytesNoCopy:length:freeWhenDone:] takes it first parameter
|
||||
// as a void* but does not modify it (API is not const clean) so we need to
|
||||
// use const_cast<> here.
|
||||
NSData* data =
|
||||
[NSData dataWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(
|
||||
kGoogleThumbnail))
|
||||
@autoreleasepool {
|
||||
// -[NSData dataWithBytesNoCopy:length:freeWhenDone:] takes its first
|
||||
// parameter as a void* but does not modify it (API is not const clean) so
|
||||
// we need to use const_cast<> here.
|
||||
NSData* data = [NSData
|
||||
dataWithBytesNoCopy:const_cast<void*>(
|
||||
static_cast<const void*>(kGoogleThumbnail))
|
||||
length:sizeof(kGoogleThumbnail)
|
||||
freeWhenDone:NO];
|
||||
UIImage* image = [UIImage imageWithData:data scale:1];
|
||||
return gfx::Image([image retain]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/version.h"
|
||||
@@ -45,29 +44,28 @@ base::Time GetUpdaterSettingsTime(NSString* value_name) {
|
||||
}
|
||||
|
||||
base::Version GetVersionFromPlist(const base::FilePath& info_plist) {
|
||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
||||
NSData* data =
|
||||
[NSData dataWithContentsOfFile:
|
||||
base::mac::FilePathToNSString(info_plist)];
|
||||
@autoreleasepool {
|
||||
NSData* data = [NSData
|
||||
dataWithContentsOfFile:base::mac::FilePathToNSString(info_plist)];
|
||||
if ([data length] == 0) {
|
||||
return base::Version();
|
||||
}
|
||||
NSDictionary* all_keys = base::mac::ObjCCastStrict<NSDictionary>(
|
||||
[NSPropertyListSerialization propertyListWithData:data
|
||||
NSDictionary* all_keys =
|
||||
base::mac::ObjCCastStrict<NSDictionary>([NSPropertyListSerialization
|
||||
propertyListWithData:data
|
||||
options:NSPropertyListImmutable
|
||||
format:nil
|
||||
error:nil]);
|
||||
if (all_keys == nil) {
|
||||
return base::Version();
|
||||
}
|
||||
CFStringRef version =
|
||||
base::mac::GetValueFromDictionary<CFStringRef>(
|
||||
base::mac::NSToCFCast(all_keys),
|
||||
kCFBundleVersionKey);
|
||||
CFStringRef version = base::mac::GetValueFromDictionary<CFStringRef>(
|
||||
base::mac::NSToCFCast(all_keys), kCFBundleVersionKey);
|
||||
if (version == NULL) {
|
||||
return base::Version();
|
||||
}
|
||||
return base::Version(base::SysCFStringRefToUTF8(version));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "content/browser/renderer_host/input/synthetic_gesture_target_mac.h"
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_input_event_router.h"
|
||||
#import "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h"
|
||||
@@ -88,13 +87,12 @@ void SyntheticGestureTargetMac::DispatchWebGestureEventToPlatform(
|
||||
const ui::LatencyInfo& latency_info) {
|
||||
// Create an autorelease pool so that we clean up any synthetic events we
|
||||
// generate.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
NSPoint content_local = NSMakePoint(
|
||||
web_gesture.PositionInWidget().x,
|
||||
[cocoa_view_ frame].size.height - web_gesture.PositionInWidget().y);
|
||||
NSPoint location_in_window =
|
||||
[cocoa_view_ convertPoint:content_local toView:nil];
|
||||
NSPoint location_in_window = [cocoa_view_ convertPoint:content_local
|
||||
toView:nil];
|
||||
|
||||
switch (web_gesture.GetType()) {
|
||||
case WebInputEvent::kGesturePinchBegin: {
|
||||
@@ -125,6 +123,7 @@ void SyntheticGestureTargetMac::DispatchWebGestureEventToPlatform(
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SyntheticGestureTargetMac::DispatchWebTouchEventToPlatform(
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
@@ -36,18 +35,19 @@ const NSInteger kPepperFontWeightsLength = base::size(kPepperFontWeights);
|
||||
} // namespace
|
||||
|
||||
void GetFontFamilies_SlowBlocking(std::vector<std::string>* font_families) {
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
@autoreleasepool {
|
||||
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
||||
NSArray* fonts = [fontManager availableFontFamilies];
|
||||
font_families->reserve([fonts count]);
|
||||
for (NSString* family_name in fonts)
|
||||
font_families->push_back(base::SysNSStringToUTF8(family_name));
|
||||
}
|
||||
}
|
||||
|
||||
void GetFontsInFamily_SlowBlocking(
|
||||
const std::string& family,
|
||||
std::vector<ppapi::proxy::SerializedTrueTypeFontDesc>* fonts_in_family) {
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
@autoreleasepool {
|
||||
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
||||
NSString* ns_family = base::SysUTF8ToNSString(family);
|
||||
NSArray* ns_fonts_in_family =
|
||||
@@ -78,6 +78,7 @@ void GetFontsInFamily_SlowBlocking(
|
||||
|
||||
fonts_in_family->push_back(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
|
@@ -140,8 +140,7 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperWithTaskEnvTest,
|
||||
supported_factors.push_back(ui::SCALE_FACTOR_100P);
|
||||
ui::test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
int32_t routing_id = process_host->GetNextRoutingID();
|
||||
mojom::WidgetPtr widget;
|
||||
std::unique_ptr<MockWidgetImpl> widget_impl =
|
||||
@@ -153,8 +152,8 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperWithTaskEnvTest,
|
||||
ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get());
|
||||
|
||||
// Owned by its |GetInProcessNSView()|, i.e. |rwhv_cocoa|.
|
||||
RenderWidgetHostViewMac* rwhv_mac = new RenderWidgetHostViewMac(
|
||||
render_widget, false);
|
||||
RenderWidgetHostViewMac* rwhv_mac =
|
||||
new RenderWidgetHostViewMac(render_widget, false);
|
||||
base::scoped_nsobject<RenderWidgetHostViewCocoa> rwhv_cocoa(
|
||||
[rwhv_mac->GetInProcessNSView() retain]);
|
||||
|
||||
@@ -168,16 +167,17 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperWithTaskEnvTest,
|
||||
|
||||
for (NSString* edit_command_name in edit_command_strings) {
|
||||
NSString* sel_str = [edit_command_name stringByAppendingString:@":"];
|
||||
[rwhwvm_owner performSelector:NSSelectorFromString(sel_str) withObject:nil];
|
||||
[rwhwvm_owner performSelector:NSSelectorFromString(sel_str)
|
||||
withObject:nil];
|
||||
}
|
||||
|
||||
size_t num_edit_commands = [edit_command_strings count];
|
||||
EXPECT_EQ(delegate.edit_command_message_count_, num_edit_commands);
|
||||
rwhv_cocoa.reset();
|
||||
pool.Recycle();
|
||||
|
||||
// The |render_widget|'s process needs to be deleted within |message_loop|.
|
||||
delete render_widget;
|
||||
}
|
||||
|
||||
ui::WindowResizeHelperMac::Get()->ShutdownForTests();
|
||||
}
|
||||
|
@@ -8,14 +8,13 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
@autoreleasepool {
|
||||
std::unique_ptr<base::ListValue> font_list(new base::ListValue);
|
||||
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
||||
NSMutableDictionary* fonts_dict = [NSMutableDictionary dictionary];
|
||||
@@ -40,6 +39,7 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
|
||||
}
|
||||
|
||||
return font_list;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@@ -87,13 +86,12 @@ void PrintingContextMac::AskUserForSettings(int max_pages,
|
||||
PrintSettingsCallback callback) {
|
||||
// Exceptions can also happen when the NSPrintPanel is being
|
||||
// deallocated, so it must be autoreleased within this scope.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
DCHECK([NSThread isMainThread]);
|
||||
|
||||
// We deliberately don't feed max_pages into the dialog, because setting
|
||||
// NSPrintLastPage makes the print dialog pre-select the option to only print
|
||||
// a range.
|
||||
// NSPrintLastPage makes the print dialog pre-select the option to only
|
||||
// print a range.
|
||||
|
||||
// TODO(stuartmorgan): implement 'print selection only' (probably requires
|
||||
// adding a new custom view to the panel on 10.5; 10.6 has
|
||||
@@ -124,8 +122,8 @@ void PrintingContextMac::AskUserForSettings(int max_pages,
|
||||
|
||||
// This function may be called in the middle of a CATransaction, where
|
||||
// running a modal panel is forbidden. That situation isn't ideal, but from
|
||||
// this code's POV the right answer is to defer running the panel until after
|
||||
// the current transaction. See https://crbug.com/849538.
|
||||
// this code's POV the right answer is to defer running the panel until
|
||||
// after the current transaction. See https://crbug.com/849538.
|
||||
__block auto block_callback = std::move(callback);
|
||||
[CATransaction setCompletionBlock:^{
|
||||
NSInteger selection = [panel runModalWithPrintInfo:printInfo];
|
||||
@@ -138,6 +136,7 @@ void PrintingContextMac::AskUserForSettings(int max_pages,
|
||||
std::move(block_callback).Run(CANCEL);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Size PrintingContextMac::GetPdfPaperSizeDeviceUnits() {
|
||||
|
@@ -7,22 +7,20 @@
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include "base/logging.h"
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#import "third_party/breakpad/breakpad/src/client/mac/Framework/Breakpad.h"
|
||||
|
||||
namespace remoting {
|
||||
|
||||
void InitializeCrashReporting() {
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
|
||||
@autoreleasepool {
|
||||
NSBundle* main_bundle = [NSBundle mainBundle];
|
||||
|
||||
// Tell Breakpad where crash_inspector and crash_report_sender are.
|
||||
NSString* resource_path = [main_bundle resourcePath];
|
||||
NSString* inspector_location =
|
||||
[resource_path stringByAppendingPathComponent:@"crash_inspector"];
|
||||
NSString* reporter_bundle_location =
|
||||
[resource_path stringByAppendingPathComponent:@"crash_report_sender.app"];
|
||||
NSString* reporter_bundle_location = [resource_path
|
||||
stringByAppendingPathComponent:@"crash_report_sender.app"];
|
||||
NSString* reporter_location =
|
||||
[[NSBundle bundleWithPath:reporter_bundle_location] executablePath];
|
||||
|
||||
@@ -46,14 +44,12 @@ void InitializeCrashReporting() {
|
||||
// service that shouldn't rely on a console user to dismiss any prompt.
|
||||
// Also, this may be running in the LoginWindow context, where prompting
|
||||
// might not be possible.
|
||||
[breakpad_config setObject:@"YES"
|
||||
forKey:@BREAKPAD_SKIP_CONFIRM];
|
||||
[breakpad_config setObject:@"YES" forKey:@BREAKPAD_SKIP_CONFIRM];
|
||||
}
|
||||
if (![breakpad_config objectForKey:@BREAKPAD_REPORT_INTERVAL]) {
|
||||
// Set a minimum 6-hour interval between crash-reports, to match the
|
||||
// throttling used on Windows.
|
||||
[breakpad_config setObject:@"21600"
|
||||
forKey:@BREAKPAD_REPORT_INTERVAL];
|
||||
[breakpad_config setObject:@"21600" forKey:@BREAKPAD_REPORT_INTERVAL];
|
||||
}
|
||||
if (![breakpad_config objectForKey:@BREAKPAD_URL]) {
|
||||
[breakpad_config setObject:@"https://clients2.google.com/cr/report"
|
||||
@@ -63,6 +59,7 @@ void InitializeCrashReporting() {
|
||||
if (!BreakpadCreate(breakpad_config)) {
|
||||
LOG(ERROR) << "Breakpad initialization failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace remoting
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@@ -62,17 +61,19 @@ ContinueWindowMac::~ContinueWindowMac() {
|
||||
void ContinueWindowMac::ShowUi() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
controller_.reset(
|
||||
[[ContinueWindowMacController alloc] initWithWindow:this]);
|
||||
[controller_ show];
|
||||
}
|
||||
}
|
||||
|
||||
void ContinueWindowMac::HideUi() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
[controller_ hide];
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
@@ -14,7 +14,6 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/i18n/message_formatter.h"
|
||||
#include "base/location.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@@ -76,9 +75,10 @@ It2MeConfirmationDialogMac::~It2MeConfirmationDialogMac() {
|
||||
dialog_timer_.Stop();
|
||||
|
||||
if (controller_) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
[controller_ hide];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void It2MeConfirmationDialogMac::Show(const std::string& remote_user_email,
|
||||
@@ -92,21 +92,23 @@ void It2MeConfirmationDialogMac::Show(const std::string& remote_user_email,
|
||||
ResultCallback dialog_action_callback = base::Bind(
|
||||
&It2MeConfirmationDialogMac::OnDialogAction, base::Unretained(this));
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
controller_.reset([[It2MeConfirmationDialogMacController alloc]
|
||||
initWithCallback:dialog_action_callback
|
||||
username:remote_user_email]);
|
||||
[controller_ show];
|
||||
}
|
||||
}
|
||||
|
||||
void It2MeConfirmationDialogMac::OnDialogAction(Result result) {
|
||||
dialog_timer_.Stop();
|
||||
|
||||
if (controller_) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
[controller_ hide];
|
||||
controller_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (result_callback_) {
|
||||
std::move(result_callback_).Run(result);
|
||||
|
@@ -353,15 +353,15 @@ RlzValueStore* ScopedRlzValueStoreLock::GetStore() {
|
||||
namespace testing {
|
||||
|
||||
void SetRlzStoreDirectory(const base::FilePath& directory) {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
||||
@autoreleasepool {
|
||||
[g_test_folder release];
|
||||
if (directory.empty()) {
|
||||
g_test_folder = nil;
|
||||
} else {
|
||||
// Not Unsafe on OS X.
|
||||
g_test_folder =
|
||||
[[NSString alloc] initWithUTF8String:directory.AsUTF8Unsafe().c_str()];
|
||||
g_test_folder = [[NSString alloc]
|
||||
initWithUTF8String:directory.AsUTF8Unsafe().c_str()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
@@ -45,10 +44,10 @@ class CoreWlanApi : public WifiDataProviderCommon::WlanApiInterface {
|
||||
};
|
||||
|
||||
bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
||||
base::mac::ScopedNSAutoreleasePool auto_pool;
|
||||
// Initialize the scan parameters with scan key merging disabled, so we get
|
||||
@autoreleasepool { // Initialize the scan parameters with scan key merging
|
||||
// disabled, so we get
|
||||
// every AP listed in the scan without any SSID de-duping logic.
|
||||
NSDictionary* params = @{ kCWScanKeyMerge : @NO };
|
||||
NSDictionary* params = @{kCWScanKeyMerge : @NO};
|
||||
|
||||
NSSet* supported_interfaces = [CWInterface interfaceNames];
|
||||
NSUInteger interface_error_count = 0;
|
||||
@@ -64,8 +63,8 @@ bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
||||
const base::TimeTicks start_time = base::TimeTicks::Now();
|
||||
|
||||
NSError* err = nil;
|
||||
NSArray* scan =
|
||||
[corewlan_interface scanForNetworksWithParameters:params error:&err];
|
||||
NSArray* scan = [corewlan_interface scanForNetworksWithParameters:params
|
||||
error:&err];
|
||||
const int error_code = [err code];
|
||||
const int count = [scan count];
|
||||
// We could get an error code but count != 0 if the scan was interrupted,
|
||||
@@ -90,13 +89,14 @@ bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
||||
AccessPointData access_point_data;
|
||||
// -[CWNetwork bssid] uses colons to separate the components of the MAC
|
||||
// address, but AccessPointData requires they be separated with a dash.
|
||||
access_point_data.mac_address = base::SysNSStringToUTF16([[network bssid]
|
||||
stringByReplacingOccurrencesOfString:@":"
|
||||
access_point_data.mac_address = base::SysNSStringToUTF16(
|
||||
[[network bssid] stringByReplacingOccurrencesOfString:@":"
|
||||
withString:@"-"]);
|
||||
access_point_data.radio_signal_strength = [network rssiValue];
|
||||
access_point_data.channel = [[network wlanChannel] channelNumber];
|
||||
access_point_data.signal_to_noise =
|
||||
access_point_data.radio_signal_strength - [network noiseMeasurement];
|
||||
access_point_data.radio_signal_strength -
|
||||
[network noiseMeasurement];
|
||||
access_point_data.ssid = base::SysNSStringToUTF16([network ssid]);
|
||||
data->insert(access_point_data);
|
||||
}
|
||||
@@ -110,6 +110,7 @@ bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
||||
// one interface did not fail.
|
||||
return interface_error_count == 0 ||
|
||||
[supported_interfaces count] > interface_error_count;
|
||||
}
|
||||
}
|
||||
|
||||
// The time periods, in milliseconds, between successive polls of the wifi data.
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/mach_port_rendezvous.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/stl_util.h"
|
||||
@@ -83,8 +82,7 @@ const char* SandboxMac::kSandboxBundleVersionPath = "BUNDLE_VERSION_PATH";
|
||||
void SandboxMac::Warmup(SandboxType sandbox_type) {
|
||||
DCHECK_EQ(sandbox_type, SANDBOX_TYPE_GPU);
|
||||
|
||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
||||
|
||||
@autoreleasepool {
|
||||
{ // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6
|
||||
base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace(
|
||||
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
|
||||
@@ -109,7 +107,8 @@ void SandboxMac::Warmup(SandboxType sandbox_type) {
|
||||
localtime(&tv);
|
||||
}
|
||||
|
||||
{ // Gestalt() tries to read /System/Library/CoreServices/SystemVersion.plist
|
||||
{ // Gestalt() tries to read
|
||||
// /System/Library/CoreServices/SystemVersion.plist
|
||||
// on 10.5.6
|
||||
int32_t tmp;
|
||||
base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp);
|
||||
@@ -134,6 +133,7 @@ void SandboxMac::Warmup(SandboxType sandbox_type) {
|
||||
// Needed by zero-copy texture update framework - crbug.com/323338
|
||||
base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load the appropriate template for the given sandbox type.
|
||||
|
@@ -212,8 +212,7 @@ void CocoaTest::TearDown() {
|
||||
([start_date timeIntervalSinceNow] > -kCloseTimeoutSeconds);
|
||||
|
||||
// Autorelease anything thrown up by the event loop.
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
++spins;
|
||||
NSEvent* next_event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||
untilDate:nil
|
||||
@@ -253,12 +252,13 @@ std::set<NSWindow*> CocoaTest::ApplicationWindows() {
|
||||
|
||||
// Must create a pool here because [NSApp windows] has created an array
|
||||
// with retains on all the windows in it.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
NSArray* appWindows = [NSApp windows];
|
||||
for (NSWindow* window in appWindows) {
|
||||
windows.insert(window);
|
||||
}
|
||||
return windows;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<NSWindow*> CocoaTest::WindowsLeft() {
|
||||
|
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#import "base/mac/scoped_nsobject.h"
|
||||
#include "base/macros.h"
|
||||
#import "testing/gtest_mac.h"
|
||||
@@ -220,8 +219,7 @@ TEST_F(NativeViewHostMacTest, NativeViewHidden) {
|
||||
// Check that we can destroy cleanly even if the native view has already been
|
||||
// released.
|
||||
TEST_F(NativeViewHostMacTest, NativeViewReleased) {
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
CreateHost();
|
||||
// In practice the native view is a WebContentsViewCocoa which is retained
|
||||
// by its superview (a TabContentsContainerView) and by WebContentsViewMac.
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/bind.h"
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "ui/base/test/scoped_fake_full_keyboard_access.h"
|
||||
#include "ui/base/test/scoped_fake_nswindow_focus.h"
|
||||
#include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
|
||||
@@ -63,13 +62,14 @@ void ViewsTestHelperMac::TearDown() {
|
||||
// this is handled automatically by views::Widget::CloseAllSecondaryWidgets().
|
||||
// Unit tests on Aura may create Widgets owned by a RootWindow that gets torn
|
||||
// down, but on Mac we need to be more explicit.
|
||||
base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released.
|
||||
@autoreleasepool {
|
||||
NSArray* native_windows = [NSApp windows];
|
||||
for (NSWindow* window : native_windows)
|
||||
DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed.";
|
||||
|
||||
ui::test::EventGeneratorDelegate::SetFactoryFunction(
|
||||
ui::test::EventGeneratorDelegate::FactoryFunction());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace views
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "base/callback.h"
|
||||
#import "base/mac/foundation_util.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
||||
#import "base/mac/scoped_nsobject.h"
|
||||
#import "base/mac/scoped_objc_class_swizzler.h"
|
||||
#include "base/macros.h"
|
||||
@@ -817,10 +816,9 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
|
||||
TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
||||
NativeWidgetMacTestWindow* last_window = nil;
|
||||
bool window_deallocated = false;
|
||||
{
|
||||
@autoreleasepool {
|
||||
// First verify the behavior of CloseAllSecondaryWidgets in the normal case,
|
||||
// and how [NSApp windows] changes in response to Widget closure.
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
Widget* widget = CreateWidgetWithTestWindow(
|
||||
Widget::InitParams(Widget::InitParams::TYPE_WINDOW), &last_window);
|
||||
last_window.deallocFlag = &window_deallocated;
|
||||
@@ -833,10 +831,9 @@ TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
||||
EXPECT_TRUE(window_deallocated);
|
||||
window_deallocated = false;
|
||||
|
||||
{
|
||||
@autoreleasepool {
|
||||
// Repeat, but now retain a reference and close the window before
|
||||
// CloseAllSecondaryWidgets().
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
Widget* widget = CreateWidgetWithTestWindow(
|
||||
Widget::InitParams(Widget::InitParams::TYPE_WINDOW), &last_window);
|
||||
last_window.deallocFlag = &window_deallocated;
|
||||
@@ -847,8 +844,7 @@ TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
||||
}
|
||||
|
||||
EXPECT_FALSE(window_deallocated);
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
Widget::CloseAllSecondaryWidgets();
|
||||
[last_window release];
|
||||
}
|
||||
@@ -880,8 +876,7 @@ TEST_F(NativeWidgetMacTest, NonWidgetParentLastReference) {
|
||||
bool child_dealloced = false;
|
||||
bool native_parent_dealloced = false;
|
||||
NativeWidgetMacTestWindow* native_parent = nil;
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
native_parent = MakeBorderlessNativeParent();
|
||||
[native_parent setDeallocFlag:&native_parent_dealloced];
|
||||
|
||||
@@ -893,13 +888,12 @@ TEST_F(NativeWidgetMacTest, NonWidgetParentLastReference) {
|
||||
CreateWidgetWithTestWindow(std::move(init_params), &window);
|
||||
[window setDeallocFlag:&child_dealloced];
|
||||
}
|
||||
{
|
||||
@autoreleasepool {
|
||||
// On 10.11, closing a weak reference on the parent window works, but older
|
||||
// versions of AppKit get upset if things are released inside -[NSWindow
|
||||
// close]. This test tries to establish a situation where the last reference
|
||||
// to the child window is released inside WidgetOwnerNSWindowAdapter::
|
||||
// OnWindowWillClose().
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
[native_parent close];
|
||||
EXPECT_TRUE(child_dealloced);
|
||||
}
|
||||
@@ -1511,8 +1505,7 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
||||
|
||||
// Test another hypothetical: What if -sheetDidEnd: was invoked somehow
|
||||
// without going through [NSApp endSheet:] or -[NSWindow endSheet:].
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
NSWindow* sheet_window =
|
||||
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
||||
@@ -1548,8 +1541,7 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
||||
// https://crbug.com/851376.
|
||||
TEST_F(NativeWidgetMacTest, CloseWindowModalSheetWithoutSheetParent) {
|
||||
NSWindow* native_parent = MakeClosableTitledNativeParent();
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@autoreleasepool {
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
NSWindow* sheet_window =
|
||||
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
||||
|
Reference in New Issue
Block a user