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

Side by Side Diff: base/mac/scoped_nsexception_enabler.mm

Issue 7038010: [Mac] Allow NSExceptions in certain cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oh, clang, you crazy fox. Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/mac/scoped_nsexception_enabler.h ('k') | chrome/browser/chrome_browser_application_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "base/mac/scoped_nsexception_enabler.h"
6
7 #import "base/lazy_instance.h"
8 #import "base/threading/thread_local.h"
9
10 // To make the |g_exceptionsAllowed| declaration readable.
11 using base::LazyInstance;
12 using base::LeakyLazyInstanceTraits;
13 using base::ThreadLocalBoolean;
14
15 namespace {
16
17 // Whether to allow NSExceptions to be raised on the current thread.
18 LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
19 g_exceptionsAllowed(base::LINKER_INITIALIZED);
20
21 } // namespace
22
23 namespace base {
24 namespace mac {
25
26 bool GetNSExceptionsAllowed() {
27 return g_exceptionsAllowed.Get().Get();
28 }
29
30 void SetNSExceptionsAllowed(bool allowed) {
31 return g_exceptionsAllowed.Get().Set(allowed);
32 }
33
34 ScopedNSExceptionEnabler::ScopedNSExceptionEnabler() {
35 was_enabled_ = GetNSExceptionsAllowed();
36 SetNSExceptionsAllowed(true);
37 }
38
39 ScopedNSExceptionEnabler::~ScopedNSExceptionEnabler() {
40 SetNSExceptionsAllowed(was_enabled_);
41 }
42
43 } // namespace mac
44 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/scoped_nsexception_enabler.h ('k') | chrome/browser/chrome_browser_application_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698