OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_FONT_LIST_ASYNC_H_ | 5 #ifndef CONTENT_BROWSER_FONT_LIST_ASYNC_H_ |
6 #define CONTENT_BROWSER_FONT_LIST_ASYNC_H_ | 6 #define CONTENT_BROWSER_FONT_LIST_ASYNC_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "content/common/content_export.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class ListValue; | 14 class ListValue; |
14 } | 15 } |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 // Wraps ownership of a ListValue so we can send it across threads without | 19 // Wraps ownership of a ListValue so we can send it across threads without |
19 // having ownership problems (for example if the calling thread goes away | 20 // having ownership problems (for example if the calling thread goes away |
20 // before the callback is executed, we want the ListValue to be destroyed. | 21 // before the callback is executed, we want the ListValue to be destroyed. |
21 struct FontListResult : public base::RefCountedThreadSafe<FontListResult> { | 22 struct CONTENT_EXPORT FontListResult |
| 23 : public base::RefCountedThreadSafe<FontListResult> { |
22 FontListResult(); | 24 FontListResult(); |
23 ~FontListResult(); | 25 ~FontListResult(); |
24 | 26 |
25 scoped_ptr<base::ListValue> list; | 27 scoped_ptr<base::ListValue> list; |
26 }; | 28 }; |
27 | 29 |
28 // Retrieves the list of fonts on the system as a list of strings. It provides | 30 // Retrieves the list of fonts on the system as a list of strings. It provides |
29 // a non-blocking interface to GetFontList_SlowBlocking in common/. | 31 // a non-blocking interface to GetFontList_SlowBlocking in common/. |
30 // | 32 // |
31 // This function will run asynchronously on a background thread since getting | 33 // This function will run asynchronously on a background thread since getting |
32 // the font list from the system can be slow. This function may be called from | 34 // the font list from the system can be slow. This function may be called from |
33 // any thread that has a BrowserThread::ID. The callback will be executed on | 35 // any thread that has a BrowserThread::ID. The callback will be executed on |
34 // the calling thread. | 36 // the calling thread. |
35 // | 37 // |
36 // If the caller wants to take ownership of the ListValue, it can just do | 38 // If the caller wants to take ownership of the ListValue, it can just do |
37 // FontListResult.list.release() or use scoped_ptr.swap() because this value | 39 // FontListResult.list.release() or use scoped_ptr.swap() because this value |
38 // isn't used for anything else. | 40 // isn't used for anything else. |
39 void GetFontListAsync( | 41 CONTENT_EXPORT void GetFontListAsync( |
40 const base::Callback<void(scoped_refptr<FontListResult>)>& callback); | 42 const base::Callback<void(scoped_refptr<FontListResult>)>& callback); |
41 | 43 |
42 } // namespace content | 44 } // namespace content |
43 | 45 |
44 #endif // CONTENT_BROWSER_FONT_LIST_ASYNC_H_ | 46 #endif // CONTENT_BROWSER_FONT_LIST_ASYNC_H_ |
OLD | NEW |