| OLD | NEW |
| 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 EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 struct NamedThreadTraits { | 38 struct NamedThreadTraits { |
| 39 static bool IsCalledOnValidThread() { | 39 static bool IsCalledOnValidThread() { |
| 40 return content::BrowserThread::CurrentlyOn(T::kThreadId); | 40 return content::BrowserThread::CurrentlyOn(T::kThreadId); |
| 41 } | 41 } |
| 42 | 42 |
| 43 static bool IsMessageLoopValid() { | 43 static bool IsMessageLoopValid() { |
| 44 return content::BrowserThread::IsMessageLoopValid(T::kThreadId); | 44 return content::BrowserThread::IsMessageLoopValid(T::kThreadId); |
| 45 } | 45 } |
| 46 | 46 |
| 47 static scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() { | 47 static scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() { |
| 48 return content::BrowserThread::GetMessageLoopProxyForThread(T::kThreadId); | 48 return content::BrowserThread::GetTaskRunnerForThread(T::kThreadId); |
| 49 } | 49 } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // An ApiResourceManager manages the lifetime of a set of resources that | 52 // An ApiResourceManager manages the lifetime of a set of resources that |
| 53 // that live on named threads (i.e. BrowserThread::IO) which ApiFunctions use. | 53 // that live on named threads (i.e. BrowserThread::IO) which ApiFunctions use. |
| 54 // Examples of such resources are sockets or USB connections. | 54 // Examples of such resources are sockets or USB connections. |
| 55 // | 55 // |
| 56 // Users of this class should define kThreadId to be the thread that | 56 // Users of this class should define kThreadId to be the thread that |
| 57 // ApiResourceManager to works on. The default is defined in ApiResource. | 57 // ApiResourceManager to works on. The default is defined in ApiResource. |
| 58 // The user must also define a static const char* service_name() that returns | 58 // The user must also define a static const char* service_name() that returns |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 ->GetSequencedTaskRunnerWithShutdownBehavior( | 429 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 430 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | 430 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
| 431 T::kSequenceToken), | 431 T::kSequenceToken), |
| 432 T::kShutdownBehavior); | 432 T::kShutdownBehavior); |
| 433 } | 433 } |
| 434 }; | 434 }; |
| 435 | 435 |
| 436 } // namespace extensions | 436 } // namespace extensions |
| 437 | 437 |
| 438 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ | 438 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
| OLD | NEW |