Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / browsing_data / local_data_container.h
blob575e2f0518e16e8436590aae67b45b057805fa49
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.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_LOCAL_DATA_CONTAINER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_LOCAL_DATA_CONTAINER_H_
8 #include <list>
9 #include <map>
10 #include <string>
11 #include <vector>
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h"
16 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h"
17 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h"
18 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
19 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
20 #include "chrome/browser/browsing_data/browsing_data_database_helper.h"
21 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
22 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
23 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
24 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h"
25 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h"
26 #include "net/ssl/channel_id_store.h"
28 class BrowsingDataFlashLSOHelper;
29 class CookiesTreeModel;
30 class LocalDataContainer;
32 namespace net {
33 class CanonicalCookie;
36 // Friendly typedefs for the multiple types of lists used in the model.
37 namespace {
39 typedef std::list<net::CanonicalCookie> CookieList;
40 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList;
41 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>
42 LocalStorageInfoList;
43 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>
44 SessionStorageInfoList;
45 typedef std::list<content::IndexedDBInfo>
46 IndexedDBInfoList;
47 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo>
48 FileSystemInfoList;
49 typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoList;
50 typedef net::ChannelIDStore::ChannelIDList ChannelIDList;
51 typedef std::list<content::ServiceWorkerUsageInfo> ServiceWorkerUsageInfoList;
52 typedef std::list<content::CacheStorageUsageInfo> CacheStorageUsageInfoList;
53 typedef std::map<GURL, std::list<content::AppCacheInfo> > AppCacheInfoMap;
54 typedef std::vector<std::string> FlashLSODomainList;
56 } // namespace
58 // LocalDataContainer ---------------------------------------------------------
59 // This class is a wrapper around all the BrowsingData*Helper classes. Because
60 // isolated applications have separate storage, we need different helper
61 // instances. As such, this class contains the app name and id, along with the
62 // helpers for all of the data types we need. The browser-wide "app id" will be
63 // the empty string, as no app can have an empty id.
64 class LocalDataContainer {
65 public:
66 LocalDataContainer(BrowsingDataCookieHelper* cookie_helper,
67 BrowsingDataDatabaseHelper* database_helper,
68 BrowsingDataLocalStorageHelper* local_storage_helper,
69 BrowsingDataLocalStorageHelper* session_storage_helper,
70 BrowsingDataAppCacheHelper* appcache_helper,
71 BrowsingDataIndexedDBHelper* indexed_db_helper,
72 BrowsingDataFileSystemHelper* file_system_helper,
73 BrowsingDataQuotaHelper* quota_helper,
74 BrowsingDataChannelIDHelper* channel_id_helper,
75 BrowsingDataServiceWorkerHelper* service_worker_helper,
76 BrowsingDataCacheStorageHelper* cache_storage_helper,
77 BrowsingDataFlashLSOHelper* flash_data_helper);
78 virtual ~LocalDataContainer();
80 // This method must be called to start the process of fetching the resources.
81 // The delegate passed in is called back to deliver the updates.
82 void Init(CookiesTreeModel* delegate);
84 private:
85 friend class CookiesTreeModel;
86 friend class CookieTreeAppCacheNode;
87 friend class CookieTreeCookieNode;
88 friend class CookieTreeDatabaseNode;
89 friend class CookieTreeLocalStorageNode;
90 friend class CookieTreeSessionStorageNode;
91 friend class CookieTreeIndexedDBNode;
92 friend class CookieTreeFileSystemNode;
93 friend class CookieTreeQuotaNode;
94 friend class CookieTreeChannelIDNode;
95 friend class CookieTreeServiceWorkerNode;
96 friend class CookieTreeCacheStorageNode;
97 friend class CookieTreeFlashLSONode;
99 // Callback methods to be invoked when fetching the data is complete.
100 void OnAppCacheModelInfoLoaded(
101 scoped_refptr<content::AppCacheInfoCollection>);
102 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list);
103 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info);
104 void OnLocalStorageModelInfoLoaded(
105 const LocalStorageInfoList& local_storage_info);
106 void OnSessionStorageModelInfoLoaded(
107 const LocalStorageInfoList& local_storage_info);
108 void OnIndexedDBModelInfoLoaded(
109 const IndexedDBInfoList& indexed_db_info);
110 void OnFileSystemModelInfoLoaded(
111 const FileSystemInfoList& file_system_info);
112 void OnQuotaModelInfoLoaded(const QuotaInfoList& quota_info);
113 void OnChannelIDModelInfoLoaded(const ChannelIDList& channel_id_list);
114 void OnServiceWorkerModelInfoLoaded(
115 const ServiceWorkerUsageInfoList& service_worker_info);
116 void OnCacheStorageModelInfoLoaded(
117 const CacheStorageUsageInfoList& cache_storage_info);
118 void OnFlashLSOInfoLoaded(const FlashLSODomainList& domains);
120 // Pointers to the helper objects, needed to retreive all the types of locally
121 // stored data.
122 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_;
123 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_;
124 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_;
125 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_;
126 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_;
127 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_;
128 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_;
129 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_;
130 scoped_refptr<BrowsingDataChannelIDHelper> channel_id_helper_;
131 scoped_refptr<BrowsingDataServiceWorkerHelper> service_worker_helper_;
132 scoped_refptr<BrowsingDataCacheStorageHelper> cache_storage_helper_;
133 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper_;
135 // Storage for all the data that was retrieved through the helper objects.
136 // The collected data is used for (re)creating the CookiesTreeModel.
137 AppCacheInfoMap appcache_info_;
138 CookieList cookie_list_;
139 DatabaseInfoList database_info_list_;
140 LocalStorageInfoList local_storage_info_list_;
141 LocalStorageInfoList session_storage_info_list_;
142 IndexedDBInfoList indexed_db_info_list_;
143 FileSystemInfoList file_system_info_list_;
144 QuotaInfoList quota_info_list_;
145 ChannelIDList channel_id_list_;
146 ServiceWorkerUsageInfoList service_worker_info_list_;
147 CacheStorageUsageInfoList cache_storage_info_list_;
148 FlashLSODomainList flash_lso_domain_list_;
150 // A delegate, which must outlive this object. The update callbacks use the
151 // delegate to deliver the updated data to the CookieTreeModel.
152 CookiesTreeModel* model_ = nullptr;
154 // Keeps track of how many batches are expected to start.
155 int batches_started_ = 0;
157 base::WeakPtrFactory<LocalDataContainer> weak_ptr_factory_;
159 DISALLOW_COPY_AND_ASSIGN(LocalDataContainer);
162 #endif // CHROME_BROWSER_BROWSING_DATA_LOCAL_DATA_CONTAINER_H_