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

Side by Side Diff: third_party/WebKit/Source/platform/text/TextBreakIteratorICU.cpp

Issue 1849023002: WTF::ThreadSpecific should use base::ThreadLocalStorage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check isShutdown(). Created 4 years, 8 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) 2006 Lars Knoll <lars@trolltech.com> 2 * Copyright (C) 2006 Lars Knoll <lars@trolltech.com>
3 * Copyright (C) 2007, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2011, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 21 matching lines...) Expand all
32 #include <unicode/ubrk.h> 32 #include <unicode/ubrk.h>
33 33
34 using namespace WTF; 34 using namespace WTF;
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class LineBreakIteratorPool final { 38 class LineBreakIteratorPool final {
39 USING_FAST_MALLOC(LineBreakIteratorPool); 39 USING_FAST_MALLOC(LineBreakIteratorPool);
40 WTF_MAKE_NONCOPYABLE(LineBreakIteratorPool); 40 WTF_MAKE_NONCOPYABLE(LineBreakIteratorPool);
41 public: 41 public:
42 LineBreakIteratorPool() { }
43
42 static LineBreakIteratorPool& sharedPool() 44 static LineBreakIteratorPool& sharedPool()
43 { 45 {
44 static WTF::ThreadSpecific<LineBreakIteratorPool>* pool = new WTF::Threa dSpecific<LineBreakIteratorPool>; 46 static WTF::ThreadSpecific<LineBreakIteratorPool>* pool = new WTF::Threa dSpecific<LineBreakIteratorPool>;
45 return **pool; 47 return **pool;
46 } 48 }
47 49
48 static PassOwnPtr<LineBreakIteratorPool> create() { return adoptPtr(new Line BreakIteratorPool); }
49
50 icu::BreakIterator* take(const AtomicString& locale) 50 icu::BreakIterator* take(const AtomicString& locale)
51 { 51 {
52 icu::BreakIterator* iterator = 0; 52 icu::BreakIterator* iterator = 0;
53 for (size_t i = 0; i < m_pool.size(); ++i) { 53 for (size_t i = 0; i < m_pool.size(); ++i) {
54 if (m_pool[i].first == locale) { 54 if (m_pool[i].first == locale) {
55 iterator = m_pool[i].second; 55 iterator = m_pool[i].second;
56 m_pool.remove(i); 56 m_pool.remove(i);
57 break; 57 break;
58 } 58 }
59 } 59 }
(...skipping 26 matching lines...) Expand all
86 86
87 if (m_pool.size() == capacity) { 87 if (m_pool.size() == capacity) {
88 delete(m_pool[0].second); 88 delete(m_pool[0].second);
89 m_pool.remove(0); 89 m_pool.remove(0);
90 } 90 }
91 91
92 m_pool.append(Entry(m_vendedIterators.take(iterator), iterator)); 92 m_pool.append(Entry(m_vendedIterators.take(iterator), iterator));
93 } 93 }
94 94
95 private: 95 private:
96 LineBreakIteratorPool() { }
97
98 static const size_t capacity = 4; 96 static const size_t capacity = 4;
99 97
100 typedef std::pair<AtomicString, icu::BreakIterator*> Entry; 98 typedef std::pair<AtomicString, icu::BreakIterator*> Entry;
101 typedef Vector<Entry, capacity> Pool; 99 typedef Vector<Entry, capacity> Pool;
102 Pool m_pool; 100 Pool m_pool;
103 HashMap<icu::BreakIterator*, AtomicString> m_vendedIterators; 101 HashMap<icu::BreakIterator*, AtomicString> m_vendedIterators;
104
105 friend WTF::ThreadSpecific<LineBreakIteratorPool>::operator LineBreakIterato rPool*();
106 }; 102 };
107 103
108 enum TextContext { NoContext, PriorContext, PrimaryContext }; 104 enum TextContext { NoContext, PriorContext, PrimaryContext };
109 105
110 const int textBufferCapacity = 16; 106 const int textBufferCapacity = 16;
111 107
112 typedef struct { 108 typedef struct {
113 DISALLOW_NEW(); 109 DISALLOW_NEW();
114 UText text; 110 UText text;
115 UChar buffer[textBufferCapacity]; 111 UChar buffer[textBufferCapacity];
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 "$Tel1 $TelV $Tel0;" // Telugu Virama (backward) 831 "$Tel1 $TelV $Tel0;" // Telugu Virama (backward)
836 "$Kan1 $KanV $Kan0;" // Kannada Virama (backward) 832 "$Kan1 $KanV $Kan0;" // Kannada Virama (backward)
837 "$Mal1 $MalV $Mal0;" // Malayalam Virama (backward) 833 "$Mal1 $MalV $Mal0;" // Malayalam Virama (backward)
838 "!!safe_reverse;" 834 "!!safe_reverse;"
839 "!!safe_forward;"; 835 "!!safe_forward;";
840 836
841 return setUpIteratorWithRules(kRules, string, length); 837 return setUpIteratorWithRules(kRules, string, length);
842 } 838 }
843 839
844 } // namespace blink 840 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/BUILD.gn » ('j') | third_party/WebKit/Source/wtf/ThreadSpecific.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698