Chromium Code Reviews| Index: chrome/browser/extensions/api/system_info/system_info_provider.h |
| diff --git a/chrome/browser/extensions/api/system_info/system_info_provider.h b/chrome/browser/extensions/api/system_info/system_info_provider.h |
| index 574e62925ace61d2cb8d60c36e767eae41599438..33a265f565899984b42110681e9cc2c8afd81d35 100644 |
| --- a/chrome/browser/extensions/api/system_info/system_info_provider.h |
| +++ b/chrome/browser/extensions/api/system_info/system_info_provider.h |
| @@ -68,24 +68,39 @@ class SystemInfoProvider |
| is_waiting_for_completion_ = true; |
| + StartQueryInfoImpl(); |
| + } |
| + |
| + protected: |
| + // Default implementation of querying system information. |
| + virtual void StartQueryInfoImpl() { |
|
Greg Billock
2013/06/27 17:12:22
Is this OK for the non-storage SystemInfoProvider
Haojian Wu
2013/06/28 14:51:05
Yes.
|
| + base::Closure callback = |
| + base::Bind(&SystemInfoProvider<T>::QueryOnWorkerPool, this); |
| + PostQueryTaskToBlockingPool(FROM_HERE, callback); |
| + } |
| + |
| + // Post a task to blocking pool for information querying. |
| + void PostQueryTaskToBlockingPool(const tracked_objects::Location& from_here, |
| + const base::Closure& query_callback) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| base::SequencedWorkerPool* worker_pool = |
| content::BrowserThread::GetBlockingPool(); |
| // The query task posted to the worker pool won't block shutdown, and any |
| // running query task at shutdown time will be ignored. |
| worker_pool->PostSequencedWorkerTaskWithShutdownBehavior( |
| - worker_pool_token_, |
| - FROM_HERE, |
| - base::Bind(&SystemInfoProvider<T>::QueryOnWorkerPool, this), |
| + worker_pool_token_, from_here, query_callback, |
| base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| } |
| - protected: |
| // Query the system information synchronously and output the result to the |
| // |info| parameter. The |info| contents MUST be reset firstly in its |
| // platform specific implementation. Return true if it succeeds, otherwise |
| // false is returned. |
| + // TODO(Haojian): Remove the parameter T-typed pointer. |
| virtual bool QueryInfo(T* info) = 0; |
| + // TODO(Haojian): Use PostBlockingPoolTaskAndReply to avoid unnecessary |
| + // trampolines trip. |
| virtual void QueryOnWorkerPool() { |
| bool success = QueryInfo(&info_); |
| content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |