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" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "content/public/browser/render_process_host_observer.h" | 12 #include "content/public/browser/render_process_host_observer.h" |
13 | 13 |
14 class Profile; | 14 class Profile; |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class RenderProcessHost; | 17 class RenderProcessHost; |
18 } | 18 } |
19 | 19 |
20 // We use this class to destroy the off the record profile so that we can make | 20 // We use this class to destroy the off the record profile so that we can make |
21 // sure it gets done asynchronously after all render process hosts are gone. | 21 // sure it gets done asynchronously after all render process hosts are gone. |
22 class ProfileDestroyer : public content::RenderProcessHostObserver { | 22 class ProfileDestroyer : public content::RenderProcessHostObserver { |
23 public: | 23 public: |
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 // If the Guest Profile is ready to be destroyed, do so. |
| 28 static void DestroyGuestProfileIfAppropriate(); |
| 29 |
27 private: | 30 private: |
28 typedef std::set<content::RenderProcessHost*> HostSet; | 31 typedef std::set<content::RenderProcessHost*> HostSet; |
29 typedef std::set<ProfileDestroyer*> DestroyerSet; | 32 typedef std::set<ProfileDestroyer*> DestroyerSet; |
30 | 33 |
31 friend class base::RefCounted<ProfileDestroyer>; | 34 friend class base::RefCounted<ProfileDestroyer>; |
32 | 35 |
33 ProfileDestroyer(Profile* const profile, HostSet* hosts); | 36 ProfileDestroyer(Profile* const profile, HostSet* hosts); |
34 ~ProfileDestroyer() override; | 37 ~ProfileDestroyer() override; |
35 | 38 |
36 // content::RenderProcessHostObserver override. | 39 // content::RenderProcessHostObserver override. |
(...skipping 18 matching lines...) Expand all Loading... |
55 // The profile being destroyed. If it is set to NULL, it is a signal from | 58 // The profile being destroyed. If it is set to NULL, it is a signal from |
56 // another instance of ProfileDestroyer that this instance is canceled. | 59 // another instance of ProfileDestroyer that this instance is canceled. |
57 Profile* profile_; | 60 Profile* profile_; |
58 | 61 |
59 base::WeakPtrFactory<ProfileDestroyer> weak_ptr_factory_; | 62 base::WeakPtrFactory<ProfileDestroyer> weak_ptr_factory_; |
60 | 63 |
61 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyer); | 64 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyer); |
62 }; | 65 }; |
63 | 66 |
64 #endif // CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ | 67 #endif // CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ |
OLD | NEW |