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

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: Dropping explicit use of UI thread. Created 9 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 | « chrome/DEPS ('k') | chrome/browser/browsing_data_file_system_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 int64 usage_persistent,
40 int64 usage_temporary);
41 ~FileSystemInfo();
42
43 bool IsFileSchemeData() {
44 return origin.scheme() == chrome::kFileScheme;
45 }
46
47 GURL origin;
48 bool has_persistent;
49 bool has_temporary;
50 int64 usage_persistent;
51 int64 usage_temporary;
52 };
53
54 // Create a BrowsingDataFileSystemHelper instance for the filesystems
55 // stored in |profile|'s user data directory.
56 static BrowsingDataFileSystemHelper* Create(Profile* profile);
57
58 // Starts the fetching process, which will notify its completion via
59 // callback.
60 // This must be called only in the UI thread.
61 virtual void StartFetching(
62 Callback1<const std::vector<FileSystemInfo>& >::Type* callback) = 0;
63 // Cancels the notification callback (i.e., the window that created it no
64 // longer exists).
65 // This must be called only in the UI thread.
66 virtual void CancelNotification() = 0;
67 // Requests a single filesystem to be deleted in the FILE thread.
68 virtual void DeleteFileSystemOrigin(const GURL& origin) = 0;
69
70 protected:
71 friend class base::RefCountedThreadSafe<BrowsingDataFileSystemHelper>;
72 virtual ~BrowsingDataFileSystemHelper() {}
73 };
74
75 // This class is an implementation of BrowsingDataFileSystemHelper that does
76 // not fetch its information from the filesystem tracker, but gets it passed
77 // in as a parameter.
78 class CannedBrowsingDataFileSystemHelper
79 : public BrowsingDataFileSystemHelper {
80 public:
81 explicit CannedBrowsingDataFileSystemHelper(Profile* profile);
82
83 // Return a copy of the filesystem helper. Only one consumer can use the
84 // StartFetching method at a time, so we need to create a copy of the helper
85 // everytime we instantiate a cookies tree model for it.
86 CannedBrowsingDataFileSystemHelper* Clone();
87
88 // Add a filesystem to the set of canned filesystems that is
89 // returned by this helper.
90 void AddFileSystem(const GURL& origin,
91 fileapi::FileSystemType type,
92 int64 size);
93
94 // Clear the list of canned filesystems.
95 void Reset();
96
97 // True if no filesystems are currently stored.
98 bool empty() const;
99
100 // BrowsingDataFileSystemHelper methods.
101 virtual void StartFetching(
102 Callback1<const std::vector<FileSystemInfo>& >::Type* callback);
103 virtual void CancelNotification() {}
104 virtual void DeleteFileSystemOrigin(const GURL& origin) {}
105
106 private:
107 struct PendingFileSystemInfo {
108 PendingFileSystemInfo();
109 PendingFileSystemInfo(const GURL& origin,
110 fileapi::FileSystemType type,
111 int64 size);
112 ~PendingFileSystemInfo();
113
114 GURL origin;
115 fileapi::FileSystemType type;
116 int64 size;
117 };
118
119 // StartFetching's callback should be executed asynchronously, Notify handles
120 // that nicely.
121 void Notify();
122
123 virtual ~CannedBrowsingDataFileSystemHelper();
124
125 Profile* profile_;
126
127 std::vector<PendingFileSystemInfo> pending_file_system_info_;
128
129 std::vector<FileSystemInfo> file_system_info_;
130
131 scoped_ptr<Callback1<const std::vector<FileSystemInfo>& >::Type >
132 completion_callback_;
133
134 // Indicates whether or not we're currently fetching information:
135 // it's true when StartFetching() is called in the UI thread, and it's reset
136 // after we notified the callback in the UI thread.
137 // This only mutates on the UI thread.
138 bool is_fetching_;
139
140 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper);
141 };
142
143 #endif // CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/DEPS ('k') | chrome/browser/browsing_data_file_system_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698