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

Side by Side Diff: chrome/browser/profiles/profile_destroyer.h

Issue 15854011: Moving ProfileDestroyer from ref counting to WeakPtr. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_destroyer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/timer.h" 11 #include "base/timer.h"
12 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
14 14
15 class Profile; 15 class Profile;
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 22 class ProfileDestroyer
23 : public content::NotificationObserver, 23 : public content::NotificationObserver {
24 public base::RefCounted<ProfileDestroyer> {
25 public: 24 public:
26 static void DestroyProfileWhenAppropriate(Profile* const profile); 25 static void DestroyProfileWhenAppropriate(Profile* const profile);
27 static void DestroyOffTheRecordProfileNow(Profile* const profile); 26 static void DestroyOffTheRecordProfileNow(Profile* const profile);
28 27
29 private: 28 private:
30 friend class base::RefCounted<ProfileDestroyer>; 29 friend class base::RefCounted<ProfileDestroyer>;
31 30
32 ProfileDestroyer( 31 ProfileDestroyer(
33 Profile* const profile, 32 Profile* const profile,
34 const std::vector<content::RenderProcessHost*>& hosts); 33 const std::vector<content::RenderProcessHost*>& hosts);
(...skipping 19 matching lines...) Expand all
54 content::NotificationRegistrar registrar_; 53 content::NotificationRegistrar registrar_;
55 54
56 // We don't want to wait forever, so we have a cancellation timer. 55 // We don't want to wait forever, so we have a cancellation timer.
57 base::Timer timer_; 56 base::Timer timer_;
58 57
59 // Used to count down the number of render process host left. 58 // Used to count down the number of render process host left.
60 uint32 num_hosts_; 59 uint32 num_hosts_;
61 60
62 Profile* profile_; 61 Profile* profile_;
63 62
63 base::WeakPtrFactory<ProfileDestroyer> weak_ptr_factory_;
64
64 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyer); 65 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyer);
65 }; 66 };
66 67
67 #endif // CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_ 68 #endif // CHROME_BROWSER_PROFILES_PROFILE_DESTROYER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_destroyer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698