diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-18 02:47:39 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-18 02:47:39 +0000 |
commit | c2818d44191bc4342c2ae322f3e0cb218dd2ec66 (patch) | |
tree | de6265a7e8506e6df679a436cb4df1cd7281a614 /base | |
parent | e8b53808f5251d1486dd8b992fa94d96bb604e01 (diff) | |
download | chromium_src-c2818d44191bc4342c2ae322f3e0cb218dd2ec66.zip chromium_src-c2818d44191bc4342c2ae322f3e0cb218dd2ec66.tar.gz chromium_src-c2818d44191bc4342c2ae322f3e0cb218dd2ec66.tar.bz2 |
Move scoped_nsdisable_screen_update from base to app/mac
Move scoped_aedesc from base to base/mac
Use namespace and proper Google-style class naming.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3828009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gypi | 7 | ||||
-rw-r--r-- | base/chrome_application_mac.h | 2 | ||||
-rw-r--r-- | base/mac/scoped_aedesc.h (renamed from base/scoped_aedesc.h) | 24 | ||||
-rw-r--r-- | base/mac/scoped_nsautorelease_pool.h (renamed from base/scoped_nsautorelease_pool.h) | 10 | ||||
-rw-r--r-- | base/mac/scoped_nsautorelease_pool.mm (renamed from base/scoped_nsautorelease_pool.mm) | 6 | ||||
-rw-r--r-- | base/message_pump_default.cc | 4 | ||||
-rw-r--r-- | base/message_pump_libevent.cc | 6 | ||||
-rw-r--r-- | base/scoped_nsdisable_screen_updates.h | 36 | ||||
-rw-r--r-- | base/shared_memory_unittest.cc | 8 | ||||
-rw-r--r-- | base/test/test_suite.cc | 4 | ||||
-rw-r--r-- | base/worker_pool_mac.mm | 8 |
11 files changed, 44 insertions, 71 deletions
diff --git a/base/base.gypi b/base/base.gypi index b90c033..992cdcc 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -118,6 +118,9 @@ 'logging_win.cc', 'mac_util.h', 'mac_util.mm', + 'mac/scoped_aedesc.h', + 'mac/scoped_nsautorelease_pool.h', + 'mac/scoped_nsautorelease_pool.mm', 'mach_ipc_mac.h', 'mach_ipc_mac.mm', 'memory_debug.cc', @@ -191,13 +194,9 @@ 'resource_util.h', 'safe_strerror_posix.cc', 'safe_strerror_posix.h', - 'scoped_aedesc.h', 'scoped_callback_factory.h', 'scoped_cftyperef.h', 'scoped_handle.h', - 'scoped_nsautorelease_pool.h', - 'scoped_nsautorelease_pool.mm', - 'scoped_nsdisable_screen_updates.h', 'scoped_nsobject.h', 'scoped_open_process.h', 'scoped_ptr.h', diff --git a/base/chrome_application_mac.h b/base/chrome_application_mac.h index 3d620b4..676959ec 100644 --- a/base/chrome_application_mac.h +++ b/base/chrome_application_mac.h @@ -20,7 +20,7 @@ @interface CrApplication : NSApplication { @private BOOL handlingSendEvent_; - // Array of objects implementing the CrApplicationEventHookProtocol + // Array of objects implementing the CrApplicationEventHookProtocol scoped_nsobject<NSMutableArray> eventHooks_; } @property(readonly, diff --git a/base/scoped_aedesc.h b/base/mac/scoped_aedesc.h index 9239887..83a38c6 100644 --- a/base/scoped_aedesc.h +++ b/base/mac/scoped_aedesc.h @@ -2,29 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_SCOPED_AEDESC_H_ -#define BASE_SCOPED_AEDESC_H_ +#ifndef BASE_MAC_SCOPED_AEDESC_H_ +#define BASE_MAC_SCOPED_AEDESC_H_ #pragma once #import <CoreServices/CoreServices.h> #include "base/basictypes.h" -// The scoped_aedesc is used to scope AppleEvent descriptors. On creation, +namespace base { +namespace mac { + +// The ScopedAEDesc is used to scope AppleEvent descriptors. On creation, // it will store a NULL descriptor. On destruction, it will dispose of the // descriptor. // // This class is parameterized for additional type safety checks. You can use // the generic AEDesc type by not providing a template parameter: -// scoped_aedesc<> desc; +// ScopedAEDesc<> desc; template <typename AEDescType = AEDesc> -class scoped_aedesc { +class ScopedAEDesc { public: - scoped_aedesc() { + ScopedAEDesc() { AECreateDesc(typeNull, NULL, 0, &desc_); } - ~scoped_aedesc() { + ~ScopedAEDesc() { AEDisposeDesc(&desc_); } @@ -41,7 +44,10 @@ class scoped_aedesc { private: AEDescType desc_; - DISALLOW_COPY_AND_ASSIGN(scoped_aedesc); + DISALLOW_COPY_AND_ASSIGN(ScopedAEDesc); }; -#endif // BASE_SCOPED_AEDESC_H_ +} // namespace mac +} // namespace base + +#endif // BASE_MAC_SCOPED_AEDESC_H_ diff --git a/base/scoped_nsautorelease_pool.h b/base/mac/scoped_nsautorelease_pool.h index 9f428ac..0a95bd1b 100644 --- a/base/scoped_nsautorelease_pool.h +++ b/base/mac/scoped_nsautorelease_pool.h @@ -1,9 +1,9 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_SCOPED_NSAUTORELEASE_POOL_H_ -#define BASE_SCOPED_NSAUTORELEASE_POOL_H_ +#ifndef BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ +#define BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ #pragma once #include "base/basictypes.h" @@ -17,6 +17,7 @@ class NSAutoreleasePool; #endif // OS_MACOSX namespace base { +namespace mac { // On the Mac, ScopedNSAutoreleasePool allocates an NSAutoreleasePool when // instantiated and sends it a -drain message when destroyed. This allows an @@ -48,6 +49,7 @@ class ScopedNSAutoreleasePool { DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool); }; +} // namespace mac } // namespace base -#endif // BASE_SCOPED_NSAUTORELEASE_POOL_H_ +#endif // BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ diff --git a/base/scoped_nsautorelease_pool.mm b/base/mac/scoped_nsautorelease_pool.mm index 174fb82..e542ca8 100644 --- a/base/scoped_nsautorelease_pool.mm +++ b/base/mac/scoped_nsautorelease_pool.mm @@ -1,14 +1,15 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/scoped_nsautorelease_pool.h" +#include "base/mac/scoped_nsautorelease_pool.h" #import <Foundation/Foundation.h> #include "base/logging.h" namespace base { +namespace mac { ScopedNSAutoreleasePool::ScopedNSAutoreleasePool() : autorelease_pool_([[NSAutoreleasePool alloc] init]) { @@ -27,4 +28,5 @@ void ScopedNSAutoreleasePool::Recycle() { DCHECK(autorelease_pool_); } +} // namespace mac } // namespace base diff --git a/base/message_pump_default.cc b/base/message_pump_default.cc index d69fc03..518684a 100644 --- a/base/message_pump_default.cc +++ b/base/message_pump_default.cc @@ -5,7 +5,7 @@ #include "base/message_pump_default.h" #include "base/logging.h" -#include "base/scoped_nsautorelease_pool.h" +#include "base/mac/scoped_nsautorelease_pool.h" namespace base { @@ -18,7 +18,7 @@ void MessagePumpDefault::Run(Delegate* delegate) { DCHECK(keep_running_) << "Quit must have been called outside of Run!"; for (;;) { - ScopedNSAutoreleasePool autorelease_pool; + mac::ScopedNSAutoreleasePool autorelease_pool; bool did_work = delegate->DoWork(); if (!keep_running_) diff --git a/base/message_pump_libevent.cc b/base/message_pump_libevent.cc index ff4a04a..d325957 100644 --- a/base/message_pump_libevent.cc +++ b/base/message_pump_libevent.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,8 +10,8 @@ #include "base/auto_reset.h" #include "base/eintr_wrapper.h" #include "base/logging.h" +#include "base/mac/scoped_nsautorelease_pool.h" #include "base/observer_list.h" -#include "base/scoped_nsautorelease_pool.h" #include "base/scoped_ptr.h" #include "base/time.h" #if defined(USE_SYSTEM_LIBEVENT) @@ -265,7 +265,7 @@ void MessagePumpLibevent::Run(Delegate* delegate) { scoped_ptr<event> timer_event(new event); for (;;) { - ScopedNSAutoreleasePool autorelease_pool; + mac::ScopedNSAutoreleasePool autorelease_pool; bool did_work = delegate->DoWork(); if (!keep_running_) diff --git a/base/scoped_nsdisable_screen_updates.h b/base/scoped_nsdisable_screen_updates.h deleted file mode 100644 index 5af6026..0000000 --- a/base/scoped_nsdisable_screen_updates.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_SCOPED_NSDISABLE_SCREEN_UPDATES_H_ -#define BASE_SCOPED_NSDISABLE_SCREEN_UPDATES_H_ -#pragma once - -#import <Cocoa/Cocoa.h> - -#include "base/basictypes.h" - -namespace base { - -// A stack-based class to disable Cocoa screen updates. When instantiated, it -// disables screen updates and enables them when destroyed. Update disabling -// can be nested, and there is a time-maximum (about 1 second) after which -// Cocoa will automatically re-enable updating. This class doesn't attempt to -// overrule that. - -class ScopedNSDisableScreenUpdates { - public: - ScopedNSDisableScreenUpdates() { - NSDisableScreenUpdates(); - } - ~ScopedNSDisableScreenUpdates() { - NSEnableScreenUpdates(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(ScopedNSDisableScreenUpdates); -}; - -} // namespace - -#endif // BASE_SCOPED_NSDISABLE_SCREEN_UPDATES_H_ diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc index 97287fa..53bffb4 100644 --- a/base/shared_memory_unittest.cc +++ b/base/shared_memory_unittest.cc @@ -1,10 +1,10 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/basictypes.h" +#include "base/mac/scoped_nsautorelease_pool.h" #include "base/platform_thread.h" -#include "base/scoped_nsautorelease_pool.h" #include "base/shared_memory.h" #include "base/scoped_ptr.h" #include "base/test/multiprocess_test.h" @@ -33,7 +33,7 @@ class MultipleThreadMain : public PlatformThread::Delegate { // PlatformThread::Delegate interface. void ThreadMain() { - ScopedNSAutoreleasePool pool; // noop if not OSX + mac::ScopedNSAutoreleasePool pool; // noop if not OSX const uint32 kDataSize = 1024; SharedMemory memory; bool rv = memory.Create(s_test_name_, false, true, kDataSize); @@ -286,7 +286,7 @@ class SharedMemoryProcessTest : public base::MultiProcessTest { static int TaskTestMain() { int errors = 0; - ScopedNSAutoreleasePool pool; // noop if not OSX + mac::ScopedNSAutoreleasePool pool; // noop if not OSX const uint32 kDataSize = 1024; SharedMemory memory; bool rv = memory.Create(s_test_name_, false, true, kDataSize); diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index a08bbd9..f2e6069 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -13,10 +13,10 @@ #include "base/file_path.h" #include "base/i18n/icu_util.h" #include "base/logging.h" +#include "base/mac/scoped_nsautorelease_pool.h" #include "base/nss_util.h" #include "base/path_service.h" #include "base/process_util.h" -#include "base/scoped_nsautorelease_pool.h" #include "base/scoped_ptr.h" #include "base/test/multiprocess_test.h" #include "base/test/test_timeouts.h" @@ -113,7 +113,7 @@ void TestSuite::CatchMaybeTests() { // Don't add additional code to this method. Instead add it to // Initialize(). See bug 6436. int TestSuite::Run() { - base::ScopedNSAutoreleasePool scoped_pool; + base::mac::ScopedNSAutoreleasePool scoped_pool; Initialize(); std::string client_func = diff --git a/base/worker_pool_mac.mm b/base/worker_pool_mac.mm index a301bf8..01c0a98 100644 --- a/base/worker_pool_mac.mm +++ b/base/worker_pool_mac.mm @@ -5,8 +5,8 @@ #include "base/worker_pool_mac.h" #include "base/logging.h" +#import "base/mac/scoped_nsautorelease_pool.h" #include "base/metrics/histogram.h" -#import "base/scoped_nsautorelease_pool.h" #include "base/scoped_ptr.h" #import "base/singleton_objc.h" #include "base/task.h" @@ -83,7 +83,7 @@ size_t outstanding_ = 0; // Operations posted but not completed. ++running_; } - base::ScopedNSAutoreleasePool autoreleasePool; + base::mac::ScopedNSAutoreleasePool autoreleasePool; @try { task_->Run(); @@ -117,7 +117,7 @@ size_t outstanding_ = 0; // Operations posted but not completed. bool WorkerPool::PostTask(const tracked_objects::Location& from_here, Task* task, bool task_is_slow) { - base::ScopedNSAutoreleasePool autorelease_pool; + base::mac::ScopedNSAutoreleasePool autorelease_pool; // Ignore |task_is_slow|, it doesn't map directly to any tunable aspect of // an NSOperation. @@ -157,7 +157,7 @@ bool WorkerPool::PostTask(const tracked_objects::Location& from_here, ++outstanding_; running_ops = running_; if (last_check_.is_null() || now - last_check_ > kCheckPeriod) { - base::ScopedNSAutoreleasePool autoreleasePool; + base::mac::ScopedNSAutoreleasePool autoreleasePool; std::vector<id> ops; for (id op in [operation_queue operations]) { // DO NOT RETAIN. |