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

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

Issue 10805015: Move browsing_data_helper files into a separate directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chrome_frame build Created 8 years, 5 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) 2012 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_LOCAL_STORAGE_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_
7
8 #include <list>
9 #include <set>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/file_path.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/synchronization/lock.h"
17 #include "base/time.h"
18 #include "content/public/browser/dom_storage_context.h"
19 #include "chrome/common/url_constants.h"
20 #include "googleurl/src/gurl.h"
21
22 class Profile;
23
24 // This class fetches local storage information and provides a
25 // means to delete the data associated with an origin.
26 class BrowsingDataLocalStorageHelper
27 : public base::RefCounted<BrowsingDataLocalStorageHelper> {
28 public:
29 // Contains detailed information about local storage.
30 struct LocalStorageInfo {
31 LocalStorageInfo(
32 const GURL& origin_url,
33 int64 size,
34 base::Time last_modified);
35 ~LocalStorageInfo();
36
37 GURL origin_url;
38 int64 size;
39 base::Time last_modified;
40 };
41
42 explicit BrowsingDataLocalStorageHelper(Profile* profile);
43
44 // Starts the fetching process, which will notify its completion via
45 // callback. This must be called only in the UI thread.
46 virtual void StartFetching(
47 const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback);
48
49 // Deletes the local storage for the |origin|.
50 virtual void DeleteOrigin(const GURL& origin);
51
52 protected:
53 friend class base::RefCounted<BrowsingDataLocalStorageHelper>;
54 virtual ~BrowsingDataLocalStorageHelper();
55
56 void CallCompletionCallback();
57
58 content::DOMStorageContext* dom_storage_context_; // Owned by the profile
59 base::Callback<void(const std::list<LocalStorageInfo>&)> completion_callback_;
60 bool is_fetching_;
61 std::list<LocalStorageInfo> local_storage_info_;
62
63 private:
64 void GetUsageInfoCallback(
65 const std::vector<dom_storage::DomStorageContext::UsageInfo>& infos);
66
67 DISALLOW_COPY_AND_ASSIGN(BrowsingDataLocalStorageHelper);
68 };
69
70 // This class is a thin wrapper around BrowsingDataLocalStorageHelper that does
71 // not fetch its information from the local storage tracker, but gets them
72 // passed as a parameter during construction.
73 class CannedBrowsingDataLocalStorageHelper
74 : public BrowsingDataLocalStorageHelper {
75 public:
76 explicit CannedBrowsingDataLocalStorageHelper(Profile* profile);
77
78 // Return a copy of the local storage helper. Only one consumer can use the
79 // StartFetching method at a time, so we need to create a copy of the helper
80 // every time we instantiate a cookies tree model for it.
81 CannedBrowsingDataLocalStorageHelper* Clone();
82
83 // Add a local storage to the set of canned local storages that is returned
84 // by this helper.
85 void AddLocalStorage(const GURL& origin);
86
87 // Clear the list of canned local storages.
88 void Reset();
89
90 // True if no local storages are currently stored.
91 bool empty() const;
92
93 // Returns the number of local storages currently stored.
94 size_t GetLocalStorageCount() const;
95
96 // Returns the set of origins that use local storage.
97 const std::set<GURL>& GetLocalStorageInfo() const;
98
99 // BrowsingDataLocalStorageHelper implementation.
100 virtual void StartFetching(
101 const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback)
102 OVERRIDE;
103
104 private:
105 virtual ~CannedBrowsingDataLocalStorageHelper();
106
107 // Convert the pending local storage info to local storage info objects.
108 void ConvertPendingInfo();
109
110 std::set<GURL> pending_local_storage_info_;
111
112 Profile* profile_;
113
114 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataLocalStorageHelper);
115 };
116
117 #endif // CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_indexed_db_helper_unittest.cc ('k') | chrome/browser/browsing_data_local_storage_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698