summaryrefslogtreecommitdiffstats
path: root/base/platform_thread_mac.mm
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-31 20:02:16 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-31 20:02:16 +0000
commitce072a7181ea5d58133e33654133236f5d9f5551 (patch)
tree1b1c903fec3fd27038cd17cb4ae9ca17d3736e40 /base/platform_thread_mac.mm
parenta8e2058011129cbef38bf89834ee01715556b392 (diff)
downloadchromium_src-ce072a7181ea5d58133e33654133236f5d9f5551.zip
chromium_src-ce072a7181ea5d58133e33654133236f5d9f5551.tar.gz
chromium_src-ce072a7181ea5d58133e33654133236f5d9f5551.tar.bz2
Move platform_thread to base/threading and put in the base namespace. I left a
stub and "using" declarations in the old location to avoid having to change the entire project at once. TEST=it compiles BUG=none Review URL: http://codereview.chromium.org/6001010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70342 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/platform_thread_mac.mm')
-rw-r--r--base/platform_thread_mac.mm54
1 files changed, 0 insertions, 54 deletions
diff --git a/base/platform_thread_mac.mm b/base/platform_thread_mac.mm
deleted file mode 100644
index 36e08be..0000000
--- a/base/platform_thread_mac.mm
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2006-2008 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/platform_thread.h"
-
-#import <Foundation/Foundation.h>
-#include <dlfcn.h>
-
-#include "base/logging.h"
-
-namespace base {
-
-// If Cocoa is to be used on more than one thread, it must know that the
-// application is multithreaded. Since it's possible to enter Cocoa code
-// from threads created by pthread_thread_create, Cocoa won't necessarily
-// be aware that the application is multithreaded. Spawning an NSThread is
-// enough to get Cocoa to set up for multithreaded operation, so this is done
-// if necessary before pthread_thread_create spawns any threads.
-//
-// http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/chapter_4_section_4.html
-void InitThreading() {
- static BOOL multithreaded = [NSThread isMultiThreaded];
- if (!multithreaded) {
- // +[NSObject class] is idempotent.
- [NSThread detachNewThreadSelector:@selector(class)
- toTarget:[NSObject class]
- withObject:nil];
- multithreaded = YES;
-
- DCHECK([NSThread isMultiThreaded]);
- }
-}
-
-} // namespace base
-
-// static
-void PlatformThread::SetName(const char* name) {
- // pthread_setname_np is only available in 10.6 or later, so test
- // for it at runtime.
- int (*dynamic_pthread_setname_np)(const char*);
- *reinterpret_cast<void**>(&dynamic_pthread_setname_np) =
- dlsym(RTLD_DEFAULT, "pthread_setname_np");
- if (!dynamic_pthread_setname_np)
- return;
-
- // Mac OS X does not expose the length limit of the name, so
- // hardcode it.
- const int kMaxNameLength = 63;
- std::string shortened_name = std::string(name).substr(0, kMaxNameLength);
- // pthread_setname() fails (harmlessly) in the sandbox, ignore when it does.
- // See http://crbug.com/47058
- dynamic_pthread_setname_np(shortened_name.c_str());
-}