Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: components/browser_context_keyed_service/refcounted_browser_context_keyed_service.h

Issue 15517005: Remove references to Profile from browser_context_keyed_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & style Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_REFCOUNTED_BROWSER_CONTEXT_KEYE D_SERVICE_H_ 5 #ifndef COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_REFCOUNTED_BROWSER_CONTEXT_KEYE D_SERVICE_H_
6 #define COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_REFCOUNTED_BROWSER_CONTEXT_KEYE D_SERVICE_H_ 6 #define COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_REFCOUNTED_BROWSER_CONTEXT_KEYE D_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 "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 11
12 class RefcountedProfileKeyedService; 12 class RefcountedBrowserContextKeyedService;
13 13
14 namespace impl { 14 namespace impl {
15 15
16 struct RefcountedProfileKeyedServiceTraits { 16 struct RefcountedBrowserContextKeyedServiceTraits {
17 static void Destruct(const RefcountedProfileKeyedService* obj); 17 static void Destruct(const RefcountedBrowserContextKeyedService* obj);
18 }; 18 };
19 19
20 } // namespace impl 20 } // namespace impl
21 21
22 // Base class for refcounted objects that hang off the Profile. 22 // Base class for refcounted objects that hang off the BrowserContext.
23 // 23 //
24 // The two pass shutdown described in ProfileKeyedService works a bit 24 // The two pass shutdown described in BrowserContextKeyedService works a bit
25 // differently because there could be outstanding references on other 25 // differently because there could be outstanding references on other
26 // threads. ShutdownOnUIThread() will be called on the UI thread, and then the 26 // threads. ShutdownOnUIThread() will be called on the UI thread, and then the
27 // destructor will run when the last reference is dropped, which may or may not 27 // destructor will run when the last reference is dropped, which may or may not
28 // be after the corresponding Profile has been destroyed. 28 // be after the corresponding BrowserContext has been destroyed.
29 // 29 //
30 // Optionally, if you initialize your service with the constructor that takes a 30 // Optionally, if you initialize your service with the constructor that takes a
31 // thread ID, your service will be deleted on that thread. We can't use 31 // thread ID, your service will be deleted on that thread. We can't use
32 // content::DeleteOnThread<> directly because RefcountedProfileKeyedService 32 // content::DeleteOnThread<> directly because
33 // must be one type that RefcountedProfileKeyedServiceFactory can use. 33 // RefcountedBrowserContextKeyedService must be one type that
34 class RefcountedProfileKeyedService 34 // RefcountedBrowserContextKeyedServiceFactory can use.
35 class RefcountedBrowserContextKeyedService
35 : public base::RefCountedThreadSafe< 36 : public base::RefCountedThreadSafe<
36 RefcountedProfileKeyedService, 37 RefcountedBrowserContextKeyedService,
37 impl::RefcountedProfileKeyedServiceTraits> { 38 impl::RefcountedBrowserContextKeyedServiceTraits> {
38 public: 39 public:
39 // Unlike ProfileKeyedService, ShutdownOnUI is not optional. You must do 40 // Unlike BrowserContextKeyedService, ShutdownOnUI is not optional. You must
40 // something to drop references during the first pass Shutdown() because this 41 // do something to drop references during the first pass Shutdown() because
41 // is the only point where you are guaranteed that something is running on 42 // this is the only point where you are guaranteed that something is running
42 // the UI thread. The PKSF framework will ensure that this is only called on 43 // on the UI thread. The PKSF framework will ensure that this is only called
43 // the UI thread; you do not need to check for that yourself. 44 // on the UI thread; you do not need to check for that yourself.
44 virtual void ShutdownOnUIThread() = 0; 45 virtual void ShutdownOnUIThread() = 0;
45 46
46 protected: 47 protected:
47 // If your service does not need to be deleted on a specific thread, use the 48 // If your service does not need to be deleted on a specific thread, use the
48 // default constructor. 49 // default constructor.
49 RefcountedProfileKeyedService(); 50 RefcountedBrowserContextKeyedService();
50 51
51 // If you need your service to be deleted on a specific thread (for example, 52 // 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 53 // you're converting a service that used content::DeleteOnThread<IO>), then
53 // use this constructor with the ID of the thread. 54 // use this constructor with the ID of the thread.
54 explicit RefcountedProfileKeyedService( 55 explicit RefcountedBrowserContextKeyedService(
55 const content::BrowserThread::ID thread_id); 56 const content::BrowserThread::ID thread_id);
56 57
57 // The second pass destruction can happen anywhere unless you specify which 58 // 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 // thread this service must be destroyed on by using the second constructor.
59 virtual ~RefcountedProfileKeyedService(); 60 virtual ~RefcountedBrowserContextKeyedService();
60 61
61 private: 62 private:
62 friend struct impl::RefcountedProfileKeyedServiceTraits; 63 friend struct impl::RefcountedBrowserContextKeyedServiceTraits;
63 friend class base::DeleteHelper<RefcountedProfileKeyedService>; 64 friend class base::DeleteHelper<RefcountedBrowserContextKeyedService>;
64 65
65 // Do we have to delete this object on a specific thread? 66 // Do we have to delete this object on a specific thread?
66 bool requires_destruction_on_thread_; 67 bool requires_destruction_on_thread_;
67 content::BrowserThread::ID thread_id_; 68 content::BrowserThread::ID thread_id_;
68 }; 69 };
69 70
70 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_REFCOUNTED_BROWSER_CONTEXT_K EYED_SERVICE_H_ 71 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_REFCOUNTED_BROWSER_CONTEXT_K EYED_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698