| 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 COMPONENTS_KEYED_SERVICE_CORE_REFCOUNTED_KEYED_SERVICE_H_ | 5 #ifndef COMPONENTS_KEYED_SERVICE_CORE_REFCOUNTED_KEYED_SERVICE_H_ |
| 6 #define COMPONENTS_KEYED_SERVICE_CORE_REFCOUNTED_KEYED_SERVICE_H_ | 6 #define COMPONENTS_KEYED_SERVICE_CORE_REFCOUNTED_KEYED_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/sequenced_task_runner_helpers.h" | 9 #include "base/sequenced_task_runner_helpers.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 virtual void ShutdownOnUIThread() = 0; | 44 virtual void ShutdownOnUIThread() = 0; |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 // If your service does not need to be deleted on a specific thread, use the | 47 // If your service does not need to be deleted on a specific thread, use the |
| 48 // default constructor. | 48 // default constructor. |
| 49 RefcountedKeyedService(); | 49 RefcountedKeyedService(); |
| 50 | 50 |
| 51 // If you need your service to be deleted on a specific thread (for example, | 51 // If you need your service to be deleted on a specific thread (for example, |
| 52 // you're converting a service that used content::DeleteOnThread<IO>), then | 52 // you're converting a service that used content::DeleteOnThread<IO>), then |
| 53 // use this constructor with a reference to the SingleThreadTaskRunner (you | 53 // use this constructor with a reference to the SingleThreadTaskRunner (you |
| 54 // can get it from content::BrowserThread::GetMessageLoopProxyForThread). | 54 // can get it from content::BrowserThread::GetTaskRunnerForThread). |
| 55 explicit RefcountedKeyedService( | 55 explicit RefcountedKeyedService( |
| 56 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 56 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 57 | 57 |
| 58 // The second pass destruction can happen anywhere unless you specify which | 58 // The second pass destruction can happen anywhere unless you specify which |
| 59 // thread this service must be destroyed on by using the second constructor. | 59 // thread this service must be destroyed on by using the second constructor. |
| 60 virtual ~RefcountedKeyedService(); | 60 virtual ~RefcountedKeyedService(); |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 friend struct impl::RefcountedKeyedServiceTraits; | 63 friend struct impl::RefcountedKeyedServiceTraits; |
| 64 friend class base::DeleteHelper<RefcountedKeyedService>; | 64 friend class base::DeleteHelper<RefcountedKeyedService>; |
| 65 friend class base::RefCountedThreadSafe<RefcountedKeyedService, | 65 friend class base::RefCountedThreadSafe<RefcountedKeyedService, |
| 66 impl::RefcountedKeyedServiceTraits>; | 66 impl::RefcountedKeyedServiceTraits>; |
| 67 | 67 |
| 68 // Do we have to delete this object on a specific thread? | 68 // Do we have to delete this object on a specific thread? |
| 69 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 69 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 #endif // COMPONENTS_KEYED_SERVICE_CORE_REFCOUNTED_KEYED_SERVICE_H_ | 72 #endif // COMPONENTS_KEYED_SERVICE_CORE_REFCOUNTED_KEYED_SERVICE_H_ |
| OLD | NEW |