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