Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/font_list_async.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/values.h" | |
| 9 #include "content/browser/browser_thread.h" | |
| 10 #include "content/common/font_list.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 // Just executes the given callback with the parameter. | |
| 17 void ReturnFontListToOriginalThread( | |
| 18 const base::Callback<void(scoped_refptr<FontListResult>)>& callback, | |
| 19 scoped_refptr<FontListResult> result) { | |
| 20 callback.Run(result); | |
| 21 } | |
| 22 | |
| 23 void GetFontListOnBackgroundThread( | |
|
viettrungluu
2011/05/18 20:21:18
Maybe you should be more specific and s/Background
| |
| 24 BrowserThread::ID calling_thread_id, | |
| 25 const base::Callback<void(scoped_refptr<FontListResult>)>& callback) { | |
| 26 scoped_refptr<FontListResult> result(new FontListResult); | |
| 27 result->list.reset(GetFontList_SlowBlocking()); | |
| 28 BrowserThread::PostTask(calling_thread_id, FROM_HERE, | |
| 29 base::Bind(&ReturnFontListToOriginalThread, callback, result)); | |
| 30 } | |
| 31 | |
| 32 } // namespace | |
| 33 | |
| 34 FontListResult::FontListResult() { | |
| 35 } | |
| 36 | |
| 37 FontListResult::~FontListResult() { | |
| 38 } | |
| 39 | |
| 40 void GetFontListAsync( | |
| 41 const base::Callback<void(scoped_refptr<FontListResult>)>& callback) { | |
| 42 BrowserThread::ID id; | |
| 43 bool well_known_thread = BrowserThread::GetCurrentThreadIdentifier(&id); | |
|
viettrungluu
2011/05/18 20:21:18
Is it true that all threads with IDs run message l
brettw
2011/05/18 21:14:38
Should be.
| |
| 44 DCHECK(well_known_thread) | |
| 45 << "Can only call GetFontList from a well-known thread"; | |
|
viettrungluu
2011/05/18 20:21:18
Does the message deserve punctuation?
| |
| 46 | |
| 47 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
| 48 base::Bind(&GetFontListOnBackgroundThread, id, callback)); | |
| 49 } | |
| 50 | |
| 51 } // namespace content | |
| OLD | NEW |