| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_PROFILES_REFCOUNTED_PROFILE_KEYED_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_REFCOUNTED_PROFILE_KEYED_SERVICE_H_ |
| 6 #define CHROME_BROWSER_PROFILES_REFCOUNTED_PROFILE_KEYED_SERVICE_H_ | 6 #define CHROME_BROWSER_PROFILES_REFCOUNTED_PROFILE_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 "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 10 | 11 |
| 11 class RefcountedProfileKeyedService; | 12 class RefcountedProfileKeyedService; |
| 12 | 13 |
| 13 namespace impl { | 14 namespace impl { |
| 14 | 15 |
| 15 struct RefcountedProfileKeyedServiceTraits { | 16 struct RefcountedProfileKeyedServiceTraits { |
| 16 static void Destruct(const RefcountedProfileKeyedService* obj); | 17 static void Destruct(const RefcountedProfileKeyedService* obj); |
| 17 }; | 18 }; |
| 18 | 19 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 RefcountedProfileKeyedService, | 36 RefcountedProfileKeyedService, |
| 36 impl::RefcountedProfileKeyedServiceTraits> { | 37 impl::RefcountedProfileKeyedServiceTraits> { |
| 37 public: | 38 public: |
| 38 // Unlike ProfileKeyedService, ShutdownOnUI is not optional. You must do | 39 // Unlike ProfileKeyedService, ShutdownOnUI is not optional. You must do |
| 39 // something to drop references during the first pass Shutdown() because this | 40 // something to drop references during the first pass Shutdown() because this |
| 40 // is the only point where you are guaranteed that something is running on | 41 // is the only point where you are guaranteed that something is running on |
| 41 // the UI thread. The PKSF framework will ensure that this is only called on | 42 // the UI thread. The PKSF framework will ensure that this is only called on |
| 42 // the UI thread; you do not need to check for that yourself. | 43 // the UI thread; you do not need to check for that yourself. |
| 43 virtual void ShutdownOnUIThread() = 0; | 44 virtual void ShutdownOnUIThread() = 0; |
| 44 | 45 |
| 45 // The second pass destruction can happen anywhere unless you specify which | |
| 46 // thread this service must be destroyed on by using the second constructor. | |
| 47 virtual ~RefcountedProfileKeyedService(); | |
| 48 | |
| 49 protected: | 46 protected: |
| 50 // 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 |
| 51 // default constructor. | 48 // default constructor. |
| 52 RefcountedProfileKeyedService(); | 49 RefcountedProfileKeyedService(); |
| 53 | 50 |
| 54 // 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, |
| 55 // you're converting a service that used content::DeleteOnThread<IO>), then | 52 // you're converting a service that used content::DeleteOnThread<IO>), then |
| 56 // use this constructor with the ID of the thread. | 53 // use this constructor with the ID of the thread. |
| 57 explicit RefcountedProfileKeyedService( | 54 explicit RefcountedProfileKeyedService( |
| 58 const content::BrowserThread::ID thread_id); | 55 const content::BrowserThread::ID thread_id); |
| 59 | 56 |
| 57 // The second pass destruction can happen anywhere unless you specify which |
| 58 // thread this service must be destroyed on by using the second constructor. |
| 59 virtual ~RefcountedProfileKeyedService(); |
| 60 |
| 60 private: | 61 private: |
| 61 friend struct impl::RefcountedProfileKeyedServiceTraits; | 62 friend struct impl::RefcountedProfileKeyedServiceTraits; |
| 63 friend class base::DeleteHelper<RefcountedProfileKeyedService>; |
| 62 | 64 |
| 63 // Do we have to delete this object on a specific thread? | 65 // Do we have to delete this object on a specific thread? |
| 64 bool requires_destruction_on_thread_; | 66 bool requires_destruction_on_thread_; |
| 65 content::BrowserThread::ID thread_id_; | 67 content::BrowserThread::ID thread_id_; |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 #endif // CHROME_BROWSER_PROFILES_REFCOUNTED_PROFILE_KEYED_SERVICE_H_ | 70 #endif // CHROME_BROWSER_PROFILES_REFCOUNTED_PROFILE_KEYED_SERVICE_H_ |
| OLD | NEW |