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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringImpl.cpp

Issue 2335573003: Move String::isSafeToSendToAnotherThread to StringImpl. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) 4 * (C) 2001 Dirk Mueller ( mueller@kde.org )
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved.
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (isAtomic()) 279 if (isAtomic())
280 AtomicStringTable::instance().remove(this); 280 AtomicStringTable::instance().remove(this);
281 } 281 }
282 282
283 void StringImpl::destroyIfNotStatic() 283 void StringImpl::destroyIfNotStatic()
284 { 284 {
285 if (!isStatic()) 285 if (!isStatic())
286 delete this; 286 delete this;
287 } 287 }
288 288
289 bool StringImpl::isSafeToSendToAnotherThread() const
290 {
291 if (isStatic())
292 return true;
293 // AtomicStrings are not safe to send between threads as ~StringImpl()
294 // will try to remove them from the wrong AtomicStringTable.
295 if (isAtomic())
296 return false;
297 if (hasOneRef())
298 return true;
299 return false;
300 }
301
289 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*& data) 302 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*& data)
290 { 303 {
291 if (!length) { 304 if (!length) {
292 data = 0; 305 data = 0;
293 return empty(); 306 return empty();
294 } 307 }
295 308
296 // Allocate a single buffer large enough to contain the StringImpl 309 // Allocate a single buffer large enough to contain the StringImpl
297 // struct as well as the data which it contains. This removes one 310 // struct as well as the data which it contains. This removes one
298 // heap allocation from this call. 311 // heap allocation from this call.
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2017 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2005 // TODO(rob.buis) implement upper-casing rules for lt 2018 // TODO(rob.buis) implement upper-casing rules for lt
2006 // like in StringImpl::upper(locale). 2019 // like in StringImpl::upper(locale).
2007 } 2020 }
2008 } 2021 }
2009 2022
2010 return toUpper(c); 2023 return toUpper(c);
2011 } 2024 }
2012 2025
2013 } // namespace WTF 2026 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698