OLD | NEW |
(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_LOCAL_DATA_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DATA_CONTAINER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/string16.h" |
| 12 #include "chrome/browser/browsing_data_appcache_helper.h" |
| 13 #include "chrome/browser/browsing_data_cookie_helper.h" |
| 14 #include "chrome/browser/browsing_data_database_helper.h" |
| 15 #include "chrome/browser/browsing_data_file_system_helper.h" |
| 16 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 17 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 18 #include "chrome/browser/browsing_data_quota_helper.h" |
| 19 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" |
| 20 #include "net/base/server_bound_cert_store.h" |
| 21 #include "net/cookies/cookie_monster.h" |
| 22 |
| 23 class LocalDataContainer; |
| 24 class CookiesTreeModelDelegate; |
| 25 |
| 26 // Friendly typedefs for the multiple types of lists used in the model. |
| 27 namespace { |
| 28 |
| 29 typedef std::map<std::string, LocalDataContainer*> ContainerMap; |
| 30 typedef std::list<net::CookieMonster::CanonicalCookie> CookieList; |
| 31 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList; |
| 32 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 33 LocalStorageInfoList; |
| 34 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 35 SessionStorageInfoList; |
| 36 typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> |
| 37 IndexedDBInfoList; |
| 38 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> |
| 39 FileSystemInfoList; |
| 40 typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoList; |
| 41 typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList; |
| 42 typedef std::map<GURL, std::list<appcache::AppCacheInfo> > AppCacheInfoMap; |
| 43 |
| 44 } // namespace |
| 45 |
| 46 // LocalDataContainer --------------------------------------------------------- |
| 47 // This class is a wrapper around all the BrowsingData*Helper classes. Because |
| 48 // isolated applications have separate storage, we need different helper |
| 49 // instances. As such, this class contains the app name and id, along with the |
| 50 // helpers for all of the data types we need. The browser-wide "app id" will be |
| 51 // the empty string, as no app can have empty id. |
| 52 class LocalDataContainer { |
| 53 public: |
| 54 LocalDataContainer( |
| 55 const std::string& app_name, |
| 56 const std::string& app_id, |
| 57 BrowsingDataCookieHelper* cookie_helper, |
| 58 BrowsingDataDatabaseHelper* database_helper, |
| 59 BrowsingDataLocalStorageHelper* local_storage_helper, |
| 60 BrowsingDataLocalStorageHelper* session_storage_helper, |
| 61 BrowsingDataAppCacheHelper* appcache_helper, |
| 62 BrowsingDataIndexedDBHelper* indexed_db_helper, |
| 63 BrowsingDataFileSystemHelper* file_system_helper, |
| 64 BrowsingDataQuotaHelper* quota_helper, |
| 65 BrowsingDataServerBoundCertHelper* server_bound_cert_helper); |
| 66 virtual ~LocalDataContainer(); |
| 67 |
| 68 // This method must be called to start the process of fetching the resources. |
| 69 // The delegate passed in is called back to deliver the updates. |
| 70 void Init(CookiesTreeModelDelegate* delegate); |
| 71 |
| 72 const std::string& app_name() { return app_name_; } |
| 73 const std::string& app_id() { return app_id_; } |
| 74 |
| 75 private: |
| 76 friend class CookiesTreeModel; |
| 77 friend class CookieTreeAppCacheNode; |
| 78 friend class CookieTreeCookieNode; |
| 79 friend class CookieTreeDatabaseNode; |
| 80 friend class CookieTreeLocalStorageNode; |
| 81 friend class CookieTreeSessionStorageNode; |
| 82 friend class CookieTreeIndexedDBNode; |
| 83 friend class CookieTreeFileSystemNode; |
| 84 friend class CookieTreeQuotaNode; |
| 85 friend class CookieTreeServerBoundCertNode; |
| 86 |
| 87 // Callback methods to be invoked when fetching the data is complete. |
| 88 void OnAppCacheModelInfoLoaded(); |
| 89 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); |
| 90 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); |
| 91 void OnLocalStorageModelInfoLoaded( |
| 92 const LocalStorageInfoList& local_storage_info); |
| 93 void OnSessionStorageModelInfoLoaded( |
| 94 const LocalStorageInfoList& local_storage_info); |
| 95 void OnIndexedDBModelInfoLoaded( |
| 96 const IndexedDBInfoList& indexed_db_info); |
| 97 void OnFileSystemModelInfoLoaded( |
| 98 const FileSystemInfoList& file_system_info); |
| 99 void OnQuotaModelInfoLoaded(const QuotaInfoList& quota_info); |
| 100 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list); |
| 101 |
| 102 // The app name and id, to which this container object is for. |
| 103 std::string app_name_; |
| 104 std::string app_id_; |
| 105 |
| 106 // Pointers to the helper objects, needed to retreive all the types of locally |
| 107 // stored data. |
| 108 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
| 109 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; |
| 110 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
| 111 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
| 112 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; |
| 113 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
| 114 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
| 115 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; |
| 116 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_; |
| 117 |
| 118 // Storage for all the data that was retrieved through the helper objects. |
| 119 // The collected data is used for (re)creating the CookiesTreeModel. |
| 120 AppCacheInfoMap appcache_info_; |
| 121 CookieList cookie_list_; |
| 122 DatabaseInfoList database_info_list_; |
| 123 LocalStorageInfoList local_storage_info_list_; |
| 124 LocalStorageInfoList session_storage_info_list_; |
| 125 IndexedDBInfoList indexed_db_info_list_; |
| 126 FileSystemInfoList file_system_info_list_; |
| 127 QuotaInfoList quota_info_list_; |
| 128 ServerBoundCertList server_bound_cert_list_; |
| 129 |
| 130 // A delegate, which must outlive this object. The update callbacks use the |
| 131 // delegate to deliver the updated data to the CookieTreeModel. |
| 132 CookiesTreeModelDelegate* delegate_; |
| 133 |
| 134 base::WeakPtrFactory<LocalDataContainer> weak_ptr_factory_; |
| 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(LocalDataContainer); |
| 137 }; |
| 138 |
| 139 #endif // CHROME_BROWSER_LOCAL_DATA_CONTAINER_H_ |
OLD | NEW |