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

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

Issue 1856793002: Revert of WTF::ThreadSpecific should use base::ThreadLocalStorage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manual revert 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
44 static LineBreakIteratorPool& sharedPool() 42 static LineBreakIteratorPool& sharedPool()
45 { 43 {
46 static WTF::ThreadSpecific<LineBreakIteratorPool>* pool = new WTF::Threa dSpecific<LineBreakIteratorPool>; 44 static WTF::ThreadSpecific<LineBreakIteratorPool>* pool = new WTF::Threa dSpecific<LineBreakIteratorPool>;
47 return **pool; 45 return **pool;
48 } 46 }
49 47
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
96 static const size_t capacity = 4; 98 static const size_t capacity = 4;
97 99
98 typedef std::pair<AtomicString, icu::BreakIterator*> Entry; 100 typedef std::pair<AtomicString, icu::BreakIterator*> Entry;
99 typedef Vector<Entry, capacity> Pool; 101 typedef Vector<Entry, capacity> Pool;
100 Pool m_pool; 102 Pool m_pool;
101 HashMap<icu::BreakIterator*, AtomicString> m_vendedIterators; 103 HashMap<icu::BreakIterator*, AtomicString> m_vendedIterators;
104
105 friend WTF::ThreadSpecific<LineBreakIteratorPool>::operator LineBreakIterato rPool*();
102 }; 106 };
103 107
104 enum TextContext { NoContext, PriorContext, PrimaryContext }; 108 enum TextContext { NoContext, PriorContext, PrimaryContext };
105 109
106 const int textBufferCapacity = 16; 110 const int textBufferCapacity = 16;
107 111
108 typedef struct { 112 typedef struct {
109 DISALLOW_NEW(); 113 DISALLOW_NEW();
110 UText text; 114 UText text;
111 UChar buffer[textBufferCapacity]; 115 UChar buffer[textBufferCapacity];
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 "$Tel1 $TelV $Tel0;" // Telugu Virama (backward) 835 "$Tel1 $TelV $Tel0;" // Telugu Virama (backward)
832 "$Kan1 $KanV $Kan0;" // Kannada Virama (backward) 836 "$Kan1 $KanV $Kan0;" // Kannada Virama (backward)
833 "$Mal1 $MalV $Mal0;" // Malayalam Virama (backward) 837 "$Mal1 $MalV $Mal0;" // Malayalam Virama (backward)
834 "!!safe_reverse;" 838 "!!safe_reverse;"
835 "!!safe_forward;"; 839 "!!safe_forward;";
836 840
837 return setUpIteratorWithRules(kRules, string, length); 841 return setUpIteratorWithRules(kRules, string, length);
838 } 842 }
839 843
840 } // namespace blink 844 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698