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_PROFILE_DESTROYER_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 static void DestroyProfileWhenAppropriate(Profile* const profile); | 24 static void DestroyProfileWhenAppropriate(Profile* const profile); |
25 static void DestroyOffTheRecordProfileNow(Profile* const profile); | 25 static void DestroyOffTheRecordProfileNow(Profile* const profile); |
26 | 26 |
27 private: | 27 private: |
28 typedef std::set<content::RenderProcessHost*> HostSet; | 28 typedef std::set<content::RenderProcessHost*> HostSet; |
29 typedef std::set<ProfileDestroyer*> DestroyerSet; | 29 typedef std::set<ProfileDestroyer*> DestroyerSet; |
30 | 30 |
31 friend class base::RefCounted<ProfileDestroyer>; | 31 friend class base::RefCounted<ProfileDestroyer>; |
32 | 32 |
33 ProfileDestroyer(Profile* const profile, HostSet* hosts); | 33 ProfileDestroyer(Profile* const profile, HostSet* hosts); |
34 virtual ~ProfileDestroyer(); | 34 ~ProfileDestroyer() override; |
35 | 35 |
36 // content::RenderProcessHostObserver override. | 36 // content::RenderProcessHostObserver override. |
37 virtual void RenderProcessHostDestroyed( | 37 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; |
38 content::RenderProcessHost* host) override; | |
39 | 38 |
40 // Called by the timer to cancel the pending destruction and do it now. | 39 // Called by the timer to cancel the pending destruction and do it now. |
41 void DestroyProfile(); | 40 void DestroyProfile(); |
42 | 41 |
43 // Fetch the list of render process hosts that still refer to the profile. | 42 // Fetch the list of render process hosts that still refer to the profile. |
44 // Return true if we found at least one, false otherwise. | 43 // Return true if we found at least one, false otherwise. |
45 static bool GetHostsForProfile(Profile* const profile, HostSet* hosts); | 44 static bool GetHostsForProfile(Profile* const profile, HostSet* hosts); |
46 | 45 |
47 // We need access to all pending destroyers so we can cancel them. | 46 // We need access to all pending destroyers so we can cancel them. |
48 static DestroyerSet* pending_destroyers_; | 47 static DestroyerSet* pending_destroyers_; |
49 | 48 |
50 // We don't want to wait forever, so we have a cancellation timer. | 49 // We don't want to wait forever, so we have a cancellation timer. |
51 base::Timer timer_; | 50 base::Timer timer_; |
52 | 51 |
53 // Used to count down the number of render process host left. | 52 // Used to count down the number of render process host left. |
54 uint32 num_hosts_; | 53 uint32 num_hosts_; |
55 | 54 |
56 // The profile being destroyed. If it is set to NULL, it is a signal from | 55 // The profile being destroyed. If it is set to NULL, it is a signal from |
57 // another instance of ProfileDestroyer that this instance is canceled. | 56 // another instance of ProfileDestroyer that this instance is canceled. |
58 Profile* profile_; | 57 Profile* profile_; |
59 | 58 |
60 base::WeakPtrFactory<ProfileDestroyer> weak_ptr_factory_; | 59 base::WeakPtrFactory<ProfileDestroyer> weak_ptr_factory_; |
61 | 60 |
62 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyer); | 61 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyer); |
63 }; | 62 }; |
64 | 63 |
65 #endif // CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ | 64 #endif // CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ |
OLD | NEW |