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

Side by Side Diff: ui/gfx/font_list_impl.h

Issue 2695393003: Make FontListImpl RefCountedThreadSafe (Closed)
Patch Set: +PlatformFont Created 3 years, 10 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 | ui/gfx/platform_font.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_FONT_LIST_IMPL_H_ 5 #ifndef UI_GFX_FONT_LIST_IMPL_H_
6 #define UI_GFX_FONT_LIST_IMPL_H_ 6 #define UI_GFX_FONT_LIST_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "ui/gfx/font.h" 12 #include "ui/gfx/font.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 // FontListImpl is designed to provide the implementation of FontList and 16 // FontListImpl is designed to provide the implementation of FontList and
17 // intended to be used only from FontList. You must not use this class 17 // intended to be used only from FontList. You must not use this class
18 // directly. 18 // directly.
19 // 19 //
20 // FontListImpl represents a list of fonts either in the form of Font vector or 20 // FontListImpl represents a list of fonts either in the form of Font vector or
21 // in the form of a string representing font names, styles, and size. 21 // in the form of a string representing font names, styles, and size.
22 // 22 //
23 // FontListImpl could be initialized either way without conversion to the other 23 // FontListImpl could be initialized either way without conversion to the other
24 // form. The conversion to the other form is done only when asked to get the 24 // form. The conversion to the other form is done only when asked to get the
25 // other form. 25 // other form.
26 // 26 //
27 // For the format of font description string, see font_list.h for details. 27 // For the format of font description string, see font_list.h for details.
28 class FontListImpl : public base::RefCounted<FontListImpl> { 28 class FontListImpl : public base::RefCountedThreadSafe<FontListImpl> {
29 public: 29 public:
30 // Creates a font list from a string representing font names, styles, and 30 // Creates a font list from a string representing font names, styles, and
31 // size. 31 // size.
32 explicit FontListImpl(const std::string& font_description_string); 32 explicit FontListImpl(const std::string& font_description_string);
33 33
34 // Creates a font list from font names, styles, size and weight. 34 // Creates a font list from font names, styles, size and weight.
35 FontListImpl(const std::vector<std::string>& font_names, 35 FontListImpl(const std::vector<std::string>& font_names,
36 int font_style, 36 int font_style,
37 int font_size, 37 int font_size,
38 Font::Weight font_weight); 38 Font::Weight font_weight);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Returns the font weight. 78 // Returns the font weight.
79 Font::Weight GetFontWeight() const; 79 Font::Weight GetFontWeight() const;
80 80
81 // Returns the Font vector. 81 // Returns the Font vector.
82 const std::vector<Font>& GetFonts() const; 82 const std::vector<Font>& GetFonts() const;
83 83
84 // Returns the first font in the list. 84 // Returns the first font in the list.
85 const Font& GetPrimaryFont() const; 85 const Font& GetPrimaryFont() const;
86 86
87 private: 87 private:
88 friend class base::RefCounted<FontListImpl>; 88 friend class base::RefCountedThreadSafe<FontListImpl>;
89 89
90 ~FontListImpl(); 90 ~FontListImpl();
91 91
92 // Extracts common font height and baseline into |common_height_| and 92 // Extracts common font height and baseline into |common_height_| and
93 // |common_baseline_|. 93 // |common_baseline_|.
94 void CacheCommonFontHeightAndBaseline() const; 94 void CacheCommonFontHeightAndBaseline() const;
95 95
96 // Extracts font style and size into |font_style_| and |font_size_|. 96 // Extracts font style and size into |font_style_| and |font_size_|.
97 void CacheFontStyleAndSize() const; 97 void CacheFontStyleAndSize() const;
98 98
(...skipping 18 matching lines...) Expand all
117 117
118 // Cached font style and size. 118 // Cached font style and size.
119 mutable int font_style_; 119 mutable int font_style_;
120 mutable int font_size_; 120 mutable int font_size_;
121 mutable Font::Weight font_weight_; 121 mutable Font::Weight font_weight_;
122 }; 122 };
123 123
124 } // namespace gfx 124 } // namespace gfx
125 125
126 #endif // UI_GFX_FONT_LIST_IMPL_H_ 126 #endif // UI_GFX_FONT_LIST_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/platform_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698