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 #include "content/public/browser/font_list_async.h" | 5 #include "content/public/browser/font_list_async.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "content/common/font_list.h" | 11 #include "content/common/font_list.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Just executes the given callback with the parameter. | 18 // Just executes the given callback with the parameter. |
19 void ReturnFontListToOriginalThread( | 19 void ReturnFontListToOriginalThread( |
20 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback, | 20 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback, |
21 scoped_ptr<base::ListValue> result) { | 21 std::unique_ptr<base::ListValue> result) { |
22 callback.Run(std::move(result)); | 22 callback.Run(std::move(result)); |
23 } | 23 } |
24 | 24 |
25 void GetFontListInBlockingPool( | 25 void GetFontListInBlockingPool( |
26 BrowserThread::ID calling_thread_id, | 26 BrowserThread::ID calling_thread_id, |
27 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback) { | 27 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) { |
28 scoped_ptr<base::ListValue> result(GetFontList_SlowBlocking()); | 28 std::unique_ptr<base::ListValue> result(GetFontList_SlowBlocking()); |
29 BrowserThread::PostTask(calling_thread_id, FROM_HERE, | 29 BrowserThread::PostTask(calling_thread_id, FROM_HERE, |
30 base::Bind(&ReturnFontListToOriginalThread, callback, | 30 base::Bind(&ReturnFontListToOriginalThread, callback, |
31 base::Passed(&result))); | 31 base::Passed(&result))); |
32 } | 32 } |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 void GetFontListAsync( | 36 void GetFontListAsync( |
37 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback) { | 37 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) { |
38 BrowserThread::ID id; | 38 BrowserThread::ID id; |
39 bool well_known_thread = BrowserThread::GetCurrentThreadIdentifier(&id); | 39 bool well_known_thread = BrowserThread::GetCurrentThreadIdentifier(&id); |
40 DCHECK(well_known_thread) | 40 DCHECK(well_known_thread) |
41 << "Can only call GetFontList from a well-known thread."; | 41 << "Can only call GetFontList from a well-known thread."; |
42 | 42 |
43 BrowserThread::PostBlockingPoolSequencedTask( | 43 BrowserThread::PostBlockingPoolSequencedTask( |
44 kFontListSequenceToken, | 44 kFontListSequenceToken, |
45 FROM_HERE, | 45 FROM_HERE, |
46 base::Bind(&GetFontListInBlockingPool, id, callback)); | 46 base::Bind(&GetFontListInBlockingPool, id, callback)); |
47 } | 47 } |
48 | 48 |
49 } // namespace content | 49 } // namespace content |
OLD | NEW |