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

Side by Side Diff: content/browser/storage_partition_impl_map.h

Issue 11419307: Garbage Collect the Storage directory on next profile start after an extension uninstall. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: done done Created 8 years 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 | « content/browser/site_instance_impl.cc ('k') | content/browser/storage_partition_impl_map.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 CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ 5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_
6 #define CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ 6 #define CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/hash_tables.h"
13 #include "base/supports_user_data.h" 14 #include "base/supports_user_data.h"
14 #include "content/browser/storage_partition_impl.h" 15 #include "content/browser/storage_partition_impl.h"
15 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
16 17
17 class FilePath; 18 class FilePath;
18 19
20 namespace base {
21 class SequencedTaskRunner;
22 } // namespace base
23
19 namespace content { 24 namespace content {
20 25
21 class BrowserContext; 26 class BrowserContext;
22 27
23 // A std::string to StoragePartition map for use with SupportsUserData APIs. 28 // A std::string to StoragePartition map for use with SupportsUserData APIs.
24 class StoragePartitionImplMap : public base::SupportsUserData::Data { 29 class StoragePartitionImplMap : public base::SupportsUserData::Data {
25 public: 30 public:
26 explicit StoragePartitionImplMap(BrowserContext* browser_context); 31 explicit StoragePartitionImplMap(BrowserContext* browser_context);
27 32
28 virtual ~StoragePartitionImplMap(); 33 virtual ~StoragePartitionImplMap();
29 34
30 // This map retains ownership of the returned StoragePartition objects. 35 // This map retains ownership of the returned StoragePartition objects.
31 StoragePartitionImpl* Get(const std::string& partition_domain, 36 StoragePartitionImpl* Get(const std::string& partition_domain,
32 const std::string& partition_name, 37 const std::string& partition_name,
33 bool in_memory); 38 bool in_memory);
34 39
35 // Starts an asynchronous best-effort attempt to delete all on-disk storage 40 // Starts an asynchronous best-effort attempt to delete all on-disk storage
36 // related to |site|, avoiding any directories that are known to be in use. 41 // related to |site|, avoiding any directories that are known to be in use.
37 void AsyncObliterate(const GURL& site); 42 //
43 // |on_gc_required| is called if the AsyncObliterate() call was unable to
44 // fully clean the on-disk storage requiring a call to GarbageCollect() on
45 // the next browser start.
46 void AsyncObliterate(const GURL& site, const base::Closure& on_gc_required);
47
48 // Examines the on-disk storage and removes any entires that are not listed
49 // in the |active_paths|, or in use by current entries in the storage
50 // partition.
51 //
52 // The |done| closure is executed on the calling thread when garbage
53 // collection is complete.
54 void GarbageCollect(scoped_ptr<base::hash_set<FilePath> > active_paths,
55 const base::Closure& done);
38 56
39 void ForEach(const BrowserContext::StoragePartitionCallback& callback); 57 void ForEach(const BrowserContext::StoragePartitionCallback& callback);
40 58
41 private: 59 private:
42 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); 60 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess);
43 61
44 // Each StoragePartition is uniquely identified by which partition domain 62 // Each StoragePartition is uniquely identified by which partition domain
45 // it belongs to (such as an app or the browser itself), the user supplied 63 // it belongs to (such as an app or the browser itself), the user supplied
46 // partition name and the bit indicating whether it should be persisted on 64 // partition name and the bit indicating whether it should be persisted on
47 // disk or not. This structure contains those elements and is used as 65 // disk or not. This structure contains those elements and is used as
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // This must always be called *after* |partition| has been added to the 112 // This must always be called *after* |partition| has been added to the
95 // partitions_. 113 // partitions_.
96 // 114 //
97 // TODO(ajwong): Is there a way to make it so that Get()'s implementation 115 // TODO(ajwong): Is there a way to make it so that Get()'s implementation
98 // doesn't need to be aware of this ordering? Revisit when refactoring 116 // doesn't need to be aware of this ordering? Revisit when refactoring
99 // ResourceContext and AppCache to respect storage partitions. 117 // ResourceContext and AppCache to respect storage partitions.
100 void PostCreateInitialization(StoragePartitionImpl* partition, 118 void PostCreateInitialization(StoragePartitionImpl* partition,
101 bool in_memory); 119 bool in_memory);
102 120
103 BrowserContext* browser_context_; // Not Owned. 121 BrowserContext* browser_context_; // Not Owned.
122 scoped_refptr<base::SequencedTaskRunner> file_access_runner_;
104 PartitionMap partitions_; 123 PartitionMap partitions_;
105 124
106 // Set to true when the ResourceContext for the associated |browser_context_| 125 // Set to true when the ResourceContext for the associated |browser_context_|
107 // is initialized. Can never return to false. 126 // is initialized. Can never return to false.
108 bool resource_context_initialized_; 127 bool resource_context_initialized_;
109 }; 128 };
110 129
111 } // namespace content 130 } // namespace content
112 131
113 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ 132 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_
OLDNEW
« no previous file with comments | « content/browser/site_instance_impl.cc ('k') | content/browser/storage_partition_impl_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698