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

Side by Side Diff: chrome/browser/browsing_data_file_system_helper.h

Issue 7063020: Adding `browsing_data_filesystem_helper*` as the first step towards content settings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaning up based on Jochen and Eric's feedback Created 9 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/callback_old.h"
13 #include "base/file_path.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/synchronization/lock.h"
17 #include "base/time.h"
18 #include "chrome/common/url_constants.h"
19 #include "googleurl/src/gurl.h"
20 #include "webkit/fileapi/file_system_types.h"
21
22 class Profile;
23
24 // BrowsingDataFileSystemHelper is an interface for classes dealing with
25 // aggregating and deleting browsing data stored in local filesystems. A
26 // client of this class needs to call StartFetching from the UI thread to
27 // initiate the flow, and it'll be notified by the callback in its UI thread at
28 // some later point. The client must call CancelNotification() if it's
29 // destroyed before the callback is notified.
30 class BrowsingDataFileSystemHelper
31 : public base::RefCountedThreadSafe<BrowsingDataFileSystemHelper> {
32 public:
33 // Contains detailed information about a filesystem
34 struct FileSystemInfo {
35 FileSystemInfo(
36 const GURL& origin,
37 bool has_persistent,
38 bool has_temporary);
39 ~FileSystemInfo();
40
41 bool IsFileSchemeData() {
42 return origin.scheme() == chrome::kFileScheme;
43 }
44
45 GURL origin;
46 bool has_persistent;
47 bool has_temporary;
48 };
49
50 // Create a BrowsingDataFileSystemHelper instance for the filesystems
51 // stored in |profile|'s user data directory.
52 static BrowsingDataFileSystemHelper* Create(Profile* profile);
53
54 // Starts the fetching process, which will notify its completion via
55 // callback.
56 // This must be called only in the UI thread.
57 virtual void StartFetching(
58 Callback1<const std::vector<FileSystemInfo>& >::Type* callback) = 0;
59 // Cancels the notification callback (i.e., the window that created it no
60 // longer exists).
61 // This must be called only in the UI thread.
62 virtual void CancelNotification() = 0;
63 // Requests a single filesystem to be deleted in the FILE thread.
64 virtual void DeleteFileSystemOrigin(const GURL& origin) = 0;
65
66 virtual ~BrowsingDataFileSystemHelper() {}
kinuko 2011/05/25 10:24:41 does this destructor need to be public?
Mike West 2011/05/25 12:00:01 Probably not.
67 protected:
68 friend class base::RefCountedThreadSafe<BrowsingDataFileSystemHelper>;
69 };
70
71 // This class is an implementation of BrowsingDataFileSystemHelper that does
72 // not fetch its information from the filesystem tracker, but gets it passed
73 // in as a parameter.
74 class CannedBrowsingDataFileSystemHelper
75 : public BrowsingDataFileSystemHelper {
76 public:
77 explicit CannedBrowsingDataFileSystemHelper(Profile* profile);
78
79 // Return a copy of the filesystem helper. Only one consumer can use the
80 // StartFetching method at a time, so we need to create a copy of the helper
81 // everytime we instantiate a cookies tree model for it.
82 CannedBrowsingDataFileSystemHelper* Clone();
83
84 // Add a filesystem to the set of canned filesystems that is
85 // returned by this helper.
86 void AddFileSystem(const GURL& origin,
87 fileapi::FileSystemType type);
88
89 // Clear the list of canned filesystems.
90 void Reset();
91
92 // True if no filesystems are currently stored.
93 bool empty() const;
94
95 // BrowsingDataFileSystemHelper methods.
96 virtual void StartFetching(
97 Callback1<const std::vector<FileSystemInfo>& >::Type* callback);
98 virtual void CancelNotification() {}
99 virtual void DeleteFileSystemOrigin(const GURL& origin) {}
100
101 private:
102 struct PendingFileSystemInfo {
103 PendingFileSystemInfo();
104 PendingFileSystemInfo(const GURL& origin, fileapi::FileSystemType type);
105 ~PendingFileSystemInfo();
106
107 GURL origin;
108 fileapi::FileSystemType type;
109 };
110
111 virtual ~CannedBrowsingDataFileSystemHelper();
112
113 void ConvertPendingInfo();
114
115 void Notify();
116
117 Profile* profile_;
118
119 // Lock to protect access to pending_file_system_info_;
120 mutable base::Lock lock_;
kinuko 2011/05/25 10:24:41 After all do we access pending_file_system_info_ o
Mike West 2011/05/25 12:00:01 Done.
121
122 std::vector<PendingFileSystemInfo> pending_file_system_info_;
123
124 std::vector<FileSystemInfo> file_system_info_;
125
126 scoped_ptr<Callback1<const std::vector<FileSystemInfo>& >::Type >
127 completion_callback_;
128
129 // Indicates whether or not we're currently fetching information:
130 // it's true when StartFetching() is called in the UI thread, and it's reset
131 // after we notified the callback in the UI thread.
132 // This only mutates on the UI thread.
133 bool is_fetching_;
134
135 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper);
136 };
137
138 #endif // CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698